summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib/luamplib.sty')
-rw-r--r--Master/texmf-dist/tex/luatex/luamplib/luamplib.sty56
1 files changed, 33 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
index 89d55e9a8e1..548bf58dda4 100644
--- a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
+++ b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty
@@ -14,7 +14,7 @@
\else
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{luamplib}
- [2013/12/29 v2.2 mplib package for LuaTeX]
+ [2014/01/20 v2.3 mplib package for LuaTeX]
\RequirePackage{luatexbase-modutils}
\RequirePackage{pdftexcmds}
\fi
@@ -35,7 +35,8 @@
\fi
\fi
\def\mplibsetupcatcodes{%
- \catcode`\{=12 \catcode`\}=12 \catcode`\#=12
+ %catcode`\{=12 %catcode`\}=12
+ \catcode`\#=12
\catcode`\^=12 \catcode`\~=12 \catcode`\_=12
%catcode`\%=12 %% don^^e2^^80^^99t in Plain!
\catcode`\&=12 \catcode`\$=12
@@ -51,39 +52,48 @@
}
\long\def\mplibdocode#1\endmplibcode{%
\egroup
- \directlua{
- luamplib.tempdata = luamplib.makeTEXboxes([===[\unexpanded{#1}]===])
- }%
- \directlua{
- luamplib.processwithTEXboxes(luamplib.tempdata)
- }%
+ \expandafter\def\expandafter\mplibtmp\expandafter
+ {\directlua{luamplib.protecttextext([===[\unexpanded{#1}]===])}}%
+ \directlua{luamplib.tempdata = luamplib.makeTEXboxes([===[\mplibtmp]===])}%
+ \directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}%
\endgroup
}
\else
\newenvironment{mplibcode}{\toks@{}\ltxdomplibcode}{}
\def\ltxdomplibcode{%
- \bgroup
+ \begingroup
\mplibsetupcatcodes
\ltxdomplibcodeindeed %
}
-\long\def\ltxdomplibcodeindeed#1\end{%
- \egroup
- \toks@\expandafter{\the\toks@#1}\ltxdomplibcodefinally%
-}%
-\def\ltxdomplibcodefinally#1{%
- \ifnum\pdf@strcmp{#1}{mplibcode}=\z@
- \directlua{
- luamplib.tempdata = luamplib.makeTEXboxes([===[\the\toks@]===])
- }%
- \directlua{
- luamplib.processwithTEXboxes(luamplib.tempdata)
- }%
+\long\def\ltxdomplibcodeindeed#1\end#2{%
+ \endgroup
+ \toks@\expandafter{\the\toks@#1}%
+ \ifnum\pdf@strcmp{#2}{mplibcode}=\z@
+ \expandafter\def\expandafter\reserved@a\expandafter
+ {\directlua{luamplib.protecttextext([===[\the\toks@]===])}}%
+ \directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\reserved@a]===])}%
+ \directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}%
\end{mplibcode}%
\else
- \toks@\expandafter{\the\toks@\end{#1}}\expandafter\ltxdomplibcode
- \fi%
+ \toks@\expandafter{\the\toks@\end{#2}}\expandafter\ltxdomplibcode
+ \fi
}
\fi
+\newtoks\everymplibtoks
+\newtoks\everyendmplibtoks
+\protected\def\everymplib{%
+ \begingroup
+ \mplibsetupcatcodes
+ \expandafter\endgroup
+ \everymplibtoks
+}
+\protected\def\everyendmplib{%
+ \begingroup
+ \mplibsetupcatcodes
+ \expandafter\endgroup
+ \everyendmplibtoks
+}
+\def\mpdim#1{ begingroup \the\dimexpr #1\relax\space endgroup } % gmp.sty
\ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi
\def\mplibstarttoPDF#1#2#3#4{%
\hbox\bgroup