OSDN Git Service

Fix #44426
authorHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 22 May 2022 05:43:09 +0000 (14:43 +0900)
committerHironori Kitagawa <h_kitagawa2001@yahoo.co.jp>
Sun, 22 May 2022 05:43:09 +0000 (14:43 +0900)
src/patches/lltjp-listings.sty
test/test13-listings.pdf
test/test13-listings.tex

index 173b1ed..c037715 100644 (file)
@@ -1,10 +1,11 @@
 %
-% lltjp-listings.sty 2020-03-23
+% lltjp-listings.sty 2022-05-22
 %
 
 \NeedsTeXFormat{LaTeX2e}
 \RequirePackage{etoolbox,listings,luatexbase-cctb}
 
+\newcount\ltj@lst@japanese@min \ltj@lst@japanese@min=128
 %%%%%%%%%%%%%%%% Japanese support
 %% whether letter-space in a fixed mode box is doubled or not
 \newif\if@ltj@lst@double
       \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}
   \catcode`\}=\ltj@lst@temp%
   \expandafter\expandafter\expandafter\lst@InsideConvert%
   \expandafter{\the\@temptokena}\lst@arg\lst@DeInit\egroup}
-
-%%%%%%%%%%%%%%%% \lstMakeShortInline
-\patchcmd\lstMakeShortInline@{\lst@shortinlinedef#1}{\lst@shortinlinedef~}{}{}
+\def\ltj@lstinline@#1{%
+  \edef\ltj@lst@temp{\the\catcode`#1}
+  \lst@Init\relax\catcode`#1\ltj@lst@temp
+  \ifnum\ltj@lst@temp=\active
+    \begingroup\lccode`\~=`#1\relax
+    \lowercase{\xdef\lst@next{\noexpand\lst@InlineJ\noexpand~}}\endgroup%
+  \else
+    \edef\lst@next{\noexpand\lst@InlineJ\scantextokens{#1}}%
+  \fi\lst@next
+}
 
 % We redefine \lst@BeginDropInput, since now we have
 % two additional `process macros'.
            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
+              if cu >= \the\ltj@lst@japanese@min\space and tex.getcatcode(cu) \string~= 13 then
                 ret = ret .. utfchar(getcount('ltjlineendcomment'))
               end
               ret = ret .. c
 \gdef\ltj@lst@MakeActive@#1{\let\lst@next\relax%
     \ifx#1\relax
     \else\let\lst@next\ltj@lst@MakeActive@
-    \ifnum`#1>127 
+    \ifnum`#1>\numexpr\ltj@lst@japanese@min-1
       \lccode`\^^A=`#1 
       \lowercase{\lst@lAddTo\lst@temp{$^^A}}%$
     \else
index 3d9803a..32eeb86 100644 (file)
Binary files a/test/test13-listings.pdf and b/test/test13-listings.pdf differ
index 62464cc..82197fe 100644 (file)
@@ -1,8 +1,9 @@
 %#!lualatex
 \documentclass{article}
 
-\usepackage{luatexja-fontspec,amsmath}
 \usepackage{listings,color,showexpl,comment}
+\lstMakeShortInline÷
+\usepackage{luatexja-fontspec,amsmath}
 \usepackage{luatexja-otf}\directlua{luatexja.otf.enable_ivs()}
 \usepackage
 [
@@ -33,7 +34,7 @@
        \fi
 }{}
 \DeclareKanjiFamily{JY3}{koz}{}
-\DeclareFontShape{JY3}{koz}{m}{n}{<-> s * [1.2] HaranoAjiMincho-Regular:jfm=ujis}{}
+\DeclareFontShape{JY3}{koz}{m}{n}{<-> s * [1.2] KozMinPr6N-Regular:jfm=ujis}{}
 \DeclareFontShape{JY3}{koz}{m}{sl}{<-> s * [1.2] psft:Ryumin-Light:jfm=ujis;slant=0.167}{}
 \DeclareFontShape{JY3}{koz}{m}{it}{<-> ssub* koz/m/sl}{}
 \def\mcdefault{koz}
@@ -186,13 +187,17 @@ IVS対応2: \texttt{vsraw=true}
 
 foo \lstinline[basicstyle=\tt]!ba{}#shr! baz あ
 
-あ\lstinline[basicstyle=\tt]{bar  s}hoge
+1あ\lstinline[basicstyle=\tt]{bar  s}hoge
+
+2あ\lstinline[basicstyle=\tt]{bar..{a}hoge
 
-あ\lstinline[basicstyle=\tt]{bar..{a}hoge
+foo \lstinline[basicstyle=\tt\gtfamily]!exit 0; #shbar! baz あ
 
-foo \lstinline[basicstyle=\tt\gtfamily]!あexit 0; #shbar! baz あ
+foo \lstinline[basicstyle=\tt\gtfamily]!あreturn 0; #shbar! baz あ
 
-あ\lstinline[basicstyle=\tt]{いbexit #sh$ar}hoge
+3あ\lstinline[basicstyle=\tt]{fexit #sh$ar}hoge
+
+4あ\lstinline[basicstyle=\tt]{いbexit #sh$ar}hoge
 
 \bigskip
 \textbf{Ticket \#35484}
@@ -201,8 +206,8 @@ foo \lstinline[basicstyle=\tt\gtfamily]!あexit 0; #shbar! baz あ
 \colorbox{red}{\lstinline!あいexit 0;#shうえお!}
 
 
-\colorbox{red}{\lstinline{aiu#sheoxyz}}
-\colorbox{red}{\lstinline{あいexit 0;#shうえお}}
+\colorbox{red}{\lstinline{aGiu#sheoxyz}}
+\colorbox{red}{\lstinline{あGいexit 0;#shうえお}}
 
 あおいうえお
 \begin{lstlisting}[frame=single]
@@ -216,29 +221,15 @@ aiu
 1234567890123457890
 aiu# \textcolor{red}{e} #o#\textcolor{red}{ka}#ki
 \end{lstlisting}
+\typeout{AAAA}
 
-
-\newpage
-\lstset{basewidth=0.75\zw,basicstyle=\ttfamily,doubleletterspace,backgroundcolor=}
-\noindent
-\def\A{\leavevmode\smash{\hbox to 0.75\zw{\kern-.0625mm\vrule height 0pt depth 200pt width 0.125mm\hss}}}%
-\textcolor{cyan}{\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A\A}%
-
-\begin{lstlisting}
-a.b.c.d.e.f.g.h.i.j.k.l.m.
-123(あいう@(カンジabc
-a.b.c.d.e.f.g.h.i.j.k.l.m.
-123あいう)@(カンジabc
-a.b.c.d.e.f.g.h.i.j.k.l.m.
-123あい:う@(カンジabc
-\end{lstlisting}
-
-\begin{lstlisting}[columns={[l]flexible}]
-a.b.c.d.e.f.g.h.i.j.k.l.m.
-123(あいう@(カンジabc
-a.b.c.d.e.f.g.h.i.j.k.l.m.
-123あいう)@(カンジabc
-a.b.c.d.e.f.g.h.i.j.k.l.m.
-123あい:う@(カンジabc
-\end{lstlisting}
+\bigskip
+\textbf{Ticket \#44426}\lstset{basicstyle=\itshape}
+Foo ÷fo#shbarあ{#}o÷ Foo
+\colorbox{green}{÷fo#shbarあ{#}o÷}
+
+\lstMakeShortInline あ
+÷いfo#shbarあ{#}}o÷
+あえbazあ
+あbaxあ
 \end{document}