Skip to content

Commit

Permalink
WIP: image bug, issue #423 #413
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Oct 3, 2024
1 parent 782cb22 commit 0082a09
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mdformat/renderer/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions tests/data/default_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
.

0 comments on commit 0082a09

Please sign in to comment.