OSDN Git Service

lltjp-listings.sty: better support for \lstinline
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 5 Nov 2015 13:16:12 +0000 (22:16 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Thu, 5 Nov 2015 13:16:12 +0000 (22:16 +0900)
src/patches/lltjp-listings.sty
test/test13-listings.pdf
test/test13-listings.tex

index 5f20a25..20e6731 100644 (file)
@@ -3,7 +3,7 @@
 %
 
 \NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{lltjp-listings}[2015/09/10 Patch to listings for LuaTeX-ja]
+\ProvidesPackage{lltjp-listings}[2015/11/05 Patch to listings for LuaTeX-ja]
 \RequirePackage{listings,luatexbase-cctb}
 
 %%%%%%%%%%%%%%%% Japanese support
   \SetCatcodeRange{"FE00}{"FE0F}{13}%     Variation Selector
 }
 
-% redefine \lstinline@ and \lst@InlineG
-% because \lstinline!あ...! causes ``Runaway argument?'' Error
-\def\lstinline@#1{%
-    \lst@Init\relax\typeout{N}%
-    \ltj@lst@check@inline{\lst@InlineM#1}{\lst@InlineJ#1}}
-\def\lst@InlineG{%
-    \lst@Init\relax\typeout{G}\tracingall%
-    \ltj@lst@check@inline{\lst@InlineM\}}%
-                         {\let\lst@arg\@empty \lst@InlineGJ}}
-
-\def\ltj@lst@check@inline#1#2#3{%
-    \typeout{<\meaning#3, \meaning#1>}
-    \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'.
index 74604fd..66833b4 100644 (file)
Binary files a/test/test13-listings.pdf and b/test/test13-listings.pdf differ
index 4e2c8c2..0274061 100644 (file)
@@ -62,6 +62,7 @@ We also avoid white band problem, by setting the value of \cs{lineskiplimit} to
  -\min(\cs{cdp}-\cs{dp}\cs{strutbox}, 0).
 \end{multline}
 
+Note: we still have a white band if the first line is line-broken.
 
 \begin{env}{\relax}
 #!/bin/sh
@@ -183,14 +184,29 @@ IVS対応2: \texttt{vsraw=true}
 \textbf{Ticket \#34786}
 \ltjsetparameter{autoxspacing=false}
 
-foo \lstinline[basicstyle=\tt]!bar! baz あ
-あ\lstinline[basicstyle=\tt]{bar}hoge
+foo \lstinline[basicstyle=\tt]!ba{}#shr! baz あ
 
-foo \lstinline[basicstyle=\tt]!あbar! baz あ
-あ\lstinline[basicstyle=\tt]{いbar}hoge
+あ\lstinline[basicstyle=\tt]{bar  s}hoge
+
+あ\lstinline[basicstyle=\tt]{bar..{a}hoge
+
+foo \lstinline[basicstyle=\tt\gtfamily]!あexit 0; #shbar! baz あ
+
+あ\lstinline[basicstyle=\tt]{いbexit #sh$ar}hoge
 
 \bigskip
 \textbf{Ticket \#35484}
 
-\colorbox{red}{\lstinline!aiueoxyz!}
+\colorbox{red}{\lstinline!aiu#sheoxyz!}
+\colorbox{red}{\lstinline!あいexit 0;#shうえお!}
+
+
+\colorbox{red}{\lstinline{aiu#sheoxyz}}
+\colorbox{red}{\lstinline{あいexit 0;#shうえお}}
+
+あおいうえお
+\begin{lstlisting}[frame=single]
+aiu
+\end{lstlisting}
+あいうえお
 \end{document}