|
| 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 because difficult. |
| 33 | + |
| 34 | +The Quotes extensions follows logic that is seen in more modern approaches to Markdown. |
| 35 | + |
| 36 | +```text title="Separate Blockquotes" |
| 37 | +> This is a paragraph |
| 38 | +
|
| 39 | +> This is another paragraph. |
| 40 | +``` |
| 41 | + |
| 42 | +/// html | div.result |
| 43 | +> This is a paragraph |
| 44 | +
|
| 45 | +> This is another paragraph. |
| 46 | +/// |
| 47 | + |
| 48 | +It should be noted that since this extension does not use lazy formatting, you should be stricter with your leading |
| 49 | +blockquote `>`. For instance, when using [SuperFences](./superfences.md), you will find that these must be fully |
| 50 | +contained in the blockquotes. In the past, the lazy handling would have allowed for |
| 51 | + |
| 52 | +````text title="Blockquotes and SuperFences" |
| 53 | +> ``` |
| 54 | +> Test |
| 55 | +> |
| 56 | +> Test |
| 57 | +> ``` |
| 58 | +
|
| 59 | +This will not. |
| 60 | +
|
| 61 | +> ``` |
| 62 | +> Test |
| 63 | +
|
| 64 | +> Test |
| 65 | +> ``` |
| 66 | +```` |
| 67 | + |
| 68 | +/// html | div.result |
| 69 | +This will work. |
| 70 | + |
| 71 | +> ``` |
| 72 | +> Test |
| 73 | +> |
| 74 | +> Test |
| 75 | +> ``` |
| 76 | +
|
| 77 | +This will not. |
| 78 | +
|
| 79 | +> ``` |
| 80 | +> Test |
| 81 | +
|
| 82 | +> Test |
| 83 | +> ``` |
| 84 | +/// |
| 85 | +
|
| 86 | +## Callouts |
| 87 | +
|
| 88 | +[GitHub][github-alerts] and [Obsidian](https://help.obsidian.md/callouts) allow for specifying admonitions (also known |
| 89 | +as alerts or callouts) by using a special syntax at the start of a blockquote. While Obsidian does this with a more |
| 90 | +feature rich syntax, GitHub offers a more stripped down version. |
| 91 | +
|
| 92 | +The Quotes extensions allows you to opt-in approach to specifying admonitions in a similar approach that is compatible |
| 93 | +with Obsidian and GitHub if usage is limited to what they offer. |
| 94 | +
|
| 95 | +Quotes will take the special blockquote syntax and output HTML that matches the output of [Admonitions][admonition] or |
| 96 | +[Details](./details.md). |
| 97 | +
|
| 98 | +To specify normal callouts, simply ensure the that the first line of a blockquote contains a class name in within |
| 99 | +`[!...]`. |
| 100 | +
|
| 101 | +```text title="Callout" |
| 102 | +> [!note] |
| 103 | +> Here is a note |
| 104 | +``` |
| 105 | +
|
| 106 | +/// html | div.result |
| 107 | +> [!note] |
| 108 | +> Here is a note |
| 109 | +/// |
| 110 | + |
| 111 | +/// note |
| 112 | +GitHub only supports the simple class notation, and only recognizes the classes: note, tip, important, warning, caution. |
| 113 | + |
| 114 | +There are no restrictions as to which classes you can specify, but if cross compliance is desired, take note of what |
| 115 | +GitHub supports. Learn more [here][github-alerts]. |
| 116 | +/// |
| 117 | + |
| 118 | +Borrowing from Obsidian, Quotes also enables a few more advanced features. If you'd like a custom title, simply provide |
| 119 | +one on the same line as the class specifier. If one is not provided, a title is sourced from the first the class. |
| 120 | + |
| 121 | +```text title="Callout with Custom Title" |
| 122 | +> [!tip] Here's a tip |
| 123 | +> Use a custom title! |
| 124 | +``` |
| 125 | + |
| 126 | +/// html | div.result |
| 127 | +> [!tip] Here's a tip |
| 128 | +> Use a custom title! |
| 129 | +/// |
| 130 | + |
| 131 | +To make a collapsible callout, just add `+` (open) or `-` (closed) immediately after the class specifier. |
| 132 | + |
| 133 | +```text title="Collapsible Callout" |
| 134 | +> [!danger]- Click to see more |
| 135 | +> I'm collapsible. |
| 136 | +``` |
| 137 | + |
| 138 | +/// html | div.result |
| 139 | +> [!danger]- Click to see more |
| 140 | +> I'm collapsible. |
| 141 | +/// |
| 142 | + |
| 143 | +Lastly, if you need to specify more multiple classes, you can utilize the Obsidian approach and and separate each class |
| 144 | +with `|`. The first class will be used as the main title if no title is provided, but all classes will be applied to the |
| 145 | +callout. |
| 146 | + |
| 147 | +```text title="Collapsible Callout" |
| 148 | +> [!warning | inline | end] |
| 149 | +> Make inline and set at the end. |
| 150 | +
|
| 151 | +A paragraph. |
| 152 | +``` |
| 153 | + |
| 154 | +/// html | div.result |
| 155 | +> [!warning | inline | end] |
| 156 | +> Make inline and set at the end. |
| 157 | +
|
| 158 | +A paragraph. |
| 159 | +/// |
| 160 | + |
| 161 | +## Options |
| 162 | + |
| 163 | +Option | Type | Default | Description |
| 164 | +-------------------- | ------- | ------------ |------------ |
| 165 | +`callouts` | bool | `#!py3 False`| Enable the ability to create special callouts using blockquotes. |
0 commit comments