size: 3 KiB
| 1 | An inline attribute allies to the preceding element, which might |
| 2 | be complex (span, emphasis, link) or a simple word (defined as a |
| 3 | sequence of non-ASCII-whitespace characters). |
| 4 | ``` |
| 5 | foo привет{.ru} |
| 6 | . |
| 7 | <p>foo <span class="ru">привет</span></p> |
| 8 | ``` |
| 9 | |
| 10 | ``` |
| 11 | (some text){.attr} |
| 12 | . |
| 13 | <p>(some <span class="attr">text)</span></p> |
| 14 | ``` |
| 15 | |
| 16 | ``` |
| 17 | [some text]{.attr} |
| 18 | . |
| 19 | <p><span class="attr">some text</span></p> |
| 20 | ``` |
| 21 | |
| 22 | Ensure that emphasis that starts before the attribute can still close, |
| 23 | even if the attribute contains a potential closer. |
| 24 | |
| 25 | ``` |
| 26 | a *b{#id key="*"}* |
| 27 | . |
| 28 | <p>a <strong><span id="id" key="*">b</span></strong></p> |
| 29 | ``` |
| 30 | |
| 31 | ``` |
| 32 | a *b{#id key="*"}o |
| 33 | . |
| 34 | <p>a <span id="id" key="*">*b</span>o</p> |
| 35 | ``` |
| 36 | |
| 37 | Don't mind braces in quotes: |
| 38 | |
| 39 | ``` |
| 40 | hi{key="{#hi"} |
| 41 | . |
| 42 | <p><span key="{#hi">hi</span></p> |
| 43 | ``` |
| 44 | |
| 45 | Don't allow attributes to start when we're parsing a potential |
| 46 | attribute. |
| 47 | |
| 48 | ``` |
| 49 | hi\{key="abc{#hi}" |
| 50 | . |
| 51 | <p>hi{key=“<span id="hi">abc</span>”</p> |
| 52 | ``` |
| 53 | |
| 54 | ``` |
| 55 | hi{key="\"#hi"} |
| 56 | . |
| 57 | <p><span key=""#hi">hi</span></p> |
| 58 | ``` |
| 59 | |
| 60 | ``` |
| 61 | hi{key="hi\"#hi"} |
| 62 | . |
| 63 | <p><span key="hi"#hi">hi</span></p> |
| 64 | ``` |
| 65 | |
| 66 | Line break: |
| 67 | |
| 68 | ``` |
| 69 | hi{#id .class |
| 70 | key="value"} |
| 71 | . |
| 72 | <p><span class="class" id="id" key="value">hi</span></p> |
| 73 | ``` |
| 74 | |
| 75 | Here there is nothing for the attribute to attach to: |
| 76 | |
| 77 | ``` |
| 78 | {#id} at beginning |
| 79 | . |
| 80 | <p> at beginning</p> |
| 81 | ``` |
| 82 | |
| 83 | ``` |
| 84 | After {#id} space |
| 85 | {.class} |
| 86 | . |
| 87 | <p>After space |
| 88 | </p> |
| 89 | ``` |
| 90 | |
| 91 | Block attributes come before the block, on a line by themselves. |
| 92 | |
| 93 | ``` |
| 94 | {#id .class} |
| 95 | A paragraph |
| 96 | . |
| 97 | <p class="class" id="id">A paragraph</p> |
| 98 | ``` |
| 99 | |
| 100 | Use indentation if you need to continue the attributes over a line break. |
| 101 | |
| 102 | ``` |
| 103 | {#id .class |
| 104 | style="color:red"} |
| 105 | A paragraph |
| 106 | . |
| 107 | <p class="class" id="id" style="color:red">A paragraph</p> |
| 108 | ``` |
| 109 | |
| 110 | If the attribute block can't be parsed as attributes, it will be |
| 111 | parsed as a regular paragraph: |
| 112 | |
| 113 | ``` |
| 114 | {#id .cla*ss* |
| 115 | . |
| 116 | <p>{#id .cla<strong>ss</strong></p> |
| 117 | ``` |
| 118 | |
| 119 | You can use consecutive attribute blocks. |
| 120 | In case of conflict, later values take precedence over earlier ones, |
| 121 | but classes accumulate: |
| 122 | |
| 123 | ``` |
| 124 | {#id} |
| 125 | {key=val} |
| 126 | {.foo .bar} |
| 127 | {key=val2} |
| 128 | {.baz} |
| 129 | {#id2} |
| 130 | Okay |
| 131 | . |
| 132 | <p class="foo bar baz" id="id2" key="val2">Okay</p> |
| 133 | ``` |
| 134 | |
| 135 | Attributes on different kinds of blocks: |
| 136 | |
| 137 | ``` |
| 138 | {#id} |
| 139 | > Block quote |
| 140 | . |
| 141 | <blockquote id="id"> |
| 142 | <p>Block quote</p> |
| 143 | </blockquote> |
| 144 | ``` |
| 145 | |
| 146 | ``` |
| 147 | {#id} |
| 148 | # Heading |
| 149 | . |
| 150 | <section id="id"> |
| 151 | <h1>Heading</h1> |
| 152 | </section> |
| 153 | ``` |
| 154 | |
| 155 | ``` |
| 156 | {.blue} |
| 157 | - - - - - |
| 158 | . |
| 159 | <hr class="blue"> |
| 160 | ``` |
| 161 | |
| 162 | ```` |
| 163 | {highlight=3} |
| 164 | ``` ruby |
| 165 | x = 3 |
| 166 | ``` |
| 167 | . |
| 168 | <pre highlight="3"><code class="language-ruby">x = 3 |
| 169 | </code></pre> |
| 170 | ```` |
| 171 | |
| 172 | ``` |
| 173 | {.special} |
| 174 | 1. one |
| 175 | 2. two |
| 176 | . |
| 177 | <ol class="special"> |
| 178 | <li> |
| 179 | one |
| 180 | </li> |
| 181 | <li> |
| 182 | two |
| 183 | </li> |
| 184 | </ol> |
| 185 | ``` |
| 186 | |
| 187 | ``` |
| 188 | > {.foo} |
| 189 | > > {.bar} |
| 190 | > > nested |
| 191 | . |
| 192 | <blockquote> |
| 193 | <blockquote class="foo"> |
| 194 | <p class="bar">nested</p> |
| 195 | </blockquote> |
| 196 | </blockquote> |
| 197 | ``` |
| 198 | |
| 199 | Comments start at a `%` character |
| 200 | (not in quotes) and end with another `%` or |
| 201 | the end of the attribute (`}`). |
| 202 | These can be used to comment up an attribute |
| 203 | list or without any real attributes. |
| 204 | |
| 205 | ``` |
| 206 | foo{#ident % this is a comment % .class} |
| 207 | . |
| 208 | <p><span class="class" id="ident">foo</span></p> |
| 209 | ``` |
| 210 | |
| 211 | ``` |
| 212 | foo{#ident % this is a comment} |
| 213 | . |
| 214 | <p><span id="ident">foo</span></p> |
| 215 | ``` |
| 216 | |
| 217 | In block-level comment, subsequent lines must |
| 218 | be indented, as with attributes: |
| 219 | |
| 220 | ``` |
| 221 | {% This is a comment before a |
| 222 | block-level item. %} |
| 223 | Paragraph. |
| 224 | . |
| 225 | <p>Paragraph.</p> |
| 226 | ``` |
| 227 | |
| 228 | Inline attributes can be empty: |
| 229 | |
| 230 | ``` |
| 231 | hi{} |
| 232 | . |
| 233 | <p>hi</p> |
| 234 | ``` |
| 235 | |
| 236 | Block attributes can be empty: |
| 237 | |
| 238 | ``` |
| 239 | {} |
| 240 | hi |
| 241 | . |
| 242 | <p>hi</p> |
| 243 | ``` |
| 244 | |
| 245 | Non-attributes: |
| 246 | |
| 247 | ``` |
| 248 | text{a=x |
| 249 | |
| 250 | hello |
| 251 | . |
| 252 | <p>text{a=x</p> |
| 253 | <p>hello</p> |
| 254 | ``` |
| 255 | |
| 256 | ``` |
| 257 | {a=x |
| 258 | hello |
| 259 | . |
| 260 | <p>{a=x |
| 261 | hello</p> |
| 262 | ``` |
| 263 | |
| 264 | ``` |
| 265 | text{a=x |
| 266 | # non-heading |
| 267 | . |
| 268 | <p>text{a=x |
| 269 | # non-heading</p> |
| 270 | ``` |
| 271 | |
| 272 | ``` |
| 273 | {a=x |
| 274 | # non-heading |
| 275 | . |
| 276 | <p>{a=x |
| 277 | # non-heading</p> |
| 278 | ``` |
| 279 | |
| 280 | ``` a |
| 281 | { |
| 282 | attr="long |
| 283 | value |
| 284 | spanning |
| 285 | multiple |
| 286 | lines" |
| 287 | } |
| 288 | > a |
| 289 | . |
| 290 | doc |
| 291 | blockquote attr="long value spanning multiple lines" |
| 292 | para |
| 293 | str text="a" |
| 294 | ``` |
| 295 | |
| 296 | ``` a |
| 297 | > {key="bar |
| 298 | > a\$bim"} |
| 299 | > ou |
| 300 | . |
| 301 | doc |
| 302 | blockquote |
| 303 | para key="bar a$bim" |
| 304 | str text="ou" |
| 305 | ``` |