Debian Codegraph @

docs/extensions/admonition.md

raw
1 title: Admonition Extension
2
3 Admonition
4 ==========
5
6 Summary
7 -------
8
9 The Admonition extension adds [rST-style][rST] admonitions to Markdown documents.
10
11 This extension is included in the standard Markdown library.
12
13 [rST]: http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
14
15 !!! Note
16
17 This extension is in __maintenance mode__. We will continue to fix bugs
18 and keep it up-to-date with the core parser, but no new features or
19 changes in behavior will be made. If you need a feature that this
20 extension does not offer, then you have three options (1) find an
21 existing [third-party extension] which meets your needs, (2) [build your
22 own extension], or (3) fork this extension (pursuant to its licensing
23 requirements) and maintain it as a third-party extension.
24
25 We recommend [PyMdown Admonition] as an actively developed alternative.
26
27 [third-party extension]: index.md#third-party-extensions
28 [build your own extension]: api.md
29 [PyMdown Admonition]: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/plugins/admonition/
30
31 Syntax
32 ------
33
34 Admonitions are created using the following syntax:
35
36 ```md
37 !!! type "optional explicit title within double quotes"
38 Any number of other indented markdown elements.
39
40 This is the second paragraph.
41 ```
42
43 `type` will be used as the CSS class name and as default title. It must be a
44 single word. So, for instance:
45
46 ```md
47 !!! note
48 You should note that the title will be automatically capitalized.
49 ```
50
51 will render:
52
53 ```html
54 <div class="admonition note">
55 <p class="admonition-title">Note</p>
56 <p>You should note that the title will be automatically capitalized.</p>
57 </div>
58 ```
59
60 Optionally, you can use custom titles. For instance:
61
62 ```md
63 !!! danger "Don't try this at home"
64 ...
65 ```
66
67 will render:
68
69 ```html
70 <div class="admonition danger">
71 <p class="admonition-title">Don't try this at home</p>
72 <p>...</p>
73 </div>
74 ```
75
76 If you don't want a title, use a blank string `""`:
77
78 ```md
79 !!! important ""
80 This is an admonition box without a title.
81 ```
82
83 results in:
84
85 ```html
86 <div class="admonition important">
87 <p>This is an admonition box without a title.</p>
88 </div>
89 ```
90
91 You can also provide additional CSS class names separated by spaces. The first
92 class should be the "type." For example:
93
94 ```md
95 !!! danger highlight blink "Don't try this at home"
96 ...
97 ```
98
99 will render:
100
101 ```html
102 <div class="admonition danger highlight blink">
103 <p class="admonition-title">Don't try this at home</p>
104 <p>...</p>
105 </div>
106 ```
107
108 rST suggests the following "types": `attention`, `caution`, `danger`, `error`,
109 `hint`, `important`, `note`, `tip`, and `warning`; however, you're free to use
110 whatever you want.
111
112 Styling
113 -------
114
115 There is no CSS included as part of this extension. Check out the default
116 [Sphinx][sphinx] theme for inspiration.
117
118 [sphinx]: https://www.sphinx-doc.org/en/master/
119
120 ## Usage
121
122 See [Extensions](index.md) for general extension usage. Use `admonition` as the
123 name of the extension.
124
125 This extension does not accept any special configuration options.
126
127 A trivial example:
128
129 ```python
130 markdown.markdown(some_text, extensions=['admonition'])
131 ```