Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested italics #562

Closed
CharlesJenkins opened this issue Jul 12, 2021 · 5 comments
Closed

Nested italics #562

CharlesJenkins opened this issue Jul 12, 2021 · 5 comments

Comments

@CharlesJenkins
Copy link

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
Copy link
Collaborator

MihaZupan commented 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
Copy link
Author

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

@thomasw-mitutoyo-ctl
Copy link

@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
Copy link
Author

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
Copy link
Owner

xoofx commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants