diff options
author | Karl Berry <karl@freefriends.org> | 2014-03-06 23:02:07 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-03-06 23:02:07 +0000 |
commit | 2cae2bb164327cd36f426861958b9e76dbdfb80d (patch) | |
tree | 1095ab4ae2e813797ab3e02408060579b1f0ca32 /Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | |
parent | eac3699c6b426ce060acf916c17d2b25f06f8818 (diff) |
luamplib (2mar14)
git-svn-id: svn://tug.org/texlive/trunk@33111 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luamplib/luamplib.sty')
-rw-r--r-- | Master/texmf-dist/tex/luatex/luamplib/luamplib.sty | 75 |
1 files changed, 63 insertions, 12 deletions
diff --git a/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty b/Master/texmf-dist/tex/luatex/luamplib/luamplib.sty index efa971be27f..be85a430f32 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} - [2014/02/19 v2.5.1 mplib package for LuaTeX] + [2014/03/01 v2.5.3 mplib package for LuaTeX] \RequirePackage{luatexbase-modutils} \RequirePackage{pdftexcmds} \fi @@ -36,33 +36,49 @@ \fi \def\mplibsetupcatcodes{% %catcode`\{=12 %catcode`\}=12 - \catcode`\#=12 - \catcode`\^=12 \catcode`\~=12 \catcode`\_=12 - %catcode`\%=12 %% don’t in Plain! - \catcode`\&=12 \catcode`\$=12 + \catcode`\#=12 \catcode`\^=12 \catcode`\~=12 \catcode`\_=12 + \catcode`\&=12 \catcode`\$=12 \catcode`\%=12 \catcode`\^^M=12 \endlinechar=10 } \def\mplibputtextbox#1{\vbox to 0pt{\vss\hbox to 0pt{\raise\dp#1\copy#1\hss}}} +\newcount\mplibstartlineno +\def\mplibpostmpcatcodes{% + \catcode`\{=12 \catcode`\}=12 \catcode`\#=12 \catcode`\%=12 } +\def\mplibreplacenewlinebr{% + \begingroup \mplibpostmpcatcodes \mplibdoreplacenewlinebr} +\begingroup\lccode`\~=`\^^M \lowercase{% + \gdef\mplibdoreplacenewlinebr#1^^J{\endgroup\luatexscantextokens{{}#1~}}} +\endgroup \bgroup\expandafter\expandafter\expandafter\egroup \expandafter\ifx\csname ProvidesPackage\endcsname\relax +\def\mplibreplacenewlinecs{% + \begingroup \mplibpostmpcatcodes \mplibdoreplacenewlinecs} +\begingroup\lccode`\~=`\^^M \lowercase{% + \gdef\mplibdoreplacenewlinecs#1^^J{\endgroup\luatexscantextokens{\relax#1~}}} +\endgroup \def\mplibcode{% + \mplibstartlineno\inputlineno + \begingroup \begingroup - \bgroup \mplibsetupcatcodes - \mplibdocode % + \mplibdocode } \long\def\mplibdocode#1\endmplibcode{% - \egroup + \endgroup \def\mplibtemp{\directlua{luamplib.protecttextext([===[\unexpanded{#1}]===])}}% \directlua{luamplib.tempdata = luamplib.makeTEXboxes([===[\mplibtemp]===])}% \directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}% \endgroup + \ifnum\mplibstartlineno<\inputlineno\expandafter\mplibreplacenewlinecs\fi } \else -\newenvironment{mplibcode}{\toks@{}\ltxdomplibcode}{} +\newenvironment{mplibcode}{% + \global\mplibstartlineno\inputlineno + \toks@{}\ltxdomplibcode +}{} \def\ltxdomplibcode{% \begingroup \mplibsetupcatcodes - \ltxdomplibcodeindeed % + \ltxdomplibcodeindeed } \long\def\ltxdomplibcodeindeed#1\end#2{% \endgroup @@ -72,6 +88,9 @@ \directlua{luamplib.tempdata=luamplib.makeTEXboxes([===[\reserved@a]===])}% \directlua{luamplib.processwithTEXboxes(luamplib.tempdata)}% \end{mplibcode}% + \ifnum\mplibstartlineno<\inputlineno + \expandafter\expandafter\expandafter\mplibreplacenewlinebr + \fi \else \toks@\expandafter{\the\toks@\end{#2}}\expandafter\ltxdomplibcode \fi @@ -80,25 +99,52 @@ \newtoks\everymplibtoks \newtoks\everyendmplibtoks \protected\def\everymplib{% + \mplibstartlineno\inputlineno \begingroup \mplibsetupcatcodes \mplibdoeverymplib } -\def\mplibdoeverymplib#1{% +\long\def\mplibdoeverymplib#1{% \endgroup \everymplibtoks{#1}% + \ifnum\mplibstartlineno<\inputlineno\expandafter\mplibreplacenewlinebr\fi } \protected\def\everyendmplib{% + \mplibstartlineno\inputlineno \begingroup \mplibsetupcatcodes \mplibdoeveryendmplib } -\def\mplibdoeveryendmplib#1{% +\long\def\mplibdoeveryendmplib#1{% \endgroup \everyendmplibtoks{#1}% + \ifnum\mplibstartlineno<\inputlineno\expandafter\mplibreplacenewlinebr\fi } \def\mpdim#1{ begingroup \the\dimexpr #1\relax\space endgroup } % gmp.sty \def\mplibnumbersystem#1{\directlua{luamplib.numbersystem = "#1"}} +\def\mplibmakenocache#1{\mplibdomakenocache #1,*,} +\def\mplibdomakenocache#1,{% + \ifx\empty#1\empty + \expandafter\mplibdomakenocache + \else + \ifx*#1\else + \directlua{luamplib.noneedtoreplace["#1.mp"]=true}% + \expandafter\expandafter\expandafter\mplibdomakenocache + \fi + \fi +} +\def\mplibcancelnocache#1{\mplibdocancelnocache #1,*,} +\def\mplibdocancelnocache#1,{% + \ifx\empty#1\empty + \expandafter\mplibdocancelnocache + \else + \ifx*#1\else + \directlua{luamplib.noneedtoreplace["#1.mp"]=false}% + \expandafter\expandafter\expandafter\mplibdocancelnocache + \fi + \fi +} +\def\mplibcachedir#1{\directlua{luamplib.getcachedir("\unexpanded{#1}")}} \ifx\mplibscratchbox\undefined \newbox\mplibscratchbox \fi \def\mplibstarttoPDF#1#2#3#4{% \hbox\bgroup @@ -147,6 +193,11 @@ \box\mplibscratchbox \endgroup } +\openin0=luamplib.cfg +\ifeof0 \else + \closein0 + \input luamplib.cfg +\fi \endinput %% %% End of file `luamplib.sty'. |