Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion markdown_it/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class NestedTokens:
"""

opening: Token = attr.ib()
closing: Optional[Token] = attr.ib()
closing: Token = attr.ib()
children: List[Union[Token, "NestedTokens"]] = attr.ib(factory=list)

def __getattr__(self, name):
Expand All @@ -144,6 +144,9 @@ def nest_tokens(tokens: List[Token]) -> List[Union[Token, NestedTokens]]:
token = token.copy()
output.append(token)
if token.children:
# Ignore type checkers because `nest_tokens` doesn't respect
# typing of `Token.children`. We add `NestedTokens` into a
# `List[Token]` here.
token.children = nest_tokens(token.children) # type: ignore
continue

Expand Down