From 02b9b5088ecbc641f23303a276dd360ecfd0a805 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 18 Nov 2020 22:07:01 +0000 Subject: optex (18nov20) git-svn-id: svn://tug.org/texlive/trunk@56960 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/optex/README | 3 + Master/texmf-dist/doc/luatex/optex/optex-doc.pdf | Bin 1246822 -> 1279767 bytes Master/texmf-dist/doc/luatex/optex/optex-doc.tex | 4 +- Master/texmf-dist/doc/luatex/optex/optex-math.tex | 12 +- .../texmf-dist/doc/luatex/optex/optex-techdoc.tex | 38 ++- .../texmf-dist/doc/luatex/optex/optex-userdoc.tex | 8 +- Master/texmf-dist/tex/luatex/optex/base/alloc.opm | 2 +- Master/texmf-dist/tex/luatex/optex/base/doc.opm | 2 +- Master/texmf-dist/tex/luatex/optex/base/f-lido.opm | 2 +- .../texmf-dist/tex/luatex/optex/base/fams-ini.opm | 2 +- .../tex/luatex/optex/base/fonts-resize.opm | 3 +- .../tex/luatex/optex/base/fonts-select.opm | 53 +++- .../texmf-dist/tex/luatex/optex/base/hi-syntax.opm | 12 +- .../tex/luatex/optex/base/hyphen-lan.opm | 188 ++++++----- .../texmf-dist/tex/luatex/optex/base/languages.opm | 5 +- .../tex/luatex/optex/base/math-macros.opm | 10 +- .../tex/luatex/optex/base/math-unicode.opm | 2 +- Master/texmf-dist/tex/luatex/optex/base/optex.ini | 9 +- Master/texmf-dist/tex/luatex/optex/base/optex.lua | 351 +++++++++++++++++++++ .../texmf-dist/tex/luatex/optex/base/prefixed.opm | 10 +- .../tex/luatex/optex/base/unimath-codes.opm | 6 +- .../texmf-dist/tex/luatex/optex/base/verbatim.opm | 140 ++++++-- Master/texmf-dist/tex/luatex/optex/pkg/qrcode.opm | 2 +- 23 files changed, 722 insertions(+), 142 deletions(-) create mode 100644 Master/texmf-dist/tex/luatex/optex/base/optex.lua (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/luatex/optex/README b/Master/texmf-dist/doc/luatex/optex/README index bcff2e144e7..09029521498 100644 --- a/Master/texmf-dist/doc/luatex/optex/README +++ b/Master/texmf-dist/doc/luatex/optex/README @@ -19,6 +19,9 @@ doc/ ... PDF version of the OpTeX documentation and sources. History: +<0.17> optex.lua introduced (instead external ltluatex.lua) + hyph.patterns are loaded directly by \patterns, not using lua code + \commentchars introduced (comments which are able to interrupt verbatim mode) <0.16> callback.register_x introduced, namespaces for packages corrected kerkis and EBGaramond fontfiles added little corrections diff --git a/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf b/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf index d7242d9d045..62be299a6c7 100644 Binary files a/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf and b/Master/texmf-dist/doc/luatex/optex/optex-doc.pdf differ diff --git a/Master/texmf-dist/doc/luatex/optex/optex-doc.tex b/Master/texmf-dist/doc/luatex/optex/optex-doc.tex index 742b35dc35b..ce043bcbec8 100644 --- a/Master/texmf-dist/doc/luatex/optex/optex-doc.tex +++ b/Master/texmf-dist/doc/luatex/optex/optex-doc.tex @@ -20,14 +20,14 @@ \tit Format Based on Plain \TeX/ and OPmac\fnotemark1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\hfill Version 0.16 +\hfill Version 0.17 \centerline{\it Petr Olšák, 2020} \bigskip \centerline{\url{http://petr.olsak.net/optex}} -\fnotetext {The OPmac package is a set of simple additional macros to Plain \TeX{}. +\fnotetext {OPmac package is a set of simple additional macros to Plain \TeX{}. It enables users to take advantage of \LaTeX/ functionality but keeps Plain \TeX/ simplicity. See \url{http://petr.olsak.net/opmac-e.html} for more information about it.} diff --git a/Master/texmf-dist/doc/luatex/optex/optex-math.tex b/Master/texmf-dist/doc/luatex/optex/optex-math.tex index be25db3970f..97d475af44f 100644 --- a/Master/texmf-dist/doc/luatex/optex/optex-math.tex +++ b/Master/texmf-dist/doc/luatex/optex/optex-math.tex @@ -22,13 +22,13 @@ \addto\_secfont\Blue \addto\_seccfont\Blue \_def\_printsec#1{\_par \_abovetitle{\_penalty-400}\_bigskip - {\_secfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1\_nbpar}\_insertmark{#1}% + {{\_secfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1}\_nbpar}\_insertmark{#1}% \_nobreak \_belowtitle{\_medskip}% \_firstnoindent } \_def\_printsecc#1{\_par \_abovetitle{\_penalty-200}\_medskip - {\_seccfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1\_nbpar}% + {{\_seccfont \_noindent \_raggedright \llap{\_printrefnum[@\_quad]}#1}\_nbpar}% \_nobreak \_belowtitle{\_medskip}% \_firstnoindent } @@ -105,7 +105,13 @@ The math atoms are \ii single/math/object {\em single math objects} or consist only from a single math object then we need not to use brackets. For example `x^2` is a math atom with `x` in nucleus, `2` in exponent and with empty subscript. - Or `a_{i,j}` is a math atom with `a` in nucleus, empty exponent and `i,j` in subscript. + Or `a_{i,j}` is a math atom with `a` in nucleus, empty exponent and `i,j` in subscript.% + \fnote{In \OpTeX/, the character `_` can be interpreted as a part of + control sequence name, not as the subscript constructor. But in common cases, + constructions of math atoms are interpreded exactly as in plain \TeX. See sections + 2.2.2 and 2.14 of \OpTeX/ documentation for more details. If you want to + be sure that `_` is only subscript constructor in \OpTeX/ then you can set \code{\\catcode`\\_=8} + but after this, you cannot use control sequences with `_` character.} The constructors for exponent `^` and for subscript `_` can be used in arbitrary order after the nucleus, for example `z_1^{x+y}` is the same math atom as `z^{x+y}_1`. The single math objects not followed by `^` nor `_` are diff --git a/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex b/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex index d35e6faf4e7..a22e6baab26 100644 --- a/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex +++ b/Master/texmf-dist/doc/luatex/optex/optex-techdoc.tex @@ -71,12 +71,16 @@ The `\_codedecl` will be re-defined later. Individual `*.opm` macro files are read. \verbinput (44-87) optex.ini - % +The file `optex.lua` is embedded into the format as byte-code. +It is documented in section~\ref[lua]. + +\verbinput (89-92) optex.ini + The `\everyjob` register is initialized and the format is saved by the `\dump` command. -\verbinput (89-97) optex.ini +\verbinput (94-102) optex.ini } @@ -179,7 +183,7 @@ The `\margins` macro is documented in the section~\ref[marg]. \printdoc lists.opm \sec Verbatim, listings -\secc Inline and \"display" verbatim +\secc[verb] Inline and \"display" verbatim \printdoc verbatim.opm \secc[hisyntax] Listings with syntax highlighting \printdoctail hi-syntax.opm @@ -244,6 +248,34 @@ The `\margins` macro is documented in the section~\ref[marg]. Miscellaneous macros are here. \printdoc others.opm +\sec[lua] Lua code embedded to the format + +The file `optex.lua` is loaded into the format in `optex.ini` as byte-code +and initialized by `\everyjob`, see section~\ref[init]. + +The file implements part of the functionality from `luatexbase` namespace, +nowadays defined by \LaTeX/ kernel. `luatexbase` deals with modules, +allocators and callback management. Callback management is a nice extension +and is actually used in \OpTeX/. Other functions are defined more or less just +to suit luaotfload's use. + +\newtoks \_hisyntaxlua +\_hisyntaxlua={% + \_hicolor C \Green + \_replfromto {--}{^^J} {\z C{--#1}^^J}% +} + +{\everytt={\typosize[8/10]\_let\_printverbline=\_printcodeline \medskip} + \commentchars-- \def\docfile{optex.lua} \ttline=-1 + \_def\_printcomments{\_medskip + {\_catcodetable0 \_typosize[10/12]\_everypar={}\_scantextokens\_ea{\_vcomments}\par}% + \_bigskip + } + +\verbinput \hisyntax{lua} (4-) optex.lua +} + + \sec Printing documentation \printdoctail doc.opm \printdoc doc.opm diff --git a/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex b/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex index f8ec1cba55d..6083eef7ea6 100644 --- a/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex +++ b/Master/texmf-dist/doc/luatex/optex/optex-userdoc.tex @@ -1055,7 +1055,13 @@ codes. Automatic syntax highlighting is possible, for example `\begtt` \^`\hisyntax{C}` activates colors for C programs. Or `\verbinput` \^`\hisyntax{HTML} (-) file.html` can be used for HTML or XML codes. \OpTeX/ implements C, Python, \TeX/, HTML and XML syntax highlighting. -More languages can be declared, see the section~\ref[hisyntax]. +More languages can be declared, see the section~\ref[hisyntax]. + +If the code is read by \^`\verbinput` and it uses two characters at the front +of the lines as a comment lines, +you can set them by \~`\commentchars```. Such comments are +fully interpreted by \TeX/ (i.e. not verbatim). +Section~\ref[verb] (page \pgref[commentchars]) says more about this feature. \sec Autogenerated lists diff --git a/Master/texmf-dist/tex/luatex/optex/base/alloc.opm b/Master/texmf-dist/tex/luatex/optex/base/alloc.opm index e68db40266f..2272dd38619 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/alloc.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/alloc.opm @@ -86,7 +86,7 @@ \_public \newinsert ; \_doc ----------------------------- - Other allocation macros \`\newattribute` and \`\newcatodetable` + Other allocation macros \`\newattribute` and \`\newcatcodetable` have their counter allocated by the `\newcount` macro. \_cod ----------------------------- diff --git a/Master/texmf-dist/tex/luatex/optex/base/doc.opm b/Master/texmf-dist/tex/luatex/optex/base/doc.opm index e46362e7c63..c86199d76c8 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/doc.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/doc.opm @@ -116,7 +116,7 @@ } \_everytt={\_let\_printverblinenum=\_relax} -\_long\_def\_endverbprinting#1\_end{\_fi \_global\_maxlines=100000 +\_long\_def\_endverbprinting#1\_end#2\_end{\_fi\_fi \_global\_maxlines=100000 \_noindent\_typosize[8/]\_dots etc. (see {\_tt\Brown\docfile})} \_doc ----------------------------- diff --git a/Master/texmf-dist/tex/luatex/optex/base/f-lido.opm b/Master/texmf-dist/tex/luatex/optex/base/f-lido.opm index b91bf1df4f2..947ed8ecc77 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/f-lido.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/f-lido.opm @@ -3,7 +3,7 @@ \_famdecl [Lido] \Lido {by StormType Foundry designed for "lidove noviny"} {\caps \cond} {\rm \bf \mr \mi \it \bi} {Termes} {[LidoSTF]} - {\_def\_fontnamegen {[LidoSTF\_condV\_currV]:\_capsV\_fontfeatures}} + {\_def\_fontnamegen {[LidoSTF\_condV\_currV]:mode=node;script=latn;\_capsV\_fontfeatures}} \_wlog{\_detokenize{% Variants:^^J diff --git a/Master/texmf-dist/tex/luatex/optex/base/fams-ini.opm b/Master/texmf-dist/tex/luatex/optex/base/fams-ini.opm index c92782260b7..3fde594c350 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/fams-ini.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/fams-ini.opm @@ -14,7 +14,7 @@ \ttprop,\ttprop\bolder,\quotset: {\rm\bf\it\bi} \caps: {\rm\it} \ttlight,\ttcond,\dunhill: {\rm\it} \upital: {\rm} } -\_famalias [LMfonts] \_famalias [Latin Modern Fonts] +\_famalias [LMfonts] \_famalias [Latin Modern Fonts] \_famalias [lm] \_famtext {TeX Gyre fonts based on Adobe 35:} diff --git a/Master/texmf-dist/tex/luatex/optex/base/fonts-resize.opm b/Master/texmf-dist/tex/luatex/optex/base/fonts-resize.opm index c21f426c890..9611fbd5b93 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/fonts-resize.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/fonts-resize.opm @@ -265,7 +265,8 @@ create a size-dependent selector for such font then you can use % The example above uses the 8\,bit `tfm` font. You can use Unicode font too, of course. The \^`\fontfam` macro initializes the extended `\font` primitive -features for \LuaTeX/. If you didn't use this command, you must to initialize +features for \LuaTeX/ (see section \ref[exfont]). +If you didn't use this command, you must to initialize these features by the \^`\initunifonts` command explicitly, for example: \begtt diff --git a/Master/texmf-dist/tex/luatex/optex/base/fonts-select.opm b/Master/texmf-dist/tex/luatex/optex/base/fonts-select.opm index 83ded2f35b8..8e7ab81fcf4 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/fonts-select.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/fonts-select.opm @@ -3,25 +3,26 @@ \_codedecl \fontfam {Fonts selection system <2020-03-18>} % preloaded in format \_doc ----------------------------- - The \`\initunifonts` initializes extended `\font` primitive - (to be able to load Unicode fonts). Unfortunately, this part of - \OpTeX/ depends on \LaTeX/ lua codes `ltluatex.lua` and - `luaotfload-main.lua`. And this code need to be declared a - control sequence `\e@alloc@attribute@count` by `\countdef` primitive. - Moreover, the `\initunifont` switches with + \`\initunifonts` macro extends \LuaTeX's font capabalities, + in order to be able to load Unicode fonts. Unfortunately, this part of + \OpTeX/ depends on `luaotfload` package, which adapts Con\TeX/t's generic + font loader for plain \TeX/ and \LaTeX. `luaotfload` uses Lua functions + from \LaTeX's `luatexbase` namespace, we provide our own replacements. + Moreover, `\initunifont` switches with the \^`\_doresizefont` macro to OTF mode which is represented by the macro \`\_doresizeunifont`. This mode includes a fallback to TFM mode if \^`\_fontnamegen` is not defined. - Finally, the `\initunifnt` sets itself to relax because we need not to do + Finally, `\initunifonts` sets itself to relax because we don't want to do this work twice. \_cod ----------------------------- \_def\_initunifonts {% - \_ea\_newcount \_csname e@alloc@attribute@count\_endcsname - \_global \_csname e@alloc@attribute@count\_endcsname=-1 - \_directlua{% - require("ltluatex") - require('luaotfload-main') local _void = luaotfload.main () + \directlua{% + require('luaotfload-main') + print_bak = print + print = function () end + luaotfload.main() + print = print_bak % "print hack" until luaotfload will be corrected }% \_gdef\_rfskipatX ##1" ##2\_relax{"##1"}% \_global\_let \_doresizefont=\_doresizeunifont @@ -663,6 +664,34 @@ with Unicode fonts loaded by \^`\fontfam`. \printdoctail fams-ini.opm +\secc[exfont] Notices about extension of `\font` primitive +%--------------------------------------------------------- + +Unicode fonts are dealed by extended `\font` primitive. This extension is +not activated in \OpTeX/ by default, \^`\initunifonts` macro activates it. +You need not to use \^`\initunifonts` explicitly if \^`\fontfam` macro is +used because \^`\fontfam` runs it internally. + +The \^`\initunifonts` loads the lua code from Luaotfload package which +actually implements the `\font` primitive extension. See its +documentation `luaotfload-latex.pdf` for information about +all possibilities of extended `\font` primitive. + +The \OpTeX/ format is initialized by `luatex` engine by default but +you can initialize it by `luahbtex` engine too. Then the harfbuzz library is +ready to use for font rendering as an alternative of build-in font renderer +from Luaotfload. The harfbuzz library gives more features for rendering +indic and arabic scripts. But it is not used as default, you need to specify +`mode=harf` in fontfeatures field when `\font` is used. Moreover, when +`mode=harf` is used, then you must specify `script` too. For example + +\begtt +\font\devafont=[NotoSansDevanagari-Regular]:mode=harf;script=dev2 +\endtt +% +If `luahbtex` engine is not used then `mode=harf` is ignored. See +Luaotfload documentation for more information. + \endinput 2020-04-18 \_tryloadfamslocal introduced diff --git a/Master/texmf-dist/tex/luatex/optex/base/hi-syntax.opm b/Master/texmf-dist/tex/luatex/optex/base/hi-syntax.opm index 48210fa4b18..e4b09ebafac 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/hi-syntax.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/hi-syntax.opm @@ -85,10 +85,11 @@ \_cod ----------------------------- \_def\_hisyntax#1{\_def\_prepareverbdata##1##2{% - \_let\n=\_relax \_def\t{\n\_noexpand\t\n}\_let\_start=\_relax - \_adef{ }{\n\ \n}\_edef\_tmpb{\_start^^J##2\_end}% - \_replthis{^^J}{\n^^J\n}\_replthis{\n\_end}{\_end}% + \_let\n=\_relax \_let\b=\_relax \_def\t{\n\_noexpand\t\n}\_let\_start=\_relax + \_adef{ }{\n\_noexpand\ \n}\_edef\_tmpb{\_start^^J##2\_end}% + \_replthis{^^J}{\n^^J\b\n}\_replthis{\b\n\_end}{\_end}% \_let\x=\_relax \_let\y=\_relax \_let\z=\_relax \_let\t=\_relax + \_hicomments % keeps comments declared by \commentchars \_endlinechar=`\^^M \_lowercase{\_def\_tmpa{#1}}% \_ifcsname _hialias:\_tmpa\_endcsname \_edef\_tmpa{\_cs{_hialias:\_tmpa}}\_fi @@ -107,8 +108,9 @@ \_else\_opwarning{Syntax highlighting "\_tmpa" undeclared (no file hisyntax-\_tmpa.opm)} \_fi\_fi \_replthis{\_start\n^^J}{}\_replthis{^^J\_end}{^^J}% - \_def\n{}% - \_def\x####1####2{\_xscan{####1}####2^^J^}% + \_def\n{}\_def\b{}\_adef{ }{\_dsp}% + \_bgroup \_lccode`\~=`\ \_lowercase{\_egroup\_def\ {\_noexpand~}}% + \_def\w####1{####1}\_def\x####1####2{\_xscan{####1}####2^^J^}% \_def\y####1{\_ea \_noexpand \_csname ####1\_endcsname}% \_edef\_tmpb{\_tmpb}% \_def\z####1{\_cs{_z:####1}}% diff --git a/Master/texmf-dist/tex/luatex/optex/base/hyphen-lan.opm b/Master/texmf-dist/tex/luatex/optex/base/hyphen-lan.opm index c6a43bc0aff..f78148ff912 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/hyphen-lan.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/hyphen-lan.opm @@ -42,7 +42,7 @@ \_input hyphen % en(USenglish) patterns from TeX82 \_doc ----------------------------- - \`\preplang` ` ` + \`\_preplang` ` ` prepares the\nl `\lang` to its initialization state. Roughly speaking, it does: \begtt \catcode`\<=13 @@ -50,33 +50,55 @@ \def\_lan: {} \def\_ulan: {} \def\_lang {% - \_loadpattrs % loads patterns using Lua code + \_loadpattrs % loads patterns using Lua code \gdef\_lang {\_uselang{}\_Patt } \_lang % runs itself in processing state } \def\lang {\_lang} % public version \lang \endtt - You can see that `\lang` runs \`\_loadpattrs` ` ` - in initialization state and \^`\_uselang` in processing state. + You can see that `\lang` runs \^`\_loadpattrs` and + \^`\_uselang` first (in initialization state) and it runs + only \^`\_uselang` when it is called again (in processing state). \_cod ----------------------------- -\_def\_preplang #1 #2 #3#4 #5 {% - \_chardef#3=#4 - \_sdef{_lan:#4}{#1}\_lowercase{\_sdef{_ulan:#2}}{#1}% - \_def\_next{\_ea\_noexpand\_csname _#1lang\_endcsname} +\_def\_preplang #1 #2 #3 #4 #5 {% + \_ea\_chardef \_csname _#1Patt\_endcsname=#4 + \_sdef{_lan:#4}{#1}\_lowercase{\_sdef{_ulan:#2}}{#1}% + \_def\_next{\_ea\_noexpand\_csname _#1lang\_endcsname}% \_ea\_edef \_csname _#1lang\_endcsname {% - \_lowercase{\_noexpand\_loadpattrs #2} #4 % loads patterns - \_gdef\_next{\_noexpand\_uselang{#1}#3#5}% re-defines itself + \_noexpand\_loadpattrs #3 #4 #2 % loads patterns + \_gdef\_next{\_noexpand\_uselang{#1}\_csname _#1Patt\_endcsname #5}% re-defines itself \_next % runs itself in processing state } \_addto\_langlist{ #1(#2)}% \_sdef{#1lang\_ea}\_ea{\_csname _#1lang\_endcsname}% unprefixed \lang } -\_def\_loadpattrs#1 #2 {% - \_directlua{ - require("luatex-hyphen") - luatexhyphen.loadlanguage("#1",#2) - }% + + \_doc ----------------------------- + \`\_loadpattrs` ` ` + loads hyphenation patterns and hyphenation exceptions for given language + and registers them as `\language=`. + + The is a part of full file name wich is read: + `hyph-.tex`. The patterns and hyphenation exceptions + are saved here in UTF-8 encoding. + The should be a list of individual 's + separated by comma, see the language Serbian below for example. + \_cod ----------------------------- + +\_def\_loadpattrs#1 #2 #3 {% + \_wlog{Loading hyphenation #3: (#1) \_string\language=#2}% + \_begingroup\_setbox0=\_vbox{% we don't want spaces in horizontal mode + \_language=#2\_def\\{#3}% + \_let\patterns=\_patterns \_let\hyphenation=\_hyphenation \_def\message##1{}% + \_loadpattrsA #1,,% + }\_endgroup +} +\_def\_loadpattrsA #1,{\_ifx,#1,\_else + \_isfile {hyph-#1}\_iftrue \_opinput{hyph-#1}% + \_else \_opwarning{Hyph. patterns #1 for \\ not loaded, probably missing package}% + \_def\_opwarning##1{}\_fi + \_ea \_loadpattrsA \_fi } \_doc ----------------------------- @@ -108,64 +130,84 @@ but we load only Unicode patterns (greater than 100), of course. \_cod ----------------------------- -\_preplang enus USenglishmax \_enusPatt 100 23 -\_preplang engb UKenglish \_engbPatt 101 23 -\_preplang it Italian \_itPatt 102 22 -\_preplang ia Interlingua \_iaPatt 103 22 -\_preplang id Indonesian \_idPatt 104 22 - -\_preplang cs Czech \_csPatt 115 23 -\_preplang sk Slovak \_skPatt 116 23 -\_preplang de nGerman \_dePatt 121 22 -\_preplang fr French \_frPatt 122 22 -\_preplang pl Polish \_plPatt 123 22 -\_preplang cy Welsh \_cyPatt 124 23 -\_preplang da Danish \_daPatt 125 22 -\_preplang es Spanish \_esPatt 126 22 -\_preplang sl Slovenian \_slPatt 128 22 -\_preplang fi Finnish \_fiPatt 129 22 -\_preplang hu Hungarian \_huPatt 130 22 -\_preplang tr Turkish \_trPatt 131 22 -\_preplang et Estonian \_etPatt 132 23 -\_preplang eu Basque \_euPatt 133 22 -\_preplang ga Irish \_gaPatt 134 23 -\_preplang nb Bokmal \_nbPatt 135 22 -\_preplang nn Nynorsk \_nnPatt 136 22 -\_preplang nl Dutch \_nlPatt 137 22 -\_preplang pt Portuguese \_ptPatt 138 23 -\_preplang ro Romanian \_roPatt 139 22 -\_preplang hr Croatian \_hrPatt 140 22 -\_preplang zh Pinyin \_zhPatt 141 11 -\_preplang is Icelandic \_isPatt 142 22 -\_preplang hsb Uppersorbian \_hsbPatt 143 22 -\_preplang af Afrikaans \_afPatt 144 12 -\_preplang gl Galician \_glPatt 145 22 -\_preplang kmr Kurmanji \_kmrPatt 146 22 -\_preplang tk Turkmen \_tkPatt 147 22 -\_preplang la Latin \_laPatt 148 22 -\_preplang lac classicLatin \_lacPatt 149 22 -\_preplang lal liturgicalLatin \_lalPatt 150 22 -\_preplang elm monoGreek \_elmPatt 201 11 -\_preplang elp Greek \_elpPatt 202 11 -\_preplang grc ancientGreek \_grcPatt 203 11 -\_preplang ca Catalan \_caPatt 204 22 -\_preplang cop Coptic \_copPatt 205 11 -\_preplang mn Mongolian \_mnPatt 206 22 -\_preplang sa Sanskrit \_saPatt 207 13 -\_preplang ru Russian \_ruPatt 208 22 -\_preplang uk Ukrainian \_ukPatt 209 22 -\_preplang hy Armenian \_hyPatt 210 12 -\_preplang as Assamese \_asPatt 211 11 -\_preplang hi Hindi \_hiPatt 212 11 -\_preplang kn Kannada \_knPatt 213 11 -\_preplang lv Latvian \_lvPatt 215 22 -\_preplang lt Lithuanian \_ltPatt 216 22 -\_preplang ml Malayalam \_mlPatt 217 11 -\_preplang mr Marathi \_mrPatt 218 11 -\_preplang or Oriya \_orPatt 219 11 -\_preplang pa Panjabi \_paPatt 220 11 -\_preplang ta Tamil \_taPatt 221 11 -\_preplang te Telugu \_tePatt 222 11 +\_preplang enus USenglishmax en-us 100 23 +\_preplang engb UKenglish en-gb 101 23 +\_preplang it Italian it 102 22 +\_preplang ia Interlingua ia 103 22 +\_preplang id Indonesian id 104 22 + +\_preplang cs Czech cs 115 23 +\_preplang sk Slovak sk 116 23 +\_preplang de nGerman de-1996 121 22 +\_preplang fr French fr 122 22 +\_preplang pl Polish pl 123 22 +\_preplang cy Welsh cy 124 23 +\_preplang da Danish da 125 22 +\_preplang es Spanish es 126 22 +\_preplang sl Slovenian sl 128 22 +\_preplang fi Finnish fi 129 22 +\_preplang hu Hungarian hu 130 22 +\_preplang tr Turkish tr 131 22 +\_preplang et Estonian et 132 23 +\_preplang eu Basque eu 133 22 +\_preplang ga Irish ga 134 23 +\_preplang nb Bokmal nb 135 22 +\_preplang nn Nynorsk nn 136 22 +\_preplang nl Dutch nl 137 22 +\_preplang pt Portuguese pt 138 23 +\_preplang ro Romanian ro 139 22 +\_preplang hr Croatian hr 140 22 +\_preplang zh Pinyin zh-latn-pinyin 141 11 +\_preplang is Icelandic is 142 22 +\_preplang hsb Uppersorbian hsb 143 22 +\_preplang af Afrikaans af 144 12 +\_preplang gl Galician gl 145 22 +\_preplang kmr Kurmanji kmr 146 22 +\_preplang tk Turkmen tk 147 22 +\_preplang la Latin la 148 22 +\_preplang lac classicLatin la-x-classic 149 22 +\_preplang lal liturgicalLatin la-x-liturgic 150 22 +\_preplang elm monoGreek el-monoton 201 11 +\_preplang elp Greek el-polyton 202 11 +\_preplang grc ancientGreek grc 203 11 +\_preplang ca Catalan ca 204 22 +\_preplang cop Coptic cop 205 11 +\_preplang mn Mongolian mn-cyrl 206 22 +\_preplang sa Sanskrit sa 207 13 +\_preplang ru Russian ru 208 22 +\_preplang uk Ukrainian uk 209 22 +\_preplang hy Armenian hy 210 12 +\_preplang as Assamese as 211 11 +\_preplang hi Hindi hi 212 11 +\_preplang kn Kannada kn 213 11 +\_preplang lv Latvian lv 215 22 +\_preplang lt Lithuanian lt 216 22 +\_preplang ml Malayalam ml 217 11 +\_preplang mr Marathi mr 218 11 +\_preplang or Oriya or 219 11 +\_preplang pa Panjabi pa 220 11 +\_preplang ta Tamil ta 221 11 +\_preplang te Telugu te 222 11 + +\_preplang be Belarusian be 223 22 +\_preplang bg Bulgarian bg 224 22 +\_preplang bn Bengali bn 225 11 +\_preplang cu churchslavonic cu 226 12 +\_preplang deo oldGerman de-1901 227 22 +\_preplang gsw swissGerman de-ch-1901 228 22 +\_preplang eo Esperanto eo 229 22 +\_preplang fur Friulan fur 230 22 +\_preplang gu Gujarati gu 231 11 +\_preplang ka Georgian ka 232 12 +\_preplang mk Macedonian mk 233 22 +\_preplang oc Occitan oc 234 22 +\_preplang pi Pali pi 235 12 +\_preplang pms Piedmontese pms 236 22 +\_preplang rm Romansh rm 237 22 +\_preplang sr Serbian sh-cyrl,sh-latn 238 22 +\_preplang sv Swedish sv 239 22 +\_preplang th Thai th 240 23 +\_preplang ethi Ethiopic mul-ethi 241 11 \_doc ----------------------------- The \`\langlist` includes names of all languages which are ready to load diff --git a/Master/texmf-dist/tex/luatex/optex/base/languages.opm b/Master/texmf-dist/tex/luatex/optex/base/languages.opm index 36800e95dbd..9fa480d96af 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/languages.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/languages.opm @@ -38,7 +38,7 @@ \_langw de Kapitel Tabelle Abbildung Betreff \_langw es Capítulo Tabla Figura Sujeto \_langw fr Chaptire Tableau Figure Matière -\_langw it Capitolo Tabella Fig. Soggetto +\_langw it Capitolo Tabella Fig. Oggetto \_langw pl Rozdział Tabela Ilustracja Temat \_langw gr Κεφάλαιο Πίνακας Σχήμα θέμα \_langw ru Глава Таблица Рисунок Предмет @@ -64,6 +64,9 @@ července srpna září října listopadu prosince \_monthw sk januára februára marca apríla mája júna júla augusta septembra októbra novembra decembra +\_monthw it gennaio febbraio marzo aprile maggio giugno + luglio agosto settembre ottobre novembre dicembre + \_sdef{_mt:today:en}{\_mtext{m\_the\_month} \_the\_day, \_the\_year} \_sdef{_mt:today:cs}{\_the\_day.~\_mtext{m\_the\_month} \_the\_year} diff --git a/Master/texmf-dist/tex/luatex/optex/base/math-macros.opm b/Master/texmf-dist/tex/luatex/optex/base/math-macros.opm index 70983fbda58..c6b22f247b7 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/math-macros.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/math-macros.opm @@ -21,7 +21,9 @@ `\``_` to `\ _` at input processor level. The \`\mathsboff` deactivates it. You can ask by \`\_ifmathsb` if this feature is activated or deactivated. - By default, is is activated in the `\everyjob`, see section~\ref[init]. + By default, it is activated in the `\everyjob`, see section~\ref[init]. + Note, that the `\everyjob` is processed after the first line of the document is + read, so the \^`\matsbon` is activated from second line of the document. \_cod ----------------------------- \catcode`\_ = 8 \let\sb = _ @@ -32,14 +34,14 @@ \_newifi\_ifmathsb \_mathsbfalse \_def \_mathsbon {% \_directlua{ - callback.register_x("process_input_buffer", + callback.add_to_callback("process_input_buffer", function (str) return string.gsub(str.." ", "(\_nbb[a-zA-Z]+)_([a-zA-Z]?[^_a-zA-Z])", "\_pcent 1 _\_pcent 2") - end) }% + end, "_mathsb") }% \_global\_mathsbtrue } \_def \_mathsboff {% - \_directlua{ callback.register_x("process_input_buffer", nil) }% + \_directlua{ callback.remove_from_callback("process_input_buffer", "_mathsb") }% \_global \_mathsbfalse } \_public \mathsboff \mathsbon ; diff --git a/Master/texmf-dist/tex/luatex/optex/base/math-unicode.opm b/Master/texmf-dist/tex/luatex/optex/base/math-unicode.opm index 03222fdad05..88b9cebe110 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/math-unicode.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/math-unicode.opm @@ -81,7 +81,7 @@ \_delimitershortfall=0.5\_fontdimen6\_textfont3 \_nulldelimiterspace=0.12\_fontdimen6\_textfont3 \_scriptspace=0.05\_fontdimen6\_textfont3 - {\_everymath{}\_global\_setbox0=\_hbox{$\_displaystyle{0\_atop0}$}}% correction for \choose + {\_everymath{}\_global\_setbox0=\_hbox{$\_fam1\_displaystyle{0\_atop0}$}}% correction for \choose \_Umathfractiondelsize\_displaystyle = \_dimexpr(\_ht0-\_Umathaxis\_displaystyle)*2\_relax } diff --git a/Master/texmf-dist/tex/luatex/optex/base/optex.ini b/Master/texmf-dist/tex/luatex/optex/base/optex.ini index e9a8babd910..7702883e3d5 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/optex.ini +++ b/Master/texmf-dist/tex/luatex/optex/base/optex.ini @@ -21,7 +21,7 @@ % OpTeX version -\def\optexversion{Beta 0.16 Oct.2020} +\def\optexversion{Beta 0.17 Nov.2020} \def\fmtname{OpTeX} % Engine testing: @@ -86,10 +86,15 @@ \input languages.opm % languages \input others.opm % miscenaleous +\_directlua{ + % preload OpTeX's lua code into format as bytecode + lua.bytecode[1] = assert(loadfile(kpse.find_file("optex", "lua"))) +} + \_everyjob = {% \_message{This is OpTeX (Olsak's Plain TeX), version <\optexversion>^^J}% \_mathchardef\_fnotestack=\_pdfcolorstackinit page {0 g 0 G}% - \_directlua {callback.register_x = callback.register}% ltluatex.lua rewrites it + \_directlua{lua.bytecode[1]()}% load OpTeX's Lua code \_mathsbon % replaces \int_a^b to \int _a^b \_inputref % inputs \jobname.ref if exists } diff --git a/Master/texmf-dist/tex/luatex/optex/base/optex.lua b/Master/texmf-dist/tex/luatex/optex/base/optex.lua new file mode 100644 index 00000000000..8201b8b3061 --- /dev/null +++ b/Master/texmf-dist/tex/luatex/optex/base/optex.lua @@ -0,0 +1,351 @@ +-- This is part of OpTeX project, see http://petr.olsak.net/optex + +-- The basic lua functions and declarations used in \OpTeX/ are here + +-- GENERAL + +-- Error function used by following functions for critical errors. +local function err(message) + error("\nerror: "..message.."\n") +end +-- +-- For a `\chardef`'d, `\countdef`'d, etc., csname return corresponding register +-- number. The responsibility of providing a `\XXdef`'d name is on the caller. +function registernumber(name) + return token.create(name).index +end +-- +-- ALLOCATORS +alloc = alloc or {} +-- +-- An attribute allocator in Lua that cooperates with normal \OpTeX/ allocator. +local attributes = {} +local attribute_max = registernumber("_maiattribute") +function alloc.new_attribute(name) + local cnt = tex.count["_attributealloc"] + 1 + if cnt > attribute_max then + tex.error("No room for a new attribute") + else + tex.setcount("global", "_attributealloc", cnt) + texio.write_nl("log", '"'..name..'"=\\attribute'..tostring(cnt)) + attributes[name] = cnt + return cnt + end +end +-- +-- CALLBACKS +callback = callback or {} +-- +-- Save `callback.register` function for internal use. +local callback_register = callback.register +function callback.register(name, fn) + err("direct registering of callbacks is forbidden, use 'callback.add_to_callback'") +end +-- +-- Table with lists of functions for different callbacks. +local callback_functions = {} +-- Table that maps callback name to a list of descriptions of its added +-- functions. The order corresponds with `callback_functions`. +local callback_description = {} +-- +-- Table used to differentiate user callbacks from standard callbacks. Contains +-- user callbacks as keys. +local user_callbacks = {} +-- Table containing default functions for callbacks, which are called if either +-- a user created callback is defined, but doesn't have added functions or for +-- standard callbacks that are \"extended" (see `mlist_to_hlist` and its pre/post +-- filters below). +local default_functions = {} +-- +-- Table that maps standard (and later user) callback names to their types. +local callback_types = { + -- file discovery + find_read_file = "exclusive", + find_write_file = "exclusive", + find_font_file = "data", + find_output_file = "data", + find_format_file = "data", + find_vf_file = "data", + find_map_file = "data", + find_enc_file = "data", + find_pk_file = "data", + find_data_file = "data", + find_opentype_file = "data", + find_truetype_file = "data", + find_type1_file = "data", + find_image_file = "data", + + open_read_file = "exclusive", + read_font_file = "exclusive", + read_vf_file = "exclusive", + read_map_file = "exclusive", + read_enc_file = "exclusive", + read_pk_file = "exclusive", + read_data_file = "exclusive", + read_truetype_file = "exclusive", + read_type1_file = "exclusive", + read_opentype_file = "exclusive", + + -- data processing + process_input_buffer = "data", + process_output_buffer = "data", + process_jobname = "data", + + -- node list processing + contribute_filter = "simple", + buildpage_filter = "simple", + build_page_insert = "exclusive", + pre_linebreak_filter = "list", + linebreak_filter = "exclusive", + append_to_vlist_filter = "exclusive", + post_linebreak_filter = "reverselist", + hpack_filter = "list", + vpack_filter = "list", + hpack_quality = "list", + vpack_quality = "list", + process_rule = "exclusive", + pre_output_filter = "list", + hyphenate = "simple", + ligaturing = "simple", + kerning = "simple", + insert_local_par = "simple", + mlist_to_hlist = "exclusive", + + -- information reporting + pre_dump = "simple", + start_run = "simple", + stop_run = "simple", + start_page_number = "simple", + stop_page_number = "simple", + show_error_hook = "simple", + show_error_message = "simple", + show_lua_error_hook = "simple", + start_file = "simple", + stop_file = "simple", + call_edit = "simple", + finish_synctex = "simple", + wrapup_run = "simple", + + -- pdf related + finish_pdffile = "data", + finish_pdfpage = "data", + page_order_index = "data", + process_pdf_image_content = "data", + + -- font related + define_font = "exclusive", + glyph_not_found = "exclusive", + glyph_info = "exclusive", + + -- undocumented + glyph_stream_provider = "exclusive", +} +-- +-- Return a list containing descriptions of added callback functions for +-- specific callback. +function callback.callback_descriptions(name) + return callback_description[name] or {} +end + +local valid_callback_types = { + exclusive = true, + simple = true, + data = true, + list = true, + reverselist = true, +} +-- +-- Create a user callback that can only be called manually using +-- `call_callback`. A default function is only needed by "exclusive" callbacks. +function callback.create_callback(name, cbtype, default) + if callback_types[name] then + err("cannot create callback '"..name.."' - it already exists") + elseif not valid_callback_types[cbtype] then + err("cannot create callback '"..name.. "' with invalid callback type '"..cbtype.."'") + elseif ctype == "exclusive" and not default then + err("unable to create exclusive callback '"..name.."', default function is required") + end + + callback_types[name] = cbtype + default_functions[name] = default or nil + user_callbacks[name] = true +end +-- +-- Add a function to the list of functions executed when callback is called. +-- For standard luatex callback a proxy function that calls our machinery is +-- registered as the real callback function. This doesn't happen for user +-- callbacks, that are called manually by user using `call_callback` or for +-- standard callbacks that have default functions -- like `mlist_to_hlist` (see +-- below). +function callback.add_to_callback(name, fn, description) + if user_callbacks[name] or callback_functions[name] or default_functions[name] then + -- either: + -- a) user callback - no need to register anything + -- b) standard callback that has already been registered + -- c) standard callback with default function registered separately + -- (mlist_to_hlist) + elseif callback_types[name] then + -- This is a standard luatex callback with first function being added, + -- register a proxy function as a real callback. Assert, so we know + -- when things break, like when callbacks get redefined by future + -- luatex. + assert(callback_register(name, function(...) + return callback.call_callback(name, ...) + end)) + else + err("cannot add to callback '"..name.."' - no such callback exists") + end + + -- add function to callback list for this callback + callback_functions[name] = callback_functions[name] or {} + table.insert(callback_functions[name], fn) + + -- add description to description list + callback_description[name] = callback_description[name] or {} + table.insert(callback_description[name], description) +end +-- +-- Remove a function from the list of functions executed when callback is +-- called. If last function in the list is removed delete the list entirely. +function callback.remove_from_callback(name, description) + local descriptions = callback_description[name] + local index + for i, desc in ipairs(descriptions) do + if desc == description then + index = i + break + end + end + + table.remove(descriptions, index) + local fn = table.remove(callback_functions[name], index) + + if #descriptions == 0 then + -- Delete the list entirely to allow easy checking of "truthiness". + callback_functions[name] = nil + + if not user_callbacks[name] and not default_functions[name] then + -- this is a standard callback with no added functions and no + -- default function (i.e. not mlist_to_hlist), restore standard + -- behaviour by unregistering. + callback_register(name, nil) + end + end + + return fn, description +end +-- +-- helper iterator generator for iterating over reverselist callback functions +local function reverse_ipairs(t) + local i, n = #t + 1, 1 + return function() + i = i - 1 + if i >= n then + return i, t[i] + end + end +end +-- +-- Call all functions added to callback. This function handles standard +-- callbacks as well as user created callbacks. It can happen that this +-- function is called when no functions were added to callback -- like for user +-- created callbacks or `mlist_to_hlist` (see below), these are handled either +-- by a default function (like for `mlist_to_hlist` and those user created +-- callbacks that set a default function) or by doing nothing for empty +-- function list. +function callback.call_callback(name, ...) + local cbtype = callback_types[name] + -- either take added functions or the default function if there is one + local functions = callback_functions[name] or {default_functions[name]} + + if cbtype == nil then + err("cannot call callback '"..name.."' - no such callback exists") + elseif cbtype == "exclusive" then + -- only one function, atleast default function is guaranteed by + -- create_callback + return functions[1](...) + elseif cbtype == "simple" then + -- call all functions one after another, no passing of data + for _, fn in ipairs(functions) do + fn(...) + end + return + elseif cbtype == "data" then + -- pass data (first argument) from one function to other, while keeping + -- other arguments + local data = (...) + for _, fn in ipairs(functions) do + data = fn(data, select(2, ...)) + end + return data + end + + -- list and reverselist are like data, but "true" keeps data (head node) + -- unchanged and "false" ends the chain immediately + local iter + if cbtype == "list" then + iter = ipairs + elseif cbtype == "reverselist" then + iter = reverse_ipairs + end + + local head = (...) + local new_head + local changed = false + for _, fn in iter(functions) do + new_head = fn(head, select(2, ...)) + if new_head == false then + return false + elseif new_head ~= true then + head = new_head + changed = true + end + end + return not changed or head +end +-- +-- Create \"virtual" callbacks `pre/post_mlist_to_hlist_filter` by setting +-- `mlist_to_hlist` callback. The default behaviour of `mlist_to_hlist` is kept by +-- using a default function, but it can still be overriden by using +-- `add_to_callback`. +default_functions["mlist_to_hlist"] = node.mlist_to_hlist +callback.create_callback("pre_mlist_to_hlist_filter", "list") +callback.create_callback("post_mlist_to_hlist_filter", "reverselist") +callback_register("mlist_to_hlist", function(head, ...) + -- pre_mlist_to_hlist_filter + local new_head = callback.call_callback("pre_mlist_to_hlist_filter", head, ...) + if new_head == false then + node.flush_list(head) + return nil + elseif new_head ~= true then + head = new_head + end + + -- mlist_to_hlist means either added functions or standard luatex behavior + -- of node.mlist_to_hlist (handled by default function) + head = callback.call_callback("mlist_to_hlist", head, ...) + + -- post_mlist_to_hlist_filter + new_head = callback.call_callback("post_mlist_to_hlist_filter", head, ...) + if new_head == false then + node.flush_list(head) + return nil + elseif new_head ~= true then + head = new_head + end + return head +end) +-- +-- Compatibility with \LaTeX/ through luatexbase namespace. Needed for +-- luaotfload. +luatexbase = { + registernumber = registernumber, + attributes = attributes, + new_attribute = alloc.new_attribute, + callback_descriptions = callback.callback_descriptions, + create_callback = callback.create_callback, + add_to_callback = callback.add_to_callback, + remove_from_callback = callback.remove_from_callback, + call_callback = callback.call_callback, + callbacktypes = {} +} diff --git a/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm b/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm index f3ed071be03..8eb851cc2ab 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/prefixed.opm @@ -74,7 +74,7 @@ Now, we define the macros \`\_namespace` `{}`, \`\_resetnamespace` `{}`, \`\_endnamespace`, \`\_nspublic` and \`\_nsprivate` - for package writers, see section~\ref[pkg-namespace]. + for package writers, see section~\ref[pkg-namespace].{\hbadness=2200\par} \_cod ----------------------------- \_def \_pkglabel{} @@ -88,14 +88,14 @@ \_ea \_gdef \_csname namesp:#1\_endcsname {}% \_gdef \_pkglabel{_#1}% \_directlua{ - callback.register_x("process_input_buffer", + callback.add_to_callback("process_input_buffer", function (str) return string.gsub(str, "\_nbb[.]([a-zA-Z])", "\_nbb _#1_\_pcent 1") - end ) + end, "_namespace") }% } \_def\_endnamespace {% - \_ifmathsb \_mathsbon \_else \_mathsboff \_fi + \_directlua{ callback.remove_from_callback("process_input_buffer", "_namespace") }% \_gdef \_pkglabel{}% } @@ -168,7 +168,7 @@ example `\my_control_sequence`, but with the following exceptions: \begitems * Control sequences which begin with `_` are reserved for \TeX/ primitives, - \OpTeX/ internal macros and macro package writers. + \OpTeX/ internal macros and packages internal macros. * Control sequences (terminated by non-letter) in the form `\_` or `\_`, where is a sequence of letters, are inaccessible, because they diff --git a/Master/texmf-dist/tex/luatex/optex/base/unimath-codes.opm b/Master/texmf-dist/tex/luatex/optex/base/unimath-codes.opm index 4718f0dd51d..8b11e4e2927 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/unimath-codes.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/unimath-codes.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \_ncharrmA {Uni math codes <2020-06-13>} % preloaded on demand by \loadmath +\_codedecl \_ncharrmA {Uni math codes <2020-11-13>} % preloaded on demand by \loadmath \_doc ----------------------------- The control sequences for `\alpha`, `\beta` etc are redefined here. @@ -247,6 +247,7 @@ \_let \setminus=\smallsetminus \_let \diamond=\smwhtdiamond +\_let \colon=\mathcolon \_let \bullet=\smblkcircle \_let \circ=\vysmwhtcircle \_let \bigcirc=\mdlgwhtcircle @@ -407,7 +408,8 @@ can define: \_endinput History: -2020-06-13 Umathcode of / declared asi iin Plain TeX +2020-11-13 Bug fix: \colon declared +2020-06-13 Umathcode of / declared as in Plain TeX 2020-06-07 \_itgreek \_itGreek, \_rmgreek \_rmGreek etc. introduced, names changed 2020-06-03 \not\mid = \nmid added, \not corrected 2020-04-30 Bug fix: \phi, \varpi etc. were bad encoded diff --git a/Master/texmf-dist/tex/luatex/optex/base/verbatim.opm b/Master/texmf-dist/tex/luatex/optex/base/verbatim.opm index c74338d2e26..3930579e15c 100644 --- a/Master/texmf-dist/tex/luatex/optex/base/verbatim.opm +++ b/Master/texmf-dist/tex/luatex/optex/base/verbatim.opm @@ -1,6 +1,6 @@ %% This is part of OpTeX project, see http://petr.olsak.net/optex -\_codedecl \begtt {Verbatim <2020-04-22>} % preloaded in format +\_codedecl \begtt {Verbatim <2020-11-13>} % preloaded in format \_doc ---------------------------- The internal parameters @@ -79,7 +79,7 @@ \_ifx\_savedttchar\_undefined\_else \_catcode\_savedttchar=\_savedttcharc \_fi \_chardef\_savedttchar=`#1 \_chardef\_savedttcharc=\_catcode`#1 - \_adef{#1}{\_begingroup \_setverb \_adef{ }{\ }\_ttfont \_the\_everyintt\_relax \_readverb}% + \_adef{#1}{\_begingroup \_setverb \_adef{ }{\_dsp}\_ttfont \_the\_everyintt\_relax \_readverb}% \_def\_readverb ##1#1{\_printinverbatim{##1}\_endgroup}% } \_public \activettchar ; @@ -109,25 +109,20 @@ active characters (defined as {\visiblesp`\ `}). Other characters have normal category 11 or 12. - When `\_prepareverbdata` finishes then `\_startverb` runs \`\_printverb` loop + When `\_prepareverbdata` finishes then `\_startverb` runs `\_printverb` loop over each line of the data and does a final work: last skip plus `\noindent` in the next paragraph. - - The `\_printverb` macro calls \`\_printverbline``{}` to each scanned line of - verbatim text. This macro expect that it strarts in vertical mode and it must - do `\par` in order to return the vertical mode. The \`\_printverblinenum` - is used here: it does nothing when `\_ttline`\code{<0} else it prints the line - number using `\_llap`. - \_cod ---------------------------- + \_cod --------------------------- \_eoldef \begtt#1{\_par \_wipeepar \_setxhsize \_vskip\_parskip \_ttskip \_begingroup \_setverb \_ifnum\_ttline<0 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi - \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt + \_adef{ }{\_dsp}\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% \_the\_everytt \_relax #1\_relax \_ttfont + \_def\_testcommentchars##1\_iftrue{\_iffalse}\_let\_hicomments=\_relax \_endlinechar=`^^J \_startverb } @@ -138,19 +133,45 @@ \_endgroup \_ttskip \_isnextchar\_par{}{\_noindent}% } -\_def\_printverb #1^^J#2{\_ifx\_end#2 - \_bgroup \_adef{ }{}\_def\t{}% - \_ifcat&\_egroup \_else\_egroup \_printverbline{#1}\_fi +\_def\_prepareverbdata#1#2{\_def#1{#2}} + + \_doc + The \`\_printverb` macro calls \^`\_printverbline``{}` repeatedly + to each scanned line of verbatim text. The `\_printverb` is used from + `\begtt...\endtt` and from `\verbinput` too. + + The \^`\_testcommentchars` replaces the following `\_iftrue` to + `\_iffalse` by default unless the \~`\commentchars` are set. So, main body + of the loop is written in `\_else` part of the `\_iftrue` condition. + The \^`\_printverbline``{}` is called here. + + The \`\_printverbline``{}` expects that it starts in vertical mode and it must + do `\par` in order to return the vertical mode. The \`\_printverblinenum` + is used here: it does nothing when `\_ttline`\code{<0} else it prints the line + number using `\_llap`. + \_cod ---------------------------- + +\_def\_printverb #1^^J#2{% + \_ifx\_printverblinenum\_relax \_else \_global\_advance\_ttline by1 \_fi + \_testcommentchars #1\_relax\_relax\_relax + \_iftrue + \_ifx\_end#2 \_printcomments\_fi \_else - \_printverbline{#1}% - \_ea \_printverb \_ea #2% + \_ifx\_vcomments\_empty\_else \_printcomments \_def\_vcomments{}\_fi + \_ifx\_end#2 + \_bgroup \_adef{ }{}\_def\t{}% if the last line is emtpy, we don't print it + \_ifcat&\_egroup \_else\_egroup \_printverbline{#1}\_fi + \_else + \_printverbline{#1}% + \_fi \_fi + \_ifx\_end#2 \_let\_next=\_relax \_else \_def\_next{\_printverb#2}\_fi + \_next } -\_def\_prepareverbdata#1#2{\_def#1{#2}} \_def\_printverbline#1{\_penalty \_ttpenalty \_indent \_printverblinenum \_kern\_ttshift #1\par} \_def\_initverblinenum{\_tenrm \_thefontscale[700]\_ea\_let\_ea\_sevenrm\_the\_font} -\_def\_printverblinenum{\_global\_advance\_ttline by1 \_llap{\_sevenrm \_the\_ttline\_kern.9em}} +\_def\_printverblinenum{\_llap{\_sevenrm \_the\_ttline\_kern.9em}} \_doc ---------------------------- Macro \`\verbinput` uses a file read previously or opens the given file. Then @@ -216,7 +237,7 @@ \_vskip\_parskip \_ttskip \_wipeepar \_setxhsize \_begingroup \_ifnum\_ttline<-1 \_let\_printverblinenum=\_relax \_else \_initverblinenum \_fi - \_setverb \_adef{ }{\ }\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt + \_setverb \_adef{ }{\_dsp}\_adef\^^I{\t}\_parindent=\_ttindent \_parskip=0pt \_def\t{\_hskip \_dimexpr\_tabspaces em/2\_relax}% \_the\_everytt\_relax \_tmpb\_relax \_ttfont \_endlinechar=`^^J \_tmpnum=0 @@ -234,6 +255,7 @@ \_ifeof\_vifile \_tmpnum=\_vidolines\_space \_else \_visaveline \_fi %% save line \_repeat \_ea\_prepareverbdata \_ea \_tmpb\_ea{\_tmpb^^J}% + \_catcode`\ =10 \_catcode`\%=9 % used in \commentchars comments \_ea\_printverb \_tmpb\_end \_global\_ttlinesave \_par @@ -246,13 +268,86 @@ \_public \verbinput ; + \_doc ----------------------------- + If the language of your code\label[commentchars]\wlabel{} + printed by \^`\verbinput` supports the + format of comments started by two characters from beginning of the + line then you can set these characters by \^`\commentchars```. + Such comments are printed in non-verbatim mode without these two + characters and they look like the verbatim printing is interrupred + at the places where such comments are. + See the section~\ref[lua] for good illustration. + The file `optex.lua` is read by single command + `\verbinput (4-) optex.lua` here and the `\commentchars --` was set before it. + + If you need to set a special character by \^`\commentchars` then you must + to set the catcode to 12 (and space to 13). Examples: + \begtt + \commentchars // % C++ comments + \commentchars -- % Lua comments + {\catcode`\%=12 \_ea}\commentchars %% % TeX comments + {\catcode`\#=12 \catcode`\ =13 \_ea}\commentchars#{ } % bash comments + \endtt + + There is one limitation when \TeX/ interprets the comments declared by + \^`\commentchars`. Each block of comments are accummulated to one line + and then it is re-interpreted by \TeX. So, the ends of lines in the + comments block are lost. You cannot use macros which + need to scan end of lines, for example `\begtt...\endtt` inside comments + block does not work. The character `%` is ignored in comments but you can use `\%` + for printing or `%` alone for de-activating `\_endpar` from empty + comment lines. + + Implementation: The \`\commentchars``` redefines the \`\_testcommentchars` + used in \^`\_printverb` in order to it removes the following `\_iftrue` + and returns `\_iftrue` or `\_iffalse` depending on the fact that + the comment characters are or aren't present at the beginning ot tested line. + If it is true (`\ifnum` expands to `\ifnum 10>0`) then the rest of the + line is added to the \`\_vcomments` macro. + + The \`\_hicomments` is `\relax` by default but it is redefined by \^`\commentchars` + in order to keep no-colorized comments if we need to use feature from + \^`\commentchars`. + + The accumulated comments are printed whenever the non-comment line + occurs. This is done by \`\_printcomments` macro. + You can re-define it, but main idea must be kept: it is printed in the + group, `\_reloding \_rm` initializes normal font, `\catcodetable0` + returns to normal catcode table used before `\verbinput` is started, and + the text accumulated in `\_vcomments` must be printed by + `\_scantextokens` primitive. + \_cod ----------------------------- + +\_def\_vcomments{} +\_let\_hicomments=\_relax + +\_def\_commentchars#1#2{% + \_def\_testcommentchars ##1##2##3\_relax ##4\_iftrue{\_ifnum % not closed in this macro + \_ifx #1##1\_ifx#2##21\_fi\_fi 0>0 + \_ifx\_relax##3\_relax \_addto\_vcomments{\_endgraf}% empty comment=\enfgraf + \_else \_addto\_vcomments{##3 }\_fi}% + \_def\_hicomments{\_replfromto{\b\n#1#2}{^^J}{\w{#1#2####1}^^J}}% used in \hisyntax +} +\_def\_testcommentchars #1\_iftrue{\_iffalse} % default value of \_testcommentchar +\_def\_printcomments{\_ttskip + {\_catcodetable0 \_reloading \_rm \_everypar={}% + \_noindent \_ignorespaces \_scantextokens\_ea{\_vcomments}\_par}% + \_ttskip +} +\_public \commentchars ; + \_doc ----------------------------- The \`\visiblesp` sets spaces as visible characters \char9251. - It redefines {\visiblesp`\ `} primitive, so it is useful for verbatim modes only. + It redefines the \^`\_dsp`, so it is useful for verbatim modes only. + + The \`\_dsp` is equivalent to {\visiblesp`\ `} primitive. + It is used in all verbatim environments: spaces are active and defined as + `\_dsp` here. \_cod ----------------------------- -\_def \_visiblesp{\_ifx\_initunifonts\_relax \_def\ {\_char9251 }% - \_else \_def\ {\_char32 }\_fi} +\_def \_visiblesp{\_ifx\_initunifonts\_relax \_def\_dsp{\_char9251 }% + \_else \_def\_dsp{\_char32 }\_fi} +\_let\_dsp=\ % primitive "direct space" \_public \visiblesp ; @@ -261,6 +356,7 @@ \_endinput History: +2020-11-13 ... \commentchars implemented 2020-04-22 ... \ttshift introduced 2020-04-06 ... \visiblesp added 2020-04-04 ... ^^I activated as \t for multiline verbatim diff --git a/Master/texmf-dist/tex/luatex/optex/pkg/qrcode.opm b/Master/texmf-dist/tex/luatex/optex/pkg/qrcode.opm index 59f3dc0334e..5df0ad2c074 100644 --- a/Master/texmf-dist/tex/luatex/optex/pkg/qrcode.opm +++ b/Master/texmf-dist/tex/luatex/optex/pkg/qrcode.opm @@ -2527,7 +2527,7 @@ \_fi }% -\_public \qrcode \qrset ; +\_nspublic \qrcode \qrset ; \_def\.qrcode_int_new{% \.qrbeginhook -- cgit v1.2.3