Skip to content

Add support for GitHub-style alert - #158

Open
guoPhineas wants to merge 7 commits into
LiYanan2004:mainfrom
guoPhineas:phg/feature/QuoteAlert
Open

Add support for GitHub-style alert#158
guoPhineas wants to merge 7 commits into
LiYanan2004:mainfrom
guoPhineas:phg/feature/QuoteAlert

Conversation

@guoPhineas

Copy link
Copy Markdown
Contributor

@guoPhineas
guoPhineas force-pushed the phg/feature/QuoteAlert branch from 927b149 to b208496 Compare July 27, 2026 02:43
@guoPhineas

guoPhineas commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author
2026-07-27.10.45.37.mov

Hello,

This PR is ready for review.

I added .markdownQuoteAlertEnabled() to enable this style:

image

Thanks.🤝

@guoPhineas
guoPhineas marked this pull request as ready for review July 27, 2026 03:11
@guoPhineas guoPhineas changed the title [WIP] Add support for GitHub-style alert Add support for GitHub-style alert Jul 27, 2026
@ajram23

ajram23 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Love it. Hope this gets added!

@LiYanan2004

Copy link
Copy Markdown
Owner

Sorry for the delay. Reviewing now!

@LiYanan2004
LiYanan2004 self-requested a review August 12, 2026 12:40
@LiYanan2004

Copy link
Copy Markdown
Owner

@guoPhineas Two issues:

  • MarkdownText does not support this new view modifier (I fixed that)
  • There are some edge cases for GitHub-style alert parsing (added some test cases for you) Please fix and make sure they are all passed)


@Suite("Markdown Quote Alert")
struct MarkdownQuoteAlertTests {
@Test(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails

#expect(renderedBody.contains(fixture.expectedFirstBodyParagraph))
}

@Test(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test fails

@guoPhineas

guoPhineas commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

@LiYanan2004
Never mind for delay. Thanks for review.

I just fixed the issues you raised. But the test isn't also passed. I speculate that there may be code logic issues with the current testing:

The .multipleParagraphs test appears to have an issue in its body-extraction logic.

For this fixture, Swift Markdown produces the following AST:

  • First Paragraph: [!NOTE] followed by First paragraph.
  • Second Paragraph: Second paragraph.

However, when there is more than one child, the test uses:

bodyChildren = Array(children.dropFirst())

This discards the first paragraph, including First paragraph., and then asserts that the rendered body contains First paragraph.. Those two operations conflict.

The renderer should strip the alert marker/title line from the first paragraph, preserve the remaining inline content, and then append the remaining blockquote children. The implementation now follows that behavior, but the test’s extraction logic would need the same adjustment.

So, I fixed the issue in commit cf6e19a, how about this? It was passed on my Mac.

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

Successfully merging this pull request may close these issues.

3 participants