Skip to content
Open
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
3 changes: 3 additions & 0 deletions docs/users/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Note that there is currently no guarantee for a stable Markdown formatting style
- Fixed
- Read UTF-8 from standard input on all systems.
Thank you, [Christopher Prohm](https://github.com/chmp), for the PR.
- No longer error on emphasis whose content is a whitespace character
reference (e.g. `* *`). The boundary whitespace is now kept in
character reference form so the emphasis markers remain functional.

## 0.7.22

Expand Down
10 changes: 10 additions & 0 deletions src/mdformat/renderer/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,22 @@ def link(node: RenderTreeNode, context: RenderContext) -> str:

def em(node: RenderTreeNode, context: RenderContext) -> str:
text = make_render_children(separator="")(node, context)
# Emphasis can not begin or end in Unicode whitespace, so if it does
# (e.g. the whitespace came from a character reference like ` `),
# re-decimalify the boundary whitespace to keep the markers functional.
text = decimalify_leading(codepoints.UNICODE_WHITESPACE, text)
text = decimalify_trailing(codepoints.UNICODE_WHITESPACE, text)
indicator = node.markup
return indicator + text + indicator


def strong(node: RenderTreeNode, context: RenderContext) -> str:
text = make_render_children(separator="")(node, context)
# Emphasis can not begin or end in Unicode whitespace, so if it does
# (e.g. the whitespace came from a character reference like ` `),
# re-decimalify the boundary whitespace to keep the markers functional.
text = decimalify_leading(codepoints.UNICODE_WHITESPACE, text)
text = decimalify_trailing(codepoints.UNICODE_WHITESPACE, text)
indicator = node.markup
return indicator + text + indicator

Expand Down
14 changes: 14 additions & 0 deletions tests/data/default_style.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,17 @@ Reduce to a space here.

Reduce to a space here.
.

emphasis around whitespace character reference (issue 492)
.
* *
.
* *
.

strong emphasis around named whitespace character reference
.
** **
.
** **
.