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

Support Alerts in Github Flavored Markdown #331

Open
6 tasks
bbb651 opened this issue May 2, 2024 · 4 comments
Open
6 tasks

Support Alerts in Github Flavored Markdown #331

bbb651 opened this issue May 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@bbb651
Copy link

bbb651 commented May 2, 2024

Context

I noticed Alerts are not supported.

They are pretty poorly specified as they are completely absent from the specification, in fact the only official information from github I found acknowledging they exist is the discussion I linked above.

Proposal

Add support for alerts, and enable it by default in the gfm-like flavor.

Is this out of scope for the core project and should be left to a plugin? I noticed task lists are a plugin instead of being supported by default which is strange to me because they are fairly common.

Tasks and updates

  • Implement a parser rule for alerts

Add support for each of them in the renderer:

  • Note
  • Tip
  • Important
  • Warning
  • Caution
@bbb651 bbb651 added the enhancement New feature or request label May 2, 2024
Copy link

welcome bot commented May 2, 2024

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@chrisjsewell
Copy link
Member

Heya yeh it would go in https://github.com/executablebooks/mdit-py-plugins

@bbb651 bbb651 changed the title Support Notes/Tips/Important/Warning/Caution in Github Flavored Markdown Support Alerts in Github Flavored Markdown May 3, 2024
@bbb651
Copy link
Author

bbb651 commented May 3, 2024

I found the a page about markdown formatting in the docs, it seems to be a lot more up to date than their specification, apparently they are called alerts.

They use octicons which are MIT licensed so we can use the same ones, specifically info, light-bulb, report, alert, stop and their colors are #4493f8, #3fb950, #a371f7, #d29922, #f85149 respectively

(Just noticed color in backticks is another missing feature, github has been adding a ton of things lately)

@bbb651
Copy link
Author

bbb651 commented May 4, 2024

I made a plugin that parses them and renders them like normal blockquotes but inserts alert and alert-* classes that can be used for styling, I'll clean it up a bit and make a pr in the plugins repo

Is there interest in support arbitrary alerts? It should be pretty straight forward to implement (I'm currently storing the alert type as an enum but I can change it to a string, of course from a whitelisted list to not allow arbitrary user input reflected classes)

Here the generated html:

<p>Text</p>
<blockquote>
<p>Quote</p>
</blockquote>
<blockquote class="alert alert-note">
<p>Highlights information that users should take into account, even when skimming.</p>
</blockquote>
<blockquote class="alert alert-tip">
<p>Optional information to help a user be more successful.</p>
</blockquote>
<blockquote class="alert alert-important">
<p>Crucial information necessary for users to succeed.</p>
</blockquote>
<blockquote class="alert alert-warning">
<p>Critical content demanding immediate user attention due to potential risks.</p>
</blockquote>
<blockquote class="alert alert-caution">
<p>Negative potential consequences of an action.</p>
</blockquote>

And here's how it looks in my project with styling as an example:
Example with heavy styling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants