How to make a styled Markdown admonition box in a GitHub Gist?
MarkdownGithub Flavored-MarkdownMarkdown Problem Overview
I am trying to make a Markdown admonition box such as note box, warning box for GitHub Gist. I do some search on Google I find Python markdown admonition but these admonitions don't seem to work on GitHub Gist.
I have tried following Python warning admonition But this markdown syntax doesn't work on GitHub Gist.
!!! Hello Admonition
I also tried bootstrap boxes like this but it does not have style as expected:
<div class="alert alert-danger" role="alert">
<div class="row vertical-align">
<div class="col-xs-1 text-center">
<i class="fa fa-exclamation-triangle fa-2x"></i>
</div>
<div class="col-xs-11">
<strong>Error:</strong>
</div>
</div>
</div>
Is there any admonition syntax or HTML code method for GitHub Gist?
Markdown Solutions
Solution 1 - Markdown
Use emoji to call the user attention
> :warning: **If you are using mobile browser**: Be very careful here!
Here is list of others emojis (just copy paste):
https://gist.github.com/roachhd/1f029bd4b50b8a524f3c
Or you can also use GitHub markdown:
Solution 2 - Markdown
You can make a box with some bold text in by using tables, like so:
| WARNING: be careful to baz the quux before initializing the retro encabulator! |
| --- |
This renders like this:
It's a bit of an abuse of syntax, but it works. There's unfortunately no way to apply other formatting like colours, as Chris noted.
Solution 3 - Markdown
Most repositories I've been a part of use the blockquote to simulate an admonition:
> **WARNING**: Be careful, or else!
Below is an example of it being used at the top, as well as inside, a section:
Solution 4 - Markdown
In standard markdown using the UTF8 symbol this looks pretty good:
> **⚠ WARNING: Aliens are coming.**
> A description of the colour, smell and dangerous behaviour of the aliens.
Which Renders like this:
> ⚠ WARNING: Aliens are coming.
> A description of the colour, smell and dangerous behaviour of the aliens.
Solution 5 - Markdown
GitHub Flavored Markdown doesn't have anything like that and its HTML, generated or inline, is aggressively sanitized.
You'll likely have to make do with the basics, e.g.
_**Warning:** Be very careful here._
or
### Warning
Be very careful here
Solution 6 - Markdown
While not exactly an admonition, this is supported (beta tested) since May 2022, as reported by Diego Haz and described in discussion 16925
> To better highlight and separate certain information from the rest in your documentation on GitHub, we now render a special and accessible note or warning blockquote in Markdown documents.
>
>We are using the existing syntax for blockquote and bold text.
>
> The first line must be exactly as shown below.
The first letter is case sensitive. The second line can contain your content.
>
> This input:
>
> > > **Note** > > This is a note > > > **Warning** > > This is a warning >
>Becomes:
>
>
Warning: the syntax might still evolve and is debated in the discussion. For instance, Brenton M. Wiernik comments:
> In addition to syntax issues and semantic web problems raised by others, I am also concerned about this introducing a major incompatibility between GitHub-Flavored Markdown and pandoc markdown or CommonMark.
>
> A large number of R developers write READMEs and other documentation in RMarkdown, which is generally processed using pandoc.
>
> This change would mean that users would be unable to get consistent rendering with the same syntax when their package documentation is displayed on GitHub vs elsewhere.
>
> Overloading the blockquote in this way creates an opaque difference in the meaning of syntax across markdown flavors that is very difficult to write around for developers.
Solution 7 - Markdown
You can this alerts in your md file
https://squidfunk.github.io/mkdocs-material/reference/admonitions/#supported-types
Solution 8 - Markdown
A simple highlighted warning can be achieved like this:
>[!WARNING]
>This is a warning
This is what it looks like: