Add Support for Custom Alert Titles#430
Conversation
3ba29d4 to
84f6dc9
Compare
d26df85 to
979a0d1
Compare
|
@robinst If you have a chance would you be able to take a look at this PR? Thanks! |
robinst
left a comment
There was a problem hiding this comment.
Nice work so far (and thanks for your patience)! Requested some changes, mainly around edge cases and preserving source position information.
| * These comments will be visible when rendered to other formats like | ||
| * Markdown, so this is only relevant for the HTML renderer. | ||
| */ | ||
| if (isCommentOnlyTitle(first)) { |
There was a problem hiding this comment.
Does GitLab do this? Seems like a strange edge case to support.
There was a problem hiding this comment.
GitLab doesn't do this because they treat the entire title content as raw text instead of parsing inlines (example). It seems like supporting inlines makes sense, however, so I did that. When I was playing around with it I noticed this edge case where the title would render but appear empty since it's just an HTML comment. I could see someone writing something like:
> [!WARNING] <!-- Remove once this feature is GA -->
> This feature is experimental. Use at your own risk. If you don't think it's worth supporting though happy to remove.
253f5d7 to
bf5d808
Compare
bf5d808 to
f27483f
Compare
5ba66ba to
c910716
Compare
c910716 to
348d18b
Compare
Made an initial attempt at implementing support for custom titles in alerts (#429). I kept running into issues when trying to enhance the post processor because there's no access to an inline parser and it was susceptible to edge cases where inline nodes would overlap between the title and the body. For example:
The
*s would create anEmphasisnode which made splitting out the title text difficult, when in reality those lines should be parsed separately. I decided to try and make a customAlertBlockParserinstead to have more control.I'm not sure if this is the right approach, but it seemed to work well for me. A few things I noticed, though, with this new parser:
> [!NOTE] Title Lazy bodyBlockQuote > Paragraph, and the paragraph allows lazy continuation.