An inline attribute attaches to the preceding element, which might be complex (span, emphasis, link) or a simple word (defined as a sequence of non-ASCII-whitespace characters). ``` foo привет{.ru} .

foo привет

``` ``` (some text){.attr} .

(some text)

``` ``` [some text]{.attr} .

some text

``` Ensure that emphasis that starts before the attribute can still close, even if the attribute contains a potential closer. ``` a *b{#id key="*"}* .

a b

``` ``` a *b{#id key="*"}o .

a *bo

``` Don't mind braces in quotes: ``` hi{key="{#hi"} .

hi

``` Process escapes correctly: ``` hi{key="\\\\\*"} {key="\\\\\*"} foo .

hi

foo

``` Don't allow attributes to start when we're parsing a potential attribute. ``` hi\{key="abc{#hi}" .

hi{key=“abc

``` ``` hi{key="\"#hi"} .

hi

``` ``` hi{key="hi\"#hi"} .

hi

``` Line break: ``` hi{#id .class key="value"} .

hi

``` Here there is nothing for the attribute to attach to: ``` {#id} at beginning .

at beginning

``` ``` After {#id} space {.class} .

After space

``` Block attributes come before the block, on a line by themselves. ``` {#id .class} A paragraph .

A paragraph

``` Use indentation if you need to continue the attributes over a line break. ``` {#id .class style="color:red"} A paragraph .

A paragraph

``` If the attribute block can't be parsed as attributes, it will be parsed as a regular paragraph: ``` {#id .cla*ss* .

{#id .class

``` You can use consecutive attribute blocks. In case of conflict, later values take precedence over earlier ones, but classes accumulate: ``` {#id} {key=val} {.foo .bar} {key=val2} {.baz} {#id2} Okay .

Okay

``` Attributes on different kinds of blocks: ``` {#id} > Block quote .

Block quote

``` ``` {#id} # Heading .

Heading

``` ``` {.blue} - - - - - .
``` ```` {highlight=3} ``` ruby x = 3 ``` .
x = 3
```` ``` {.special} 1. one 2. two .
  1. one
  2. two
``` ``` > {.foo} > > {.bar} > > nested .

nested

``` Comments start at a `%` character (not in quotes) and end with another `%` or the end of the attribute (`}`). These can be used to comment up an attribute list or without any real attributes. ``` foo{#ident % this is a comment % .class} .

foo

``` ``` foo{#ident % this is a comment} .

foo

``` In block-level comment, subsequent lines must be indented, as with attributes: ``` {% This is a comment before a block-level item. %} Paragraph. .

Paragraph.

``` Inline attributes can be empty: ``` hi{} .

hi

``` Block attributes can be empty: ``` {} hi .

hi

``` Non-attributes: ``` text{a=x hello .

text{a=x

hello

``` skip ``` skip {a=x skip hello skip . skip

{a=x skip hello

skip ``` ``` text{a=x # non-heading .

text{a=x # non-heading

``` skip ``` skip {a=x skip # non-heading skip . skip

{a=x skip # non-heading

skip ``` ``` {a=" inline text .

{a=“ inline text

``` ``` { attr="long value spanning multiple lines" } > a .

a

``` ``` > {key="bar > a\$bim"} > ou .

ou

```