-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
fix(markdown) strong/emphasis requires whitespace after #3520
fix(markdown) strong/emphasis requires whitespace after #3520
Conversation
Gonna start a quick discussion on this one. I did some light reading on the commonmark spec and learned two things:
Given that any whitespace (including newlines) terminate the sequence, maybe use const BOLD = {
className: 'strong',
contains: [], // defined later
variants: [
{
begin: /_{2}(?!\s)/, // <- changed
end: /_{2}/
},
{
begin: /\*{2}(?!\s)/, // <- changed
end: /\*{2}/
}
]
};
const ITALIC = {
className: 'emphasis',
contains: [], // defined later
variants: [
{
begin: /\*(?![*\s])/, // <- changed
end: /\*/
},
{
begin: /_(?![_\s])/, // <- changed
end: /_/,
relevance: 0
}
]
}; (I'd submit it as a review but GitHub doesn't let me make changes on non-touched lines) This PR as-is would result in the following, |
The markdown I'm using: ** i shouldn't be italic**
* and I shouldn't be italic either*
__ not really bold__
_ not italic_
Hello
**actually bold**
__again, bold__
*italic*
_oh i'm italic_ How GitHub renders this ** i shouldn't be italic**
__ not really bold__ _ not italic_ Hello actually bold again, bold italic |
Not completely accurate:
**not bold *not italic should be should be |
Did you try and see if all the tests still passed with that snippet? |
Ran it against
Ahhh good catch on this, you're right. Anything that's not "punctuation" before the closing sequence keeps it bold/italic. But if it's just a newline and closing, then it's not valid since the newline is considered "punctuation" |
I don't mean to overstep and push to your branch, @joshgoebel! I'd like to vote that we fix the immediate false positives by disallowing newlines inside of bolds and italics. And in the future, come up with a more robust expression that matches the markdown spec and can handle newlines (or whatever new APIs that may be added). |
Resolves #3519. Prevents false positive of emphasis when bullets are nested inside block quotes. This doesn't detect the bullets, it only fixes the false positive.
Checklist
CHANGES.md