summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/base/more-macros.opm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/optex/base/more-macros.opm')
-rw-r--r--macros/luatex/optex/base/more-macros.opm30
1 files changed, 28 insertions, 2 deletions
diff --git a/macros/luatex/optex/base/more-macros.opm b/macros/luatex/optex/base/more-macros.opm
index 51f1919870..595a4f2ed3 100644
--- a/macros/luatex/optex/base/more-macros.opm
+++ b/macros/luatex/optex/base/more-macros.opm
@@ -1,6 +1,6 @@
%% This is part of OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \eoldef {OpTeX useful macos <2020-05-03>} % preloaded in format
+\_codedecl \eoldef {OpTeX useful macos <2020-05-22>} % preloaded in format
\_doc -----------------------------
We define \`\opinput` `{<file name>}` macro which
@@ -147,6 +147,30 @@
\_public \eoldef \skiptoeol \bracedparam ;
\_doc -----------------------------
+ \`\scantoeol``\macro <text to end of line>` scans the
+ `<text to end of line>` in verbatim mode and runs the
+ `\macro{<text to end of line>}`. The `\macro`
+ can be defined `\def\macro#1{...\scantextokens{#1}...}`.
+ The new tokenization of the parameter is processed when the parameter is used,
+ no when the parameter is scanned. This principle is used in definition
+ of \^`\chap`, \^`\sec`, \^`\secc` and \^`\_Xtoc` macros.
+ It means that user can write \code{\\sec text `&` text} for example.
+ Inline verbatim works in title sections.
+
+ The verbatim scanner of `\scatoeol` keeps category 7 for `^` in
+ order to be able to use `^^J` as comment chracter which means that
+ the next line continues.
+ \_cod -----------------------------
+
+\_def\_scantoeol#1{\def\_tmp{#1}\_begingroup \_setscancatcodes \_scantoeolA}
+\_def\_setscancatcodes{\_setverb \_catcode`\^^M=12\_catcode`\^=7\_catcode`\ =10\_catcode`\^^J=14 }
+\_catcode`\^^M=12 %
+\_def\_scantoeolA#1^^M{\_endgroup \_tmp{#1}}%
+\_normalcatcodes %
+
+\_public \scantoeol ;
+
+ \_doc -----------------------------
The \`\replstring``\macro{<textA>}{<textB>}`
replaces all occurrences of `<textA>` by `<textB>` in the `\macro` body.
The `\macro` must be defined without parameters. The occurrences of
@@ -176,7 +200,8 @@
If you really need primitive `\catcode` then you can use `\_catcode`.
\_cod -----------------------------
-\_def\catcode{\_catcode\_string} % more robust in cases \catcode` or \catcode"
+\_def\catcode#1{\_catcode \_if`\_noexpand#1\_ea`\_else\_if"\_noexpand#1"\_else
+ \_if'\_noexpand#1'\_else \_ea\_ea\_ea\_ea\_ea\_ea\_ea#1\_fi\_fi\_fi}
\_doc -----------------------------
The \`\removespaces` `<text with spaces >{}` expands to <textwithoutspaces>.
@@ -237,5 +262,6 @@
\_endcode % -------------------------------------
+2020-05-22 robust \catcode newly defined in order \catcode\string.... be possible
2020-05-03 \load macro introduced
2020-03-15 released