summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/pitex/lua.ptx
blob: b41c5af338e7031ca8a23296131538a10c7acda8 (plain)
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
\def\inputluafile#1 {\directlua{dofile(kpse.find_file("#1"))}}

\inputluafile base.ptxlua

\def\ptx@lua{\directlua name {Internal PiTeX chunk}}

\newcatcodetable\luacatcodes{\#\%\^^M\~=12}
\newtoks\ptx@luacode_list
\newif\ifptx@luacode_store
% Mimicks a block (\newblock isn't defined yet
% and anyway it wouldn't be very useful).
\def\luacode{%
  \begingroup
  \catcodetable\luacatcodes
  \ifnext[
    {\ptx@luacode_store}
    {\ptx@luacode_store[]}}
\bgroup
\setcatcodes{\^^M=12}%
\long\gdef\ptx@luacode_store[#1]^^M#2\luacode/{% So line count is right.
  \endgroup%
  \ifemptystring{#1}%
    {\ptx@lua{#2}}%
    {\def#1{#2}}%
  }%
\egroup