size: 3 KiB

1An inline attribute allies to the preceding element, which might
2be complex (span, emphasis, link) or a simple word (defined as a
3sequence of non-ASCII-whitespace characters).
4```
5foo привет{.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
22Ensure that emphasis that starts before the attribute can still close,
23even if the attribute contains a potential closer.
24
25```
26a *b{#id key="*"}*
27.
28<p>a <strong><span id="id" key="*">b</span></strong></p>
29```
30
31```
32a *b{#id key="*"}o
33.
34<p>a <span id="id" key="*">*b</span>o</p>
35```
36
37Don't mind braces in quotes:
38
39```
40hi{key="{#hi"}
41.
42<p><span key="{#hi">hi</span></p>
43```
44
45Don't allow attributes to start when we're parsing a potential
46attribute.
47
48```
49hi\{key="abc{#hi}"
50.
51<p>hi{key=&ldquo;<span id="hi">abc</span>&rdquo;</p>
52```
53
54```
55hi{key="\"#hi"}
56.
57<p><span key="&quot;#hi">hi</span></p>
58```
59
60```
61hi{key="hi\"#hi"}
62.
63<p><span key="hi&quot;#hi">hi</span></p>
64```
65
66Line break:
67
68```
69hi{#id .class
70key="value"}
71.
72<p><span class="class" id="id" key="value">hi</span></p>
73```
74
75Here there is nothing for the attribute to attach to:
76
77```
78{#id} at beginning
79.
80<p> at beginning</p>
81```
82
83```
84After {#id} space
85{.class}
86.
87<p>After space
88</p>
89```
90
91Block attributes come before the block, on a line by themselves.
92
93```
94{#id .class}
95A paragraph
96.
97<p class="class" id="id">A paragraph</p>
98```
99
100Use indentation if you need to continue the attributes over a line break.
101
102```
103{#id .class
104 style="color:red"}
105A paragraph
106.
107<p class="class" id="id" style="color:red">A paragraph</p>
108```
109
110If the attribute block can't be parsed as attributes, it will be
111parsed as a regular paragraph:
112
113```
114{#id .cla*ss*
115.
116<p>{#id .cla<strong>ss</strong></p>
117```
118
119You can use consecutive attribute blocks.
120In case of conflict, later values take precedence over earlier ones,
121but classes accumulate:
122
123```
124{#id}
125{key=val}
126{.foo .bar}
127{key=val2}
128{.baz}
129{#id2}
130Okay
131.
132<p class="foo bar baz" id="id2" key="val2">Okay</p>
133```
134
135Attributes 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
165x = 3
166```
167.
168<pre highlight="3"><code class="language-ruby">x = 3
169</code></pre>
170````
171
172```
173{.special}
1741. one
1752. two
176.
177<ol class="special">
178<li>
179one
180</li>
181<li>
182two
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
199Comments start at a `%` character
200(not in quotes) and end with another `%` or
201the end of the attribute (`}`).
202These can be used to comment up an attribute
203list or without any real attributes.
204
205```
206foo{#ident % this is a comment % .class}
207.
208<p><span class="class" id="ident">foo</span></p>
209```
210
211```
212foo{#ident % this is a comment}
213.
214<p><span id="ident">foo</span></p>
215```
216
217In block-level comment, subsequent lines must
218be indented, as with attributes:
219
220```
221{% This is a comment before a
222 block-level item. %}
223Paragraph.
224.
225<p>Paragraph.</p>
226```
227
228Inline attributes can be empty:
229
230```
231hi{}
232.
233<p>hi</p>
234```
235
236Block attributes can be empty:
237
238```
239{}
240hi
241.
242<p>hi</p>
243```
244
245Non-attributes:
246
247```
248text{a=x
249
250hello
251.
252<p>text{a=x</p>
253<p>hello</p>
254```
255
256```
257{a=x
258hello
259.
260<p>{a=x
261hello</p>
262```
263
264```
265text{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.
290doc
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.
301doc
302 blockquote
303 para key="bar a$bim"
304 str text="ou"
305```