How to make a styled Markdown admonition box in a GitHub Gist?

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> <div> <div> <i></i> </div> <div> <strong>Error:</strong> </div> </div>
</div>

Is there any admonition syntax or HTML code method for GitHub Gist?

3

8 Answers

Use emoji to call the user attention

> :warning: **If you are using mobile browser**: Be very careful here!

Github example

Here is list of others emojis (just copy paste):

Or you can also use GitHub markdown:

5

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:

An image of a single-cell table, containing the text "WARNING: be careful to baz the quux before initializing the retro encabulator!"

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.

1

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:

enter image description here

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.

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:

Note / This is a note and Warning / This is a warning

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.

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

Material for MkDocs provides several different types of admonitions and allows for the inclusion and nesting of arbitrary content.

First, you should configure:

markdown_extensions: - admonition - pymdownx.details - pymdownx.superfences

Then, you can use admonitions in markdown:

!!! note Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla et euismod nulla. Curabitur feugiat, tortor non consequat finibus, justo purus auctor massa, nec semper lorem quam in massa.

Source:

4

A simple highlighted warning can be achieved like this:

>[!WARNING]
>This is a warning

This is what it looks like:

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like