-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
5.6-code-block.tex
36 lines (31 loc) · 1.9 KB
/
5.6-code-block.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
\definesubsection{Code block}
\begin{identifier}{code-block}
<prefix ::+> *<language ![,]+>?<options .*>
<content .*>
<prefix>
\end{identifier}
\definetextualcomponent{code block}{font-family: monospace; white-space: preserve} \\
The code block is a \g{guarded line directive}. It marks the \g{text} to belong to a \g{textual component} that somehow distinguishes the block as source code. Only the \g{text} held by the \g{content binding} is outputted to the \g{resulting textual component}. The code block \g{directive} cannot contain any other \gpl{directive}. \\
The \gpl{newline} and \g{whitespace} must be represented exactly as in the source text. Multiple consecutive \g{whitespace} \gpl{character} cannot be combined and must be individually represented. A \g{newline} \g{character} cannot be escaped and must always result in a new line being started. \G{escaping} is deactivated within the content, meaning backslashes are output literally in the \g{resulting textual component}. \\
The \inline$options$ \g{binding} holds potential parameters that can configure the \g{style} of the \g{resulting textual component}. The syntax and effect of the options is \g{implementation dependant}. If a language is requested in the \inline$language$ \g{binding} that the \g{implementation} does not have specific support for, a \g{warning} is \glink{signalling}{signalled}. The language \inline$text$ must always be supported and will incur no styling changes. \\
\begin{examples}
\begin{examplesource}
Some unexciting code:
:: common-lisp
(print "Hello world")
::
\end{examplesource}
&$\Rightarrow$&
\begin{tabular}{@{}l@{}}
Some unexciting code: \\
\begin{lstlisting}[style=codestyle,language=Lisp,showstringspaces=false]
(print "Hello world")
\end{lstlisting}
\end{tabular}
\end{examples}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "markless"
%%% TeX-engine: luatex
%%% TeX-command-extra-options: "-shell-escape"
%%% End: