Inline Attribute Lists

March 1, 2016

docs

Mmark is a powerful markdown parser.

With Inline Attribute Lists (IALs) you can add extra information to block elements, think of extra classes, attributes or an ID. In Mmark these have the syntax: {#id .class attr="key"}. And should be specified before a block level element.

These will mostly be backend specific, i.e. a {color="blue"} might do something in HTML5 output, but does nothing in the XML v2 output. Worse yet; the XML might not validate anymore. Mmark try to help here by white listing the allowed attributes for an element (this happens in each renderer and is currently a work in progress).

Prime example is the difference between XMLv2 and XMLv3 input for list, where we have the style (v2) and type (v3) attribute for list styling. Mmark will drop style in v3 and use type and vice versa .

So you can just specify both and Mmark will do the “right thing” ™.

BlockCode

In a blockcode you can specify the language of the block:

~~~ go
// Go stuff here
~~~

Mmark will treat the type attribute in the same way as this language specifier, i.e. for XML output this will become: type="go" and in HTML this will be class="language-go. So the following is equivalent:

{type="go"}
~~~
// Go stuff here
~~~

The language specifier has precedence over the type= attribute.

Further more there is prefix=".." which allows the source code to be prefix with a string (at the beginning of each line). This is handled by Mmark and the attribute prefix is dropped from the final output.

Then there is callout=".." which enables callouts parsing in Mmark. This is handled by Mmark and the attribute callout is dropped from the final output.

Things like align are supported by each renderer and don’t require special support from Mmark.

Lists

An list in XML v2 supports only two attributes: style and counter. Style allows you to define different bullet styles, i.e. <list style="format (%I)">. Counter is used to have a document wide lists that keeps on incrementing. In Mmark you are better of using an example list.

For v3 there was a slight renaming, counter became group, style became type. Spacing and start were added, spacing adds extra blank lines between the items and start allows you to specify with what number to start (not supported in XML v2). Mmark is smart enough to detect the starting number of a list:

2. item1
3. item2

will set start=2 for you. Again for groups you’re better of using example lists.

Also see this blog post on styling lists.

Mmark  Lists  Attribute  Inline  Markdown