-
-
Notifications
You must be signed in to change notification settings - Fork 5.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 alert blocks not following GitHub's behaviour with backslashes #31231
Conversation
Previously, these blocks would only get rendered if the markdown was `[!TYPE]`. Now they also render with `\[!TYPE\]`. Signed-off-by: Yarden Shoham <git@yardenshoham.com>
7be636b
to
f2951b1
Compare
Hmm… I'm torn on this one. Should we cave to a bug in the dominant player? |
attentionParagraph := newAttentionParagraph(v, attentionType, g) | ||
v.InsertBefore(v, firstChild, attentionParagraph) | ||
if firstChild.ChildCount() == 0 { | ||
v.RemoveChild(v, firstChild) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
popAttentionTypeFromParagraph
/ popAttentionTypeFromMathBlock
should handle the removal correctly, instead of removing the children here.
if firstParagraph.ChildCount() < 3 { | ||
return ast.WalkContinue, nil | ||
// make sure it's a !TYPE | ||
if innerText[0] != '!' { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings.HasPrefix
to avoid panic if string is empty
if paragraph, ok := firstChild.(*ast.Paragraph); ok { | ||
attentionType = popAttentionTypeFromParagraph(g, paragraph, reader) | ||
} else { | ||
mathBlock, ok := firstChild.(*math.Block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe in the future we should use an "Extension" like "math" , instead of using "transform", then no need to play the type-casting trick with "math.Block" (just an idea, not a change suggestion 😁 )
@delvh convinced me |
But according to the reporter:
So I would suppose the |
-> Make blockquote attention recognize more syntaxes #31240 |
Previously, these blocks would only get rendered if the markdown was
[!TYPE]
. Now they also render with\[!TYPE\]
.Before
After