Nested italics #474

Closed
opened 2026-01-29 14:37:40 +00:00 by claunia · 5 comments
Owner

Originally created by @CharlesJenkins on GitHub (Jul 12, 2021).

In typesetting, when italics are used for emphasis inside a section of text which is already italicized, the emphasized text should appear in roman type. An example would be: You must perform this test in the sandbox database. The emphasized word "must" should appear in roman type as a contrast to the rest of the italicized text.

Markdig cannot currently switch back and forth like that. It would be ideal if Markdig could handle the following syntax to produce an italicized sentence with the word "must" in roman type: *You *must* perform this test in the sandbox database.*

That would make typesetting with Markdig work correctly, but I realize it may be a difficult change to make. However, that sample syntax does not screw up the surrounding italics, so I think the parser is already parsing it correctly and producing the exact syntax tree you would need; but Markdig simply isn't making the check to see if the surrounding text is already italicized before deciding to renter the word "must" in italics.

Originally created by @CharlesJenkins on GitHub (Jul 12, 2021). In typesetting, when italics are used for emphasis inside a section of text which is already italicized, the emphasized text should appear in roman type. An example would be: _**You**_ **must** _**perform this test in the sandbox database.**_ The emphasized word "must" should appear in roman type as a contrast to the rest of the italicized text. Markdig cannot currently switch back and forth like that. It would be ideal if Markdig could handle the following syntax to produce an italicized sentence with the word "must" in roman type: `*You *must* perform this test in the sandbox database.*` That would make typesetting with Markdig work correctly, but I realize it may be a difficult change to make. However, that sample syntax does not screw up the surrounding italics, so I think the parser is already parsing it correctly and producing the exact syntax tree you would need; but Markdig simply isn't making the check to see if the surrounding text is already italicized before deciding to renter the word "must" in italics.
Author
Owner

@MihaZupan commented on GitHub (Jul 12, 2021):

Markdig is following the CommonMark specification with this behavior and as such won't change.
See https://spec.commonmark.org/0.30/#emphasis-and-strong-emphasis or example 417.

If you want different behavior, you can use CSS (I assume) to configure how nested italics are rendered.
Alternatively, it should be possible to transform the syntax tree to the desired shape before rendering it.

FWIW, I would personally prefer the text be formatted as "You must perform this test in the sandbox database." (*You **must** perform this test in the sandbox database.*) as I would miss the fact that a single word in a sentence is not italic.

@MihaZupan commented on GitHub (Jul 12, 2021): Markdig is following the CommonMark specification with this behavior and as such won't change. See https://spec.commonmark.org/0.30/#emphasis-and-strong-emphasis or [example 417](https://spec.commonmark.org/0.30/#example-417). If you want different behavior, you can use CSS (I assume) to configure how nested italics are rendered. Alternatively, it should be possible to transform the syntax tree to the desired shape before rendering it. FWIW, I would personally prefer the text be formatted as "*You **must** perform this test in the sandbox database.*" (`*You **must** perform this test in the sandbox database.*`) as I would miss the fact that a single word in a sentence is not italic.
Author
Owner

@CharlesJenkins commented on GitHub (Jul 12, 2021):

That's too bad, but I understand. Thanks.

@CharlesJenkins commented on GitHub (Jul 12, 2021): That's too bad, but I understand. Thanks.
Author
Owner

@thomasw-mitutoyo-ctl commented on GitHub (Feb 21, 2023):

@CharlesJenkins It depends on where you put the asterisks. You can stop italics before must and restart italics afterwards.
*You* must *perform this test in the sandbox database.*

@thomasw-mitutoyo-ctl commented on GitHub (Feb 21, 2023): @CharlesJenkins It depends on where you put the asterisks. You can stop italics before *must* and restart italics afterwards. `*You* must *perform this test in the sandbox database.*`
Author
Owner

@CharlesJenkins commented on GitHub (Feb 21, 2023):

Thank you, Thomas. My request was to make italics automatically work they way they are supposed to work in publishing, without making users fool with the markdown in order to achieve proper behavior. But the devs don't want that, and it is their project, their choice!

@CharlesJenkins commented on GitHub (Feb 21, 2023): Thank you, Thomas. My request was to make italics _automatically_ work they way they are supposed to work in publishing, without making users fool with the markdown in order to achieve proper behavior. But the devs don't want that, and it is their project, their choice!
Author
Owner

@xoofx commented on GitHub (Feb 21, 2023):

Thank you, Thomas. My request was to make italics automatically work they way they are supposed to work in publishing, without making users fool with the markdown in order to achieve proper behavior. But the devs don't want that, and it is their project, their choice!

It's not about the devs that don't want but the fact that Markdig is following the CommonMark specs. There is a specs precisely for this reason: to avoid having fragmented Markdown custom rules (that sometimes can create awful ambiguate parser problems). GitHub is now following also CommonMark. The specs don't allow what you are looking for.

@xoofx commented on GitHub (Feb 21, 2023): > Thank you, Thomas. My request was to make italics automatically work they way they are supposed to work in publishing, without making users fool with the markdown in order to achieve proper behavior. But the devs don't want that, and it is their project, their choice! It's not about the devs that don't want but the fact that Markdig is following the [CommonMark specs](https://spec.commonmark.org/). There is a specs precisely for this reason: to avoid having fragmented Markdown custom rules (that sometimes can create awful ambiguate parser problems). GitHub is now following also CommonMark. The specs don't allow what you are looking for.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/markdig#474