mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-09 13:56:56 +00:00
Nested italics #474
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
@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.@CharlesJenkins commented on GitHub (Jul 12, 2021):
That's too bad, but I understand. Thanks.
@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.*@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!
@xoofx commented on GitHub (Feb 21, 2023):
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.