diff --git a/markdown_it/tree.py b/markdown_it/tree.py index a39ba32a..6641e5a4 100644 --- a/markdown_it/tree.py +++ b/markdown_it/tree.py @@ -229,7 +229,12 @@ def pretty( if not self.is_root and self.attrs: text += " " + " ".join(f"{k}={v!r}" for k, v in self.attrs.items()) text += ">" - if show_text and not self.is_root and self.type == "text" and self.content: + if ( + show_text + and not self.is_root + and self.type in ("text", "text_special") + and self.content + ): text += "\n" + textwrap.indent(self.content, prefix + " " * indent) for child in self.children: text += "\n" + child.pretty( diff --git a/tests/test_tree.py b/tests/test_tree.py index c5203b0b..36bd0b67 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -76,6 +76,13 @@ def test_pretty(file_regression): file_regression.check(node.pretty(indent=2, show_text=True), extension=".xml") +def test_pretty_text_special(file_regression): + md = MarkdownIt() + md.disable("text_join") + tree = SyntaxTreeNode(md.parse("foo © bar \\(")) + file_regression.check(tree.pretty(show_text=True), extension=".xml") + + def test_walk(): tokens = MarkdownIt().parse(EXAMPLE_MARKDOWN) tree = SyntaxTreeNode(tokens) diff --git a/tests/test_tree/test_pretty_text_special.xml b/tests/test_tree/test_pretty_text_special.xml new file mode 100644 index 00000000..211d790c --- /dev/null +++ b/tests/test_tree/test_pretty_text_special.xml @@ -0,0 +1,11 @@ + + + + + foo + + © + + bar + + ( \ No newline at end of file