Debian Codegraph @

docs/src/markdown/extensions/quotes.md

raw
1 ---
2 icon: lucide/quote
3 ---
4 [:octicons-file-code-24:][_quotes]{: .source-link }
5
6 # Quotes
7
8 ## Overview
9
10 Quotes is an extension that offers a more modern take on blockquotes compared to the one that ships with Python Markdown
11 by default.
12
13 Python Markdown is an old-school parser that aims to follow the original Markdown specification. When implementing
14 blockquotes, it follows the guidance that describes the ability to lazily specify content under a blockquote as shown
15 below. Notice that two blocks of text can be specified without having to specify `>` on the empty lines between the
16 blocks.
17
18 ```text title="Lazy Blockquote Handling"
19 > This is a paragraph
20
21 > This is another paragraph.
22 ```
23
24 /// html | div.result
25 ```md-render
26 > This is a paragraph
27
28 > This is another paragraph.
29 ```
30 ///
31
32 The problem with this approach is that if you have a need to have two separate blockquotes, this becomes difficult.
33
34 The Quotes extensions follows logic that is seen in more modern approaches to Markdown where each blockquote is distinct
35 and separate.
36
37 ```text title="Separate Blockquotes"
38 > This is a paragraph
39
40 > This is another paragraph.
41 ```
42
43 /// html | div.result
44 > This is a paragraph
45
46 > This is another paragraph.
47 ///
48
49 It should be noted that since this extension does not use lazy formatting, you should be stricter with your leading
50 blockquote `>`. For instance, when using [SuperFences](./superfences.md), you will find that these must be fully
51 contained in the blockquotes. In the past, the lazy handling would have allowed a more relaxed behavior.
52
53 ````text title="Blockquotes and SuperFences"
54 This will work.
55
56 > ```
57 > Test
58 >
59 > Test
60 > ```
61
62 This will not.
63
64 > ```
65 > Test
66
67 > Test
68 > ```
69 ````
70
71 /// html | div.result
72 This will work.
73
74 > ```
75 > Test
76 >
77 > Test
78 > ```
79
80 This will not.
81
82 > ```
83 > Test
84
85 > Test
86 > ```
87 ///
88
89 ## Callouts
90
91 [GitHub][github-alerts] and [Obsidian](https://help.obsidian.md/callouts) allow for specifying admonitions (also known
92 as alerts or callouts) by using a special syntax at the start of a blockquote. While Obsidian does this with a more
93 feature rich syntax, GitHub offers a more stripped down version.
94
95 The Quotes extensions allows you to opt-in to specifying admonitions in a similar approach that is compatible with
96 Obsidian and GitHub.
97
98 /// note
99 GitHub only supports the simple, single class notation, and only recognizes specific classes.
100
101 Quotes does not physically add restrictions to which classes you can specify, or how many, but if compatibility is
102 desired, take note of what GitHub supports. Learn more [here][github-alerts].
103 ///
104
105 Quotes will take the special blockquote syntax and output HTML that matches the output of [Admonitions][admonition] or
106 [Details](./details.md).
107
108 To specify normal callouts, simply ensure the that the first line of a blockquote contains a class name in within
109 `[!<type>]` where `<type>` is the specific callout type. The type is always converted to a lowercase CSS class.
110
111 ```text title="Callout"
112 > [!note]
113 > Here is a note
114 ```
115
116 /// html | div.result
117 > [!note]
118 > Here is a note
119 ///
120
121 Borrowing from Obsidian, Quotes also enables a few more advanced features. If you'd like a custom title, simply provide
122 one on the same line as the class specifier. If one is not provided, a title is sourced from the first the class.
123
124 ```text title="Callout with Custom Title"
125 > [!tip] Here's a tip
126 > Use a custom title!
127 ```
128
129 /// html | div.result
130 > [!tip] Here's a tip
131 > Use a custom title!
132 ///
133
134 To make a collapsible callout, just add `+` (open) or `-` (closed) immediately after the class specifier.
135
136 ```text title="Collapsible Callout"
137 > [!danger]- Click to see more
138 > I'm collapsible.
139 ```
140
141 /// html | div.result
142 > [!danger]- Click to see more
143 > I'm collapsible.
144 ///
145
146 Lastly, if you need to specify multiple classes, you can utilize the Obsidian approach and separate each class with `|`.
147 The first class will be used as the type and also the title if no title is provided, but all classes will be applied to
148 the callout.
149
150 ```text title="Collapsible Callout"
151 > [!warning | inline | end]
152 > Make inline and set at the end.
153
154 A paragraph.
155 ```
156
157 /// html | div.result
158 > [!warning | inline | end]
159 > Make inline and set at the end.
160
161 A paragraph.
162 ///
163
164 While GitHub does not support nesting, nesting is also supported which aligns with Obsidian.
165
166 ```text title="Nesting"
167 > [!note]
168 > Content
169 > > [!danger]
170 > > Content
171 > > > [!important]
172 > > > Content
173 > >
174 > > Content
175 >
176 > > [!tip]
177 ```
178
179 /// html | div.result
180 > [!note]
181 > Content
182 > > [!danger]
183 > > Content
184 > > > [!important]
185 > > > Content
186 > >
187 > > Content
188 >
189 > > [!tip]
190 ///
191
192 ## Options
193
194 Option | Type | Default | Description
195 -------------------- | ------- | ------------ |------------
196 `callouts` | bool | `#!py3 False`| Enable the ability to create special callouts using blockquotes.