From 0082a0989ce64ffe1aa13db993fcaee358e0bf1a Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:22:14 +0300 Subject: [PATCH] WIP: image bug, issue #423 #413 --- src/mdformat/renderer/_context.py | 8 +++++++- tests/data/default_style.md | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/mdformat/renderer/_context.py b/src/mdformat/renderer/_context.py index 59ce666..4b6b96c 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) +.