Markdig not converting in between words formatting for Markdown properly #440

Closed
opened 2026-01-29 14:36:44 +00:00 by claunia · 4 comments
Owner

Originally created by @HarshKhaneja on GitHub (Feb 23, 2021).

inputmkd
outputmkd

Markdig is not converting in-words formatting properly.

Originally created by @HarshKhaneja on GitHub (Feb 23, 2021). ![inputmkd](https://user-images.githubusercontent.com/79523054/108856371-0166ca00-7610-11eb-8bd6-201581207d5c.PNG) ![outputmkd](https://user-images.githubusercontent.com/79523054/108856382-04fa5100-7610-11eb-9972-0f39b286b9ee.PNG) Markdig is not converting in-words formatting properly.
claunia added the invalid label 2026-01-29 14:36:44 +00:00
Author
Owner

@MihaZupan commented on GitHub (Feb 23, 2021):

While it may be unexpected, Markdig is CommonMark-compliant here:

Example 378 of the specification:

This is not strong emphasis, because the opening delimiter is followed by whitespace:
** foo bar** => <p>** foo bar**</p>

@MihaZupan commented on GitHub (Feb 23, 2021): While it may be unexpected, Markdig is CommonMark-compliant here: [Example 378](https://spec.commonmark.org/0.29/#example-378) of the specification: > This is not strong emphasis, because the opening delimiter is followed by whitespace: `** foo bar**` => `<p>** foo bar**</p>`
Author
Owner

@MihaZupan commented on GitHub (Feb 28, 2021):

Going to assume this answered the question. Feel free to reopen the issue if you have other examples of unexpected behavior.

@MihaZupan commented on GitHub (Feb 28, 2021): Going to assume this answered the question. Feel free to reopen the issue if you have other examples of unexpected behavior.
Author
Owner

@HarshKhaneja commented on GitHub (Mar 15, 2021):

Hey Miha,

Scenario is like this:- i have a selector, the user can also select whitespaces while doing the formatting, example :- This is a Test, in this sentence the user can select individual words for formatting and there comes a use-case in which he can select trailing and leading spaces too using the selector just like a text box, according to you if i go ahead and trim on leading and trailing spaces, then for me the spaces between words will be lost, this will create problem in readability, and if i don't trim on the spaces then Markdig parser leaves special characters in the result.. So trimming on leading and trailing spaces is not a solution instead the parser should parse according to the starting and closing tags which have been applied in selected text, Note:- Selected text can contain leading and trailing spaces.

Regards,
Harsh

@HarshKhaneja commented on GitHub (Mar 15, 2021): Hey Miha, Scenario is like this:- i have a selector, the user can also select whitespaces while doing the formatting, example :- This is a Test, in this sentence the user can select individual words for formatting and there comes a use-case in which he can select trailing and leading spaces too using the selector just like a text box, according to you if i go ahead and trim on leading and trailing spaces, then for me the spaces between words will be lost, this will create problem in readability, and if i don't trim on the spaces then Markdig parser leaves special characters in the result.. So trimming on leading and trailing spaces is not a solution instead the parser should parse according to the starting and closing tags which have been applied in selected text, Note:- Selected text can contain leading and trailing spaces. Regards, Harsh
Author
Owner

@xoofx commented on GitHub (Mar 15, 2021):

instead the parser should parse according to the starting and closing tags which have been applied in selected text

No, the parser is parsing according to the CommonMark specs, not to what you would expect. We really can't change that behavior, so you need to change the way you are approaching your problem.

@xoofx commented on GitHub (Mar 15, 2021): > instead the parser should parse according to the starting and closing tags which have been applied in selected text No, the parser is parsing according to the CommonMark specs, not to what you would expect. We really can't change that behavior, so you need to change the way you are approaching your problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#440