Extension: fenced_code_attributes
Optionally, you may attach attributes to fenced or backtick code block using this syntax:
~~~~ {#mycode .haskell .numberLines startFrom="100"}
qsort [] = []
qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++
qsort (filter (>= x) xs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here mycode
is an identifier, haskell
and numberLines
are classes, and startFrom
is an attribute with value 100
. Some output formats can use this information to do syntax highlighting. Currently, the only output formats that uses this information are HTML, LaTeX, Docx, Ms, and PowerPoint. If highlighting is supported for your output format and language, then the code block above will appear highlighted, with numbered lines. (To see which languages are supported, type pandoc --list-highlight-languages
.) Otherwise, the code block above will appear as follows:
<pre id="mycode" class="haskell numberLines" startFrom="100">
<code>
...
</code>
</pre>
The numberLines
(or number-lines
) class will cause the lines of the code block to be numbered, starting with 1
or the value of the startFrom
attribute. The lineAnchors
(or line-anchors
) class will cause the lines to be clickable anchors in HTML output.
A shortcut form can also be used for specifying the language of the code block:
```haskell
qsort [] = []
```
This is equivalent to:
``` {.haskell}
qsort [] = []
```
If the fenced_code_attributes
extension is disabled, but input contains class attribute(s) for the code block, the first class attribute will be printed after the opening fence as a bare word.
To prevent all highlighting, use the --no-highlight
flag. To set the highlighting style, use --highlight-style
. For more information on highlighting, see Syntax highlighting, below.