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

Only apply Markdown emphasis when there is an adjacent space #3207

Open
krono opened this issue Feb 17, 2025 · 0 comments
Open

Only apply Markdown emphasis when there is an adjacent space #3207

krono opened this issue Feb 17, 2025 · 0 comments
Labels
s: pending triage Pending Triage

Comments

@krono
Copy link

krono commented Feb 17, 2025

Currently, it feels like the markdown display will simply jam markdown interpretation of * and _ on any matching pair.
(very simplified description)

This upsets quite some usages.

The same holds for _, although to a lesser extent.
_ has its uses in IT-related posts, and not everyone wants to use backquotes (because, again, they might not be using elk or any markdowning client in the first place.

Most "funnily", C function signatures are all over the place. Consider:

int	 rename (const char *__old, const char *__new);
extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);

Proposal


Only apply emphasis to text iff:

  1. text starts with any space
  2. followed by one to three of * or _ (adjacent space to the left)
  3. followed by at least one character not being * or _. Maybe has * or _ embedded 1
  4. followed by one to three of * or _, that match the characters found in 2., but mirrored.
  5. optionally followed by puctuation (eg, .,;?:!)
  6. followed by at least one space (adjacent space to the right).

Test cases

This *has* emphasis.
This th*ng does n*ot.
This one is *debat*able*

from markdownguide

I just love **bold text**.
I just love __bold text__. 
NOT: Love**is**bold -- see caveat
Italicized text is the *cat's meow*.
Italicized text is the _cat's meow_.
NOT: A*cat*meow -- see caveat
This text is ***really important***.
This text is ___really important___.
This text is __*really important*__.
This text is **_really important_**.
NOT: This is really***very***important text. -- see caveat

Commonmark

YES: *foo bar*
NO: a * foo bar*
NO: a*"foo"*
NO: * a *
NO: *$*alpha.
NO: *£*bravo.
NO: **charlie.
YES: foo*bar* --- debatable
NO: 5*6*78 -- see caveat
NO: _foo*
NO: *foo bar *
NO: 
*foo bar
*
NO:  *(*foo)
YES: *(*foo*)* -- debatable, not considered here
YES: 
*foo
bar*
YES: *foo **bar** baz*
NO: *foo**bar**baz* -- see caveat

(_, double-*, and double-_ cases ommitted, but its virtually identical)

Caveat

This on purpose violates the recommendation in this markdown guide and commonmark.
The guide, for example, recommends rendering A*cat*meow with inter-word-emphasis, which is explicitly not recommended here.
Commonmark already restricts it to inner-word-*, disallowing _:

internal emphasis: foo*bar*baz
no emphasis: foo_bar_baz

The case foo*bar* from commonmark is debatable. applyinh

Footnotes

  1. This restriction is only a simple case. Naurally, nesting, or switching between italic/bold emphasis needs more work. Also, singular, non-matched * might be allowed.

@krono krono added the s: pending triage Pending Triage label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: pending triage Pending Triage
Projects
None yet
Development

No branches or pull requests

1 participant