xoofx / markdig

A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET
BSD 2-Clause "Simplified" License
4.32k stars 448 forks source link

How to make bold just a part of a word? #767

Closed Artem-Beziazychnyi closed 8 months ago

Artem-Beziazychnyi commented 8 months ago

I have a string that needs to be transformed into HTML format.

非常抱歉,{{coachname}}无法再在**{{sessiondate}}**的**{{sessiontime}} {{sessiontimezone}}**进行您即将参加的教练谈话。

The result of Markdig Markdig.Markdown.ToHtml is

非常抱歉,{{coachname}}无法再在**{{sessiondate}}<strong>的</strong>{{sessiontime}} {{sessiontimezone}}**进行您即将参加的教练谈话。

Some of the ( ) were converted to HTML, while others were not. I guess the problem is with spaces. Ideally, Markdig expects something like hello but not he**llo.

What is the appropriate way to handle such a string that I have above? More examples:

image image

where: value - is the original string that should be converted. markdig - the result of Markdig package work markdown - the result of the legacy Markdown package

xoofx commented 8 months ago

Similar issue to https://github.com/xoofx/markdig/issues/765#issuecomment-1914833501

在**{{sessiondate}}**的 cannot work because { or } is a punctuation character, so you have to put a space before (for the opening) or after (for the closing so that 在 **{{sessiondate}}** 的 would render properly 在 {{sessiondate}}

See babelmark here and you can verify that all CommonMark implementations behave the same here.

It is normal that you will get lots of error when converting from markdown - the result of the legacy Markdown package to CommonMark, but it will be unlikely an issue with Markdig, but more something that you will have to change in these templates to comply with CommonMark.