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

[Markdown] Add GitHub Alerts syntax #3892

Merged
merged 2 commits into from
Dec 29, 2023

Conversation

deathaxe
Copy link
Collaborator

Resolves #3891

This PR proposes to add support for syntax highlighting of GitHub alerts as proposed by #3891.

This PR uses dedicated scopes markup.heading.alert and markup.quote.alert to avoid unwanted negative impacts on highlighting in conjunction with legacy color schemes. Dedicated highlighting requires to opt-in via new color scheme rules. Otherwise those blocks keep highlighting as normal block quotes except [!...] marker being highlighted as normal heading.

@jwortmann
Copy link
Contributor

markup.quote.alert looks fine to me, but if you want to use markup.heading.alert for the alert type, then this scope should at least be excluded from the symbol list.

Block quotes may contain headings, which are not related with normal
documentation structure. Thus exclude them from symbol lists and index.
@deathaxe
Copy link
Collaborator Author

Extended the scope of exclusion to all kinds of headings in block quotes as they are unlikely to represent normal documentation structure.

@jrappen
Copy link
Contributor

jrappen commented Dec 15, 2023

Reading through this, maybe change some scope suffixes here from .markdown to .markdown.github? Haven't checked if it's done elsewhere.

@deathaxe
Copy link
Collaborator Author

Maybe .markdown-gfm, which all the other Github Favoured Markdown constructs use. But actually I see barely use for that and would even rather drop all of those distinctions, especially as most (not all) of them have been adopted by CommonMark as well.

IIRC, only remaining GFM specific expressions are tables and now github alerts.

Any other admonation syntax could use exactly the same scopes. Not sure if anyone would want to highlight them different.

@deathaxe deathaxe merged commit e420984 into sublimehq:master Dec 29, 2023
2 checks passed
@deathaxe deathaxe deleted the pr/markdown/add-gfm-alerts branch December 29, 2023 10:16
@jwortmann
Copy link
Contributor

Just a small discrepancy that I noticed:

If there is an empty line within an alert block, the alert scope is not applied anymore. But on GitHub, an empty line doesn't close the alert block:

alert

Not sure if this was intentionally made different in the syntax to keep the implementation simple, or if it was just missed.

deathaxe added a commit to deathaxe/sublime-packages that referenced this pull request Dec 30, 2023
FichteFoll pushed a commit that referenced this pull request Jan 1, 2024
* [Markdown] Fix premature block quote termination

Fixes #3892 (comment)

Follow up commit for #3892.

* [Markdown] Remove useless context pushes

This commit removes block-quote punctuation contexts from being pushed on stack,
which do not have any effect in conjunction with Github Alerts.

They are required support multiple > > > markers in front of content, which is
not supported by Github Alerts.

Due to consuming caption text pushing those contexts does actually nothing, but
causing some extra round-trips.
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.

[Markdown] Add support for GFM alert blocks
5 participants