Fails to substitute (**) with <strong> tags for Japanese and Chinese languages. #650

Closed
opened 2026-01-29 14:42:04 +00:00 by claunia · 3 comments
Owner

Originally created by @ghost on GitHub (Jan 29, 2024).

Method Markdown.ToHtml doesn't convert ** to <strong> when it appears before or after Japanese or Chinese symbols. For other languages, it works as expected.

Example:
Text that I need to convert to html
**如果您需要重新安排教练时间,**请确保在原定教练时间前至少提前 **48 小时**重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档。

The result from Markdig: **如果您需要重新安排教练时间,**请确保在原定教练时间前至少提前 <strong>48 小时</strong>重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档。

The result from Legacy Markdown package: <strong>如果您需要重新安排教练时间,</strong>请确保在原定教练时间前至少提前 <strong>48 小时</strong>重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档。

Could you please provide me with instructions on how to fix this issue correctly?

Originally created by @ghost on GitHub (Jan 29, 2024). Method Markdown.ToHtml doesn't convert ** to `<strong>` when it appears before or after Japanese or Chinese symbols. For other languages, it works as expected. Example: Text that I need to convert to html `**如果您需要重新安排教练时间,**请确保在原定教练时间前至少提前 **48 小时**重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档。` The result from Markdig: `**如果您需要重新安排教练时间,**请确保在原定教练时间前至少提前 <strong>48 小时</strong>重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档。` The result from Legacy Markdown package: `<strong>如果您需要重新安排教练时间,</strong>请确保在原定教练时间前至少提前 <strong>48 小时</strong>重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档。` Could you please provide me with instructions on how to fix this issue correctly?
claunia added the question label 2026-01-29 14:42:04 +00:00
Author
Owner

@xoofx commented on GitHub (Jan 29, 2024):

From the specs emphasis-and-strong-emphasis section:

A left-flanking delimiter run is a delimiter run that is (1) not followed by Unicode whitespace, and either (2a) not followed by a Unicode punctuation character, or (2b) followed by a Unicode punctuation character and preceded by Unicode whitespace or a Unicode punctuation character. For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.

A right-flanking delimiter run is a delimiter run that is (1) not preceded by Unicode whitespace, and either (2a) not preceded by a Unicode punctuation character, or (2b) preceded by a Unicode punctuation character and followed by Unicode whitespace or a Unicode punctuation character. For purposes of this definition, the beginning and the end of the line count as Unicode whitespace.

So for this to be correctly formatted, you need to change it to:

**如果您需要重新安排教练时间**,请确保在原定教练时间前至少提前 **48小时**重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档

如果您需要重新安排教练时间,请确保在原定教练时间前至少提前 48小时重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档

as shown on babelmark here

It is not possible to have **如果您需要重新安排教练时间,** working for example, because the character seems to be a space before the closing **, hence why it can't detect it.

@xoofx commented on GitHub (Jan 29, 2024): From the specs [emphasis-and-strong-emphasis](https://spec.commonmark.org/0.30/#emphasis-and-strong-emphasis) section: > _A [left-flanking delimiter run](https://spec.commonmark.org/0.30/#left-flanking-delimiter-run) is a [delimiter run](https://spec.commonmark.org/0.30/#delimiter-run) that is (1) not followed by [Unicode whitespace](https://spec.commonmark.org/0.30/#unicode-whitespace), and either (2a) not followed by a [Unicode punctuation character](https://spec.commonmark.org/0.30/#unicode-punctuation-character), or (2b) followed by a [Unicode punctuation character](https://spec.commonmark.org/0.30/#unicode-punctuation-character) and preceded by [Unicode whitespace](https://spec.commonmark.org/0.30/#unicode-whitespace) or a [Unicode punctuation character](https://spec.commonmark.org/0.30/#unicode-punctuation-character). For purposes of this definition, the beginning and the end of the line count as Unicode whitespace._ > > _A [right-flanking delimiter run](https://spec.commonmark.org/0.30/#right-flanking-delimiter-run) is a [delimiter run](https://spec.commonmark.org/0.30/#delimiter-run) that is (1) not preceded by [Unicode whitespace](https://spec.commonmark.org/0.30/#unicode-whitespace), and either (2a) not preceded by a [Unicode punctuation character](https://spec.commonmark.org/0.30/#unicode-punctuation-character), or (2b) preceded by a [Unicode punctuation character](https://spec.commonmark.org/0.30/#unicode-punctuation-character) and followed by [Unicode whitespace](https://spec.commonmark.org/0.30/#unicode-whitespace) or a [Unicode punctuation character](https://spec.commonmark.org/0.30/#unicode-punctuation-character). For purposes of this definition, the beginning and the end of the line count as Unicode whitespace._ So for this to be correctly formatted, you need to change it to: `**如果您需要重新安排教练时间**,请确保在原定教练时间前至少提前 **48小时**重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档` **如果您需要重新安排教练时间**,请确保在原定教练时间前至少提前 **48小时**重新预约教练环节,以便您的教练知悉情况并为其他学员安排时间以填补空档 as shown on babelmark [here](https://babelmark.github.io/?text=**%E5%A6%82%E6%9E%9C%E6%82%A8%E9%9C%80%E8%A6%81%E9%87%8D%E6%96%B0%E5%AE%89%E6%8E%92%E6%95%99%E7%BB%83%E6%97%B6%E9%97%B4**%EF%BC%8C%E8%AF%B7%E7%A1%AE%E4%BF%9D%E5%9C%A8%E5%8E%9F%E5%AE%9A%E6%95%99%E7%BB%83%E6%97%B6%E9%97%B4%E5%89%8D%E8%87%B3%E5%B0%91%E6%8F%90%E5%89%8D+**48%E5%B0%8F%E6%97%B6**%E9%87%8D%E6%96%B0%E9%A2%84%E7%BA%A6%E6%95%99%E7%BB%83%E7%8E%AF%E8%8A%82%EF%BC%8C%E4%BB%A5%E4%BE%BF%E6%82%A8%E7%9A%84%E6%95%99%E7%BB%83%E7%9F%A5%E6%82%89%E6%83%85%E5%86%B5%E5%B9%B6%E4%B8%BA%E5%85%B6%E4%BB%96%E5%AD%A6%E5%91%98%E5%AE%89%E6%8E%92%E6%97%B6%E9%97%B4%E4%BB%A5%E5%A1%AB%E8%A1%A5%E7%A9%BA%E6%A1%A3) It is not possible to have `**如果您需要重新安排教练时间,**` working for example, because the character `,` seems to be a space before the closing `**`, hence why it can't detect it.
Author
Owner

@ghost commented on GitHub (Jan 29, 2024):

It seems that I need to work on improving those templates. Thank you for bringing this to my attention!

@ghost commented on GitHub (Jan 29, 2024): It seems that I need to work on improving those templates. Thank you for bringing this to my attention!
Author
Owner

@ghost commented on GitHub (Jan 29, 2024):

In Japanese and Chinese languages ", " and ". " are single char :(
https://www.compart.com/en/unicode/U+FF0C
So, I cannot remove space there.

@ghost commented on GitHub (Jan 29, 2024): In Japanese and Chinese languages ", " and ". " are single char :( https://www.compart.com/en/unicode/U+FF0C So, I cannot remove space there.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#650