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
8 changes: 4 additions & 4 deletions markdown_it/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ def __init__(self) -> None:
# children (i.e. inline or img)
self.children: List["SyntaxTreeNode"] = []

@staticmethod
def from_tokens(tokens: Sequence[Token]) -> "SyntaxTreeNode":
@classmethod
def from_tokens(cls, tokens: Sequence[Token]) -> "SyntaxTreeNode":
"""Instantiate a `SyntaxTreeNode` from a token stream.

This is the standard method for instantiating `SyntaxTreeNode`.
"""
root = SyntaxTreeNode()
root = cls()
root._set_children_from_tokens(tokens)
return root

Expand Down Expand Up @@ -143,7 +143,7 @@ def _make_child(
"""Make and return a child node for `self`."""
if token and nester_tokens or not token and not nester_tokens:
raise ValueError("must specify either `token` or `nester_tokens`")
child = SyntaxTreeNode()
child = type(self)()
if token:
child.token = token
else:
Expand Down