djot-0.1.0.0: test/attributes.test
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}
.
<p>foo <span class="ru">привет</span></p>
```
```
(some text){.attr}
.
<p>(some <span class="attr">text)</span></p>
```
```
[some text]{.attr}
.
<p><span class="attr">some text</span></p>
```
Ensure that emphasis that starts before the attribute can still close,
even if the attribute contains a potential closer.
```
a *b{#id key="*"}*
.
<p>a <strong><span id="id" key="*">b</span></strong></p>
```
```
a *b{#id key="*"}o
.
<p>a <span id="id" key="*">*b</span>o</p>
```
Don't mind braces in quotes:
```
hi{key="{#hi"}
.
<p><span key="{#hi">hi</span></p>
```
Process escapes correctly:
```
hi{key="\\\\\*"}
{key="\\\\\*"}
foo
.
<p><span key="\\*">hi</span></p>
<p key="\\*">foo</p>
```
Don't allow attributes to start when we're parsing a potential
attribute.
```
hi\{key="abc{#hi}"
.
<p>hi{key=“<span id="hi">abc</span>”</p>
```
```
hi{key="\"#hi"}
.
<p><span key=""#hi">hi</span></p>
```
```
hi{key="hi\"#hi"}
.
<p><span key="hi"#hi">hi</span></p>
```
Line break:
```
hi{#id .class
key="value"}
.
<p><span id="id" class="class" key="value">hi</span></p>
```
Here there is nothing for the attribute to attach to:
```
{#id} at beginning
.
<p> at beginning</p>
```
```
After {#id} space
{.class}
.
<p>After space
</p>
```
Block attributes come before the block, on a line by themselves.
```
{#id .class}
A paragraph
.
<p id="id" class="class">A paragraph</p>
```
Use indentation if you need to continue the attributes over a line break.
```
{#id .class
style="color:red"}
A paragraph
.
<p id="id" class="class" style="color:red">A paragraph</p>
```
If the attribute block can't be parsed as attributes, it will be
parsed as a regular paragraph:
```
{#id .cla*ss*
.
<p>{#id .cla<strong>ss</strong></p>
```
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
.
<p class="foo bar baz" key="val2" id="id2">Okay</p>
```
Attributes on different kinds of blocks:
```
{#id}
> Block quote
.
<blockquote id="id">
<p>Block quote</p>
</blockquote>
```
```
{#id}
# Heading
.
<section id="id">
<h1>Heading</h1>
</section>
```
```
{.blue}
- - - - -
.
<hr class="blue">
```
````
{highlight=3}
``` ruby
x = 3
```
.
<pre highlight="3"><code class="language-ruby">x = 3
</code></pre>
````
```
{.special}
1. one
2. two
.
<ol class="special">
<li>
one
</li>
<li>
two
</li>
</ol>
```
```
> {.foo}
> > {.bar}
> > nested
.
<blockquote>
<blockquote class="foo">
<p class="bar">nested</p>
</blockquote>
</blockquote>
```
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}
.
<p><span id="ident" class="class">foo</span></p>
```
```
foo{#ident % this is a comment}
.
<p><span id="ident">foo</span></p>
```
In block-level comment, subsequent lines must
be indented, as with attributes:
```
{% This is a comment before a
block-level item. %}
Paragraph.
.
<p>Paragraph.</p>
```
Inline attributes can be empty:
```
hi{}
.
<p>hi</p>
```
Block attributes can be empty:
```
{}
hi
.
<p>hi</p>
```
Non-attributes:
```
text{a=x
hello
.
<p>text{a=x</p>
<p>hello</p>
```
skip ```
skip {a=x
skip hello
skip .
skip <p>{a=x
skip hello</p>
skip ```
```
text{a=x
# non-heading
.
<p>text{a=x
# non-heading</p>
```
skip ```
skip {a=x
skip # non-heading
skip .
skip <p>{a=x
skip # non-heading</p>
skip ```
```
{a=" inline text
.
<p>{a=“ inline text</p>
```
```
{
attr="long
value
spanning
multiple
lines"
}
> a
.
<blockquote attr="long value spanning multiple lines">
<p>a</p>
</blockquote>
```
```
> {key="bar
> a\$bim"}
> ou
.
<blockquote>
<p key="bar a$bim">ou</p>
</blockquote>
```