This section explains how you can automatically add line numbers,
“expand” tab characters and colorize the source code contained in
<pre>
, <codeblock>
or any
other element specializing <pre>
.
<pre>
, <codeblock>
or any
other element specializing <pre>
is done by adding
one or more of the following classes to the @outputclass
attribute of
this element:<pre>
element.<pre>
element. L, a “programming
language” such as c, java, css,
xml, specifies how the source code should be
colorized.<pre>
element, if any. See example below.
RememberWhen the
<outputclass>
attribute of any element specializing <pre>
contains class line-numbers/line-numbers-N and/or
class language-L , then class tab-width-8 is
implicitly specified too, that is, whitespace normalization is
automatically performed. If this is not what you want, please explicitly
add class tab-width-0 to @outputclass . |
1 2 3 4 5 6 7 8 |
<pre outputclass="language-c line-numbers tab-width-4">/* Hello World */ #include <stdio.h&ght; int main() { printf("Hello World\n"); return 0; }</pre> |
1 2 3 4 5 6 7 8 |
/* Hello World */ #include <stdio.h> int main() { printf("Hello World\n"); return 0; } |
@outputclass
implicitly also
contains tab-width-8. First line " /tmp/" starts with
4 space characters.
1 2 3 4 5 6 7 8 9 10 11 |
<pre outputclass="line-numbers"> /tmp/ /usr/ bin/ lib/ <b>local/</b> <b>bin/</b> <b>lib/</b> <b>src/</b> src/ /var/ </pre> |
1 2 3 4 5 6 7 8 9 10 11 |
/tmp/ /usr/ bin/ lib/ local/ bin/ lib/ src/ src/ /var/ |