diff --git a/src/mdformat/renderer/_context.py b/src/mdformat/renderer/_context.py index 59ce666..8d80611 100644 --- a/src/mdformat/renderer/_context.py +++ b/src/mdformat/renderer/_context.py @@ -141,6 +141,10 @@ def text(node: RenderTreeNode, context: RenderContext) -> str: return text +def text_special(node: RenderTreeNode, context: RenderContext) -> str: + return node.content + + def fence(node: RenderTreeNode, context: RenderContext) -> str: info_str = node.info.strip() lang = info_str.split(maxsplit=1)[0] if info_str else "" @@ -181,7 +185,8 @@ def code_block(node: RenderTreeNode, context: RenderContext) -> str: def image(node: RenderTreeNode, context: RenderContext) -> str: - description = _render_inline_as_text(node, context) + # description = _render_inline_as_text(node, context) + description = "".join(child.render(context) for child in node.children) if context.do_wrap: # Prevent line breaks @@ -579,6 +584,7 @@ def ordered_list(node: RenderTreeNode, context: RenderContext) -> str: "hardbreak": hardbreak, "softbreak": softbreak, "text": text, + "text_special": text_special, "fence": fence, "code_block": code_block, "link": link, diff --git a/tests/data/default_style.md b/tests/data/default_style.md index 8df54df..3a6c42c 100644 --- a/tests/data/default_style.md +++ b/tests/data/default_style.md @@ -464,3 +464,18 @@ Unicode space (U+3000) after heading . # hoge . + +Keep code span in image description +. +![example](/url) + +![*example*](/url) + +![`example`](/url) +. +![example](/url) + +![*example*](/url) + +![`example`](/url) +.