Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: image bug, issue #423 #413 #444

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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: 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)
.
Loading