summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/patches
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-12-14 17:21:42 +0000
committerKarl Berry <karl@freefriends.org>2015-12-14 17:21:42 +0000
commit7e7b3ad9875434c71de5f91338327a5c82193d1d (patch)
tree6242dca91601ddad0f0bd98f5e3932ab0aeb8ea2 /Master/texmf-dist/tex/luatex/luatexja/patches
parent7039986c5ad79fac13b8b725dfee4001f7f85332 (diff)
luatexja (12dec15)
git-svn-id: svn://tug.org/texlive/trunk@39105 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luatexja/patches')
-rw-r--r--Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-listings.sty145
1 files changed, 103 insertions, 42 deletions
diff --git a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-listings.sty b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-listings.sty
index dfd97ca054d..40c71c83a7b 100644
--- a/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-listings.sty
+++ b/Master/texmf-dist/tex/luatex/luatexja/patches/lltjp-listings.sty
@@ -3,7 +3,7 @@
%
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjp-listings}[2015/09/10 Patch to listings for LuaTeX-ja]
+\ProvidesPackage{lltjp-listings}[2015/12/11 Patch to listings for LuaTeX-ja]
\RequirePackage{listings,luatexbase-cctb}
%%%%%%%%%%%%%%%% Japanese support
@@ -35,8 +35,8 @@
local cat_lp = luatexbase.catcodetables['latex-package']
local ubyte = unicode.utf8.byte
local spccmd = string.char(0x5C) .. 'ltj@lst@hss@normal'
- luatexja.lst = {}
- function luatexja.lst.althss(t)
+ luatexja.listings = {}
+ function luatexja.listings.althss(t)
t = ubyte(t)
if not (t>=0xE0100 and t<0xE01F0) then
tex.sprint(cat_lp, spccmd)
@@ -44,7 +44,7 @@
end
}
\def\ltj@lst@hss@ivs#1{%
- \directlua{luatexja.lst.althss('\luatexluaescapestring{#1}')}#1%
+ \directlua{luatexja.listings.althss('\luatexluaescapestring{#1}')}#1%
}
\def\ltj@lst@hss@double{\lst@hss\lst@hss}
@@ -179,25 +179,23 @@
\SetCatcodeRange{"FE00}{"FE0F}{13}% Variation Selector
}
-% redefine \lstinline@ and \lst@InlineG
-% because \lstinline!あ...! causes ``Runaway argument?'' Error
-\def\lstinline@#1{%
- \lst@Init\relax
- \ltj@lst@check@inline{\lst@InlineM#1}{\lst@InlineJ#1}}
-\def\lst@InlineG{%
- \lst@Init\relax
- \ltj@lst@check@inline{\lst@InlineM\}}%
- {\let\lst@arg\@empty \lst@InlineGJ}}
-
-\def\ltj@lst@check@inline#1#2#3{%
- \begingroup \lccode`\~=`#3\lowercase{\endgroup
- \ifx~}#3%
- \def\lst@next{#1}%
- \else\ifnum`#3>127\relax
- \def\lst@next{#1}%
- \else
- \def\lst@next{#2}%
- \fi\fi\lst@next #3}
+% redefine \lstinline and its inner commands to support Japanese characters
+\renewcommand\lstinline[1][]{%
+ \leavevmode\bgroup % \hbox\bgroup --> \bgroup
+ \def\lst@boxpos{b}%
+ \lsthk@PreSet\lstset{flexiblecolumns,#1}%
+ \lsthk@TextStyle
+ \@ifnextchar\bgroup \ltj@lst@InlineG \ltj@lstinline@}
+\def\ltj@lstinline@#1{%
+ \edef\ltj@lst@temp{\the\catcode`#1}\lst@Init\relax\catcode`#1\ltj@lst@temp
+ \lst@InlineJ#1}
+\def\ltj@lst@InlineG{%
+ \lst@Init\relax\edef\ltj@lst@temp{\the\catcode`\}}\catcode`\}=2 \catcode`\ =12\relax
+ \let\lst@arg\@empty\afterassignment\ltj@lst@InlineG@@\@temptokena}
+\def\ltj@lst@InlineG@@{%
+ \catcode`\}=\ltj@lst@temp%
+ \expandafter\expandafter\expandafter\lst@InsideConvert%
+ \expandafter{\the\@temptokena}\lst@arg\lst@DeInit\egroup}
% We redefine \lst@BeginDropInput, since now we have
% two additional `process macros'.
@@ -216,24 +214,38 @@
\let\ltj@lst@ProcessJALetterHalf\@gobble % added
}}
+\directlua{
+ luatexja.listings.insert_cb = function()
+ if not luatexja.listings.patched then
+ luatexja.listings.patched = 1
+ luatexbase.add_to_callback('process_input_buffer',
+ function(buf)
+ local ret = ''
+ for i = 1, utf.len(buf) do
+ local c = utf.sub(buf, i, i)
+ local cu = utf.byte(c)
+ if cu >= 0x80 and tex.getcatcode(cu) \string~= 13 then
+ ret = ret .. utf.char(1048575) % U+FFFFF
+ end
+ ret = ret .. c
+ end
+ return ret
+ end, 'ltj.listings_unicode', 1)
+ end
+ end
+ luatexja.listings.remove_cb = function()
+ if luatexja.listings.patched then
+ luatexja.listings.patched = nil
+ luatexbase.remove_from_callback('process_input_buffer',
+ 'ltj.listings_unicode')%
+ end
+ end}
% hook!
\lst@AddToHook{Init}{%
\luatexcatcodetable\CatcodeTableLTJlistings\ltj@@listing@jpcmd
\lccode`\~="FFFFF\lowercase{\def~{\ltj@lst@ProcessJALetter}}%"
- \directlua{luatexbase.add_to_callback('process_input_buffer',
- function(buf)
- local ret = ''
- for i = 1, utf.len(buf) do
- local c = utf.sub(buf, i, i)
- local cu = utf.byte(c)
- if cu >= 0x80 and tex.getcatcode(cu) \string~= 13 then
- ret = ret .. utf.char(1048575) % U+FFFFF
- end
- ret = ret .. c
- end
- return ret
- end, 'ltj.listings_unicode', 1)}%
+ \directlua{luatexja.listings.insert_cb()}%
\if@ltj@lst@double
\let\ltj@lst@hss@normal=\ltj@lst@hss@double
\else
@@ -245,12 +257,42 @@
\let\ltj@lst@hss=\ltj@lst@hss@normal
\fi
}
+
+\def\ltj@lst@MakeActive#1{%
+ \let\lst@temp\@empty \ltj@lst@MakeActive@#1\relax}
+\begingroup
+\catcode`\^^A=12
+\catcode`\^^@=\active
+\lccode`\$="FFFFF \catcode`\$=13 %"
+\lowercase{%
+\gdef\ltj@lst@MakeActive@#1{\let\lst@next\relax%
+ \ifx#1\relax
+ \else\let\lst@next\ltj@lst@MakeActive@
+ \ifnum`#1>127
+ \lccode`\^^A=`#1
+ \lowercase{\lst@lAddTo\lst@temp{$^^A}}%
+ \else
+ \lccode`\^^@=`#1
+ \lowercase{\lst@lAddTo\lst@temp{^^@}}%
+ \fi\fi\lst@next}}
+\endgroup
+
+
+\begingroup \lccode`\~=`\ \relax \lowercase{%
+\gdef\lst@InsideConvert@#1 #2{%
+ \ltj@lst@MakeActive{#1}%
+ \ifx\@empty#2%
+ \lst@lExtend\lst@arg{\lst@temp}%
+ \else
+ \lst@lExtend\lst@arg{\lst@temp~}%
+ \expandafter\lst@InsideConvert@
+ \fi #2}
+}\endgroup
+
\lst@AddToHook{ExitVars}{%
- \directlua{luatexbase.remove_from_callback('process_input_buffer',
- 'ltj.listings_unicode')}%
+ \directlua{luatexja.listings.remove_cb()}%
}
-
% 白線対策
\newif\ifltj@lst@frame@top
\newdimen\ltj@lst@frame@lslimit
@@ -302,7 +344,7 @@
%%%%%%%%%%%%%%%% escape to \LaTeX
\lstloadaspects{escape}
-\gdef\lst@Escape#1#2#3#4{%
+\gdef\lst@Escape#1#2#3#4{
\lst@CArgX #1\relax\lst@CDefX
{}%
{\lst@ifdropinput\else
@@ -320,10 +362,29 @@
{\lst@escapeend #4\lst@LeaveAllModes\lst@ReenterModes
\lst@newlines\z@ \lst@whitespacefalse}%
{}%
- \fi
- #3\catcode"FFFFF=9\lst@escapebegin%"
+ \fi%
+ \ltj@lst@escape@setup#2%
+ #3\catcode"FFFFF=9\lst@escapebegin\expandafter\lst@next%"
\fi}%
{}}
+\def\ltj@lst@escape@setup#1{%
+ \begingroup\lccode`\~=`#1\lowercase{%
+ \gdef\lst@next##1~{%
+ \let\lst@arg\@empty\ltj@lst@remove@jacmd{##1}%
+ \expandafter\expandafter\expandafter\scantokens\expandafter{\lst@arg}%
+ ~}%
+ }\endgroup
+}
+\begingroup
+ \lccode`\|="FFFFF \lowercase{%"
+ \gdef\ltj@lst@remove@jacmd#1{%
+ \expandafter\ltj@lst@remove@jacmd@\detokenize{#1}|\@nil|}
+ \gdef\ltj@lst@remove@jacmd@#1|{%
+ \ifx#1\@nil\else
+ \lst@lAddTo\lst@arg{#1}%
+ \expandafter\ltj@lst@remove@jacmd@
+ \fi}}
+\endgroup
%%%%%%%%%%%%%%%%
\lstloadaspects{writefile}