From bdead7ff97ef61cca4f56b4a153cc85e18c41fda Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 15 Jan 2021 03:05:16 +0000 Subject: CTAN sync 202101150305 --- macros/luatex/optex/base/hi-syntax.opm | 62 ++++++++++++++++------------------ 1 file changed, 30 insertions(+), 32 deletions(-) (limited to 'macros/luatex/optex/base/hi-syntax.opm') diff --git a/macros/luatex/optex/base/hi-syntax.opm b/macros/luatex/optex/base/hi-syntax.opm index 540c618242..eb6d747914 100644 --- a/macros/luatex/optex/base/hi-syntax.opm +++ b/macros/luatex/optex/base/hi-syntax.opm @@ -1,24 +1,24 @@ -%% This is part of OpTeX project, see http://petr.olsak.net/optex +%% This is part of the OpTeX project, see http://petr.olsak.net/optex \_codedecl \hisyntax {Syntax highlithing of verbatim listings <2020-04-04>} % preloaded in format \_doc ----------------------------- - The following macros `\replfromto` and `\replthis` manipulate with the + The following macros `\replfromto` and `\replthis` manipulate with the verbatim text which has been read already and stored in the `\_tmpb` macro. - + The \`\replfromto` `{}{}{}` finds first `` then the - first `` following by `` pattern and the + first `` following by `` pattern and the `` between them is packed to `#1`. Then `` is replaced by ``. The `` parameter can use `#1` which is replaced by the ``. The `\replfromto` continues by finding next ``, then, next `` - repeatedly over the whole verbatim text. If the verbatim text is ended by - opened `` but not closing by `` then `` is appended to the - verbatim text automatically and the last part of verbatim text is replaced too. + repeatedly over the whole verbatim text. If the verbatim text is ended by + opened `` but not closing by `` then `` is appended to the + verbatim text automatically and the last part of the verbatim text is replaced too. First two parameters are expanded before usage of `\replfromto`. You can - use `\csstring\%` or something else here. + use `\csstring\%` or something else here. \_cod ----------------------------- \_def\_replfromto #1#2{\_edef\_tmpa{{#1}{#2}}\_ea\_replfromtoE\_tmpa} @@ -26,10 +26,10 @@ \_def\_replfrom##1#1##2{\_addto\_tmpb{##1}% \_ifx\_end##2\_ea\_replstop \_else \_afterfi{\_replto##2}\_fi}% \_def\_replto##1#2##2{% - \_ifx\_end##2\_afterfi{\_replfin##1}\_else + \_ifx\_end##2\_afterfi{\_replfin##1}\_else \_addto\_tmpb{#3}% \_afterfi{\_replfrom##2}\_fi}% - \_def\_replfin##1#1\_end{\_addto\_tmpb{#3}\_replstop}% + \_def\_replfin##1#1\_end{\_addto\_tmpb{#3}\_replstop}% \_edef\_tmpb{\_ea}\_ea\_replfrom\_tmpb#1\_end#2\_end\_end\_relax } \_def\_replstop#1\_end\_relax{} @@ -55,7 +55,7 @@ The \`\_xscan` macro does replacing `\x` by `\z` in the post-processing phase. The `\x {}` expands to `\_xscan {}^^J^`. - If `#3` is `\_end` then it signals that something wrong happens, the + If `#3` is `\_end` then it signals that something wrong happens, the `` was not terminated by legal `` when `\replfromto` did work. We must to fix it by the \`\_xscanR` macro. \_cod ----------------------------- @@ -67,7 +67,7 @@ \_doc ----------------------------- The \`\hicolor` ` ` defines `\_z{}` - as `{}`. It should be used in the context of + as `{}`. It should be used in the context of `\x {}` macros. \_cod ----------------------------- @@ -76,9 +76,9 @@ \_doc ----------------------------- The \`\hisyntax``{}` re-defines default \^`\_prepareverbdata``` in order to it does more things: - It saves `` to `\_tmpb`, appends `\n` around spaces and - `^^J` characters in pre-processing phase, it opens `hisyntax-.opm` - file if `\_hisyntax` is not defined. Then `\_the\_isyntax` + It saves `` to `\_tmpb`, appends `\n` around spaces and + `^^J` characters in pre-processing phase, it opens `hisyntax-.opm` + file if `\_hisyntax` is not defined. Then `\_the\_isyntax` is processed. Finally, the post-processing phase is realized by setting appropriate values to `\x` and `\y` macros and doing `\_edef\_tmpb{\_tmpb}`. @@ -138,12 +138,12 @@ The user can write \endtt and the code is colorized by C syntax. The user can write `\everytt={\hisyntax{C}}` and all verbatim listings are -colorized. +colorized. The \^`\hisyntax``{}` reads the file `hisyntax-.opm` where the colorization is declared. The parameter `` is case insensitive and the -file name must include it in lowercase letters. For example the file -`hisyntax-c.opm` looks like: +file name must include it in lowercase letters. For example, the file +`hisyntax-c.opm` looks like this: \printdoc hisyntax-c.opm @@ -153,8 +153,8 @@ You can take inspiration from these files and declare more languages. User can re-declare colors by `\hicolors={...}` This value has precedence before `\_hicolors` values declared in the `hicolors-.opm` file. What exactly to do: copy `\_hicolors={...}` -from `hicolors-.opm` to your document, -rename it as `\hicolors={...}` and do you own colors modifications. +from `hicolors-.opm` to your document, +rename it as `\hicolors={...}` and do you own colors modifications. Another way to set non-default colors is to declare `\newtoks\hicolors` (without the `_` prefix) and set the colors palette here. @@ -162,15 +162,13 @@ It has precedence before `\_hicolors` (with the `_` prefix) declared in the `hicolors-.opm` file. This is useful when there are more hi-syntax languages used in one document. -\medskip -\noindent{\bf Notes for hi-syntax macro writers} - -The file `hisyntax-.opm` is read only once in the \TeX/ group. -If there are definitions then they must be declared as global. +\secl4 Notes for hi-syntax macro writers +The file `hisyntax-.opm` is read only once in the \TeX/ group. +If there are definitions then they must be declared as global. The `hisyntax-.opm` file must (globally) declare `\_hisyntax` tokens string where the action over verbatim text is declared typically by `\replfromto` or -`\replthis` macros. +`\replthis` macros. The verbatim text is prepared by {\em pre-processing phase}, then the `\_hisyntax` is applied and then {\em post-processing phase} does final @@ -183,12 +181,12 @@ The pre-processing phase does: finding whole words (no subwords). The `\n` control sequence is removed in the post-processing phase. * Each end of line is represented by `\n^^J\n`. -* The `\_start` control sequence is added before the verbatim text and `\_end` control +* The `\_start` control sequence is added before the verbatim text and the `\_end` control sequence is appended to the end of the verbatim text. These control - sequences are removed in post-processing phase. -\enditems + sequences are removed in the post-processing phase. +\enditems -There are special macros working only in a group when processing the verbatim +Special macros are working only in a group when processing the verbatim text. @@ -209,12 +207,12 @@ text. by `\x C{}` and they are replaced to `\z C{}` without any change. But: \begtt \catcode`\<=13 - \x C{^^J^^J} + \x C{^^J^^J} is replaced by \z C{}^^J\z C{}^^J\z C{} \endtt The `\z {}` is expanded to `\_z:{}` and if - `\hicolor ` is declared then + `\hicolor ` is declared then `\_z:{}` expands to `{}`. So, required color is activated at all lines (separately) where C comment spans. * `\y {}` is replaced by `\` in the post processing phase. It should -- cgit v1.2.3