<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%
% ltj-base.sty
%

%! ã“ã‚Œã¯å¤–ã‹ã‚‰èª­ã¾ã‚Œãªã„
%% Avoid multiple loading.
\csname luatexjabaseLoaded\endcsname
\edef\ltj@base@AtEnd{%
\endlinechar=\the\endlinechar
\relax}
\endlinechar=-1 %
\def\luatexjabaseLoaded{\endinput}

\ifltj@in@latex                 %&lt;*LaTeX&gt;
  \NeedsTeXFormat{LaTeX2e}
  \ProvidesPackage{ltj-base}[2021-03-16]
\fi                             %&lt;/LaTeX&gt;

%%------------------ Tiny helpers

%% Registers
%\newcount\ltj@tempcnta % defined at luatexja-core.sty
%\newcount\ltj@tempdima % defined at luatexja-core.sty
\newcount\ltj@tempcntb
\newcount\ltj@tempcntc
% \newskip\ltj@tempskipa unused
% \newtoks\ltj@temptoks unused

\countdef\ltj@@count@zero=0 %
\luatexattributedef\ltj@@attr@zero=0 %
\dimendef\ltj@@dimen@zero=0 %
\skipdef\ltj@@skip@zero=0 %

%% Quarks
%! ãŸã&nbsp; expl3 ã® quark ã¨ã¯ç•°ãªã‚Šå±•é–‹ã•ã‚Œã‚‹ã¨ã‚¨ãƒ©ãƒ¼ã«ãªã‚‹.
%% \ltj@q@stop
\protected\def\ltj@q@stop{\ltj@q@stop@}
%% \ltj@q@nil
\protected\def\ltj@q@nil{\ltj@q@nil@}
%% \ltj@q@mark
\protected\def\ltj@q@mark{\ltj@q@mark@}

%! etoolbox ã® \csletcs.
%% \ltj@csletcs
\protected\def\ltj@csletcs#1#2{
  \expandafter\let\csname#1\expandafter\endcsname
  \csname#2\endcsname
}

%% \ltj@ifx{&lt;sutff&gt;}{&lt;yes&gt;}{&lt;no&gt;}
%! LaTeX å½¢å¼ã® \ifx. ã“ã®å½¢å¼ã®åˆ©ç‚¹ã¯è‡ªå‹•çš„ã«æ¡ä»¶ãƒã‚¹ãƒˆã‹ã‚‰ã®
%! è„±å‡ºãŒå¯èƒ½ã§ã‚ã‚‹ã“ã¨.
% Does \ifx&lt;stuff&gt; test in LaTeX style.
\long\def\ltj@ifx#1{
  \ifx#1\expandafter\ltx@firstoftwo
  \else\expandafter\ltx@secondoftwo\fi
}

\protected\def\ltj@@q@empty{\ltj@@q@empty@}

%% \ltj@if@blank{&lt;stuff&gt;}{&lt;yes&gt;}{&lt;no&gt;}
%! &lt;stuff&gt; ãŒç©ºã¾ãŸã¯ç©ºç™½æ–‡å­—ã‹ã‚‰ãªã‚‹ã‹.
% Checks if &lt;stuff&gt; is either empty or consisting only of spaces.
\def\ltj@if@blank#1{
  \ltj@@if@blankA#1\ltj@@q@empty\ltj@@q@empty
   \ltx@secondoftwo\ltx@firstoftwo\ltj@q@nil
}
\long\def\ltj@@if@blankA#1#2\ltj@@q@empty#3#4#5\ltj@q@nil{
  #4
}

%%------------------ LaTeX vs plain
\ifltj@in@latex            %&lt;*LaTeX&gt;

%% \ifltj@in@latex
%! LaTeX ã§ã‚ã‚‹ã‹.
%(Defined in luatexja-core.sty.)

%% \ifltj@in@plain
%! plain ã§ã‚ã‚‹ã‹.
\ltj@csletcs{ifltj@in@plain}{iffalse}

\else                           %&lt;*!LaTeX&gt;

%% \ifltj@in@plain
\ifnum\pdf@strcmp{\fmtname}{plain}=0 %
  \ltj@csletcs{ifltj@in@plain}{iftrue}
\else
  \ltj@csletcs{ifltj@in@plain}{iffalse}
\fi

\fi                             %&lt;/LaTeX&gt;
%%------------------ Value-token handling

%% helper stuffs

%% \ltj@gobble@num &lt;number&gt;
%! æ¬¡ã«ç¶šãæ•´æ•°ã‚’(2 å›žå±•é–‹ã§)èª­ã¿æ¨ã¦ã‚‹. 
\def\ltj@gobble@num{
  \directlua{token.scan_int()}
}

%% \ltj@gobble@glue &lt;glue&gt;
%! æ¬¡ã«ç¶šãã‚°ãƒ«ãƒ¼å€¤ã‚’(2 å›žå±•é–‹ã§)èª­ã¿æ¨ã¦ã‚‹. 
\def\ltj@gobble@glue{
  \directlua{node.free(token.scan_glue())}
}

%% \ltj@gobble@dimen &lt;dimen&gt;
%! æ¬¡ã«ç¶šãå¯¸æ³•å€¤ã‚’(2 å›žå±•é–‹ã§)èª­ã¿æ¨ã¦ã‚‹. 
\def\ltj@gobble@dimen{
  \directlua{token.scan_dimen()}
}

%% \ltj@grab@num &lt;number&gt;
%! æ¬¡ã«ç¶šãæ•´æ•°ã‚’èª­ã¿å–ã£ã¦, ãã‚Œã¨ç­‰ã—ã„æ•´æ•°ã‚’è¡¨ã™ãƒˆãƒ¼ã‚¯ãƒ³åˆ—
%! (å¿…ãšã—ã‚‚æ•´æ•°è¡¨è¨˜ã¨ã¯é™ã‚‰ãªã„)ã‚’ { } ã«å…¥ã‚ŒãŸã‚‚ã®ã«(2 å›žã§)
%! å±•é–‹ã™ã‚‹.
%! ãŸã&nbsp;ã—, æ•´æ•°ã¯ä»¥ä¸‹ã®å½¢å¼ã®ã„ãšã‚Œã‹ã§ãªã‘ã‚Œã°ãªã‚‰ãªã„.
%! - æ•´æ•°è¡¨è¨˜(10 é€², 8 é€², 16 é€², æ–‡å­—)
%! - chardef ãƒˆãƒ¼ã‚¯ãƒ³
%! - å†…éƒ¨æ•´æ•°ãƒ‘ãƒ©ãƒ¡ã‚¿, countdef ãƒˆãƒ¼ã‚¯ãƒ³
%!   (command_name ãŒ "assign_int" ã§ã‚ã‚‹ãƒˆãƒ¼ã‚¯ãƒ³).
%! (æ³¨æ„: ã¾ã&nbsp;æ–‡å­—è¡¨è¨˜(`A)ã«å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“.)
\def\ltj@grab@num{
  \directlua{tex.sprint(luatexbase.catcodetables['latex-package'], '{' .. token.scan_int() .. '}')}
}

%%------------------ Safe passing

% These macros convert a token sequence denoting a TeX value to its
% suitable notation in Lua, and when the argument is malformed then
% 'nil' is returned. They are all fully-expandable.
%! TeX ã®å€¤ã‚’ Lua ä¸Šã®è¡¨è¨˜ã«å¤‰æ›ã™ã‚‹. ä¸æ­£å½¢å¼ã&nbsp;ã¨ nil ã«ã™ã‚‹.

\def\ltj@@safe@end{\noexpand\ltj@@safe@end}
  % behaves same as \relax but is distinct from it

%% \ltj@safe@invalid
% The value passed to lua instead of malformed value tokens.
\def\ltj@safe@invalid{(nil)}

%% \ltj@safe@num{&lt;number&gt;}
%! æ•´æ•°.
% For a number (integer).
\def\ltj@safe@num{
  \ltj@safe@num@or\ltj@safe@invalid
}
\def\ltj@safe@num@or#1#2{
  \expandafter\expandafter\expandafter\ltj@@safe@numA
   \ltj@gobble@num#2\ltj@@safe@end{#2}{#1}
}
\def\ltj@@safe@numA#1\ltj@@safe@end#2#3{
  \ltj@if@blank{#1}{
    (\number#2)
  }{
    #3
  }
}

%% \ltj@safe@dimen{&lt;dimen&gt;}
%! å¯¸æ³•å€¤.
% For a dimension. The result is a scaled-point value.
\def\ltj@safe@dimen{
  \ltj@safe@dimen@or\ltj@safe@invalid
}
\def\ltj@safe@dimen@or#1#2{
  \expandafter\expandafter\expandafter\ltj@@safe@dimenA
   \ltj@gobble@dimen#2\ltj@@safe@end{#2}{#1}
}
\def\ltj@@safe@dimenA#1\ltj@@safe@end#2#3{
  \ltj@if@blank{#1}{
    (\number\dimexpr#2\relax)
  }{
    #3
  }
}

%! æ•´å½¢å¼ã®æ•´æ•° â†’ æ•°å€¤ : \number#1
%! å†…éƒ¨å¯¸æ³• â†’ æ•°å€¤ : \number#1
%! æ•´å½¢å¼ã®å¯¸æ³• â†’ æ•°å€¤ : \number\dimexpr#1\relax

%% \ltj@safe@str{&lt;text&gt;}
%! æ–‡å­—åˆ—. (ãƒˆãƒ¼ã‚¯ãƒ³åˆ—ã‚’éžãƒˆãƒ¼ã‚¯ãƒ³åŒ–)
% Converts a token sequence to Lua string notation.
\def\ltj@safe@str#1{
  "\luatexluaescapestring{\detokenize{#1}}"
}

%%------------------ debug logging
\ifdefined\LuaTeXjaDebugEnabled

%% Load Lua module
\RequireLuaModule{luatexja.debug}

%% \ltj@debug{&lt;format&gt;}{&lt;arg&gt;,...}
\def\ltj@debug#1#2{
  \directlua{
    luatexja.base.debug(\ltj@safe@str{#1}
      \ltj@if@blank{#2}{}{, }
      #2)
  }
}

%% \ltj@package@debug{&lt;package&gt;}{&lt;format&gt;}{&lt;arg&gt;,...}
\def\ltj@package@debug#1#2#3{
  \directlua{
    luatexja.base.package_debug(\ltj@safe@str{#1},
      \ltj@safe@str{#2}
      \ltj@if@blank{#3}{}{, }
      #3)
  }
}

\else

\def\ltj@debug#1#2{}
\def\ltj@package@debug#1#2#3{}

\fi

%% \ltj@debug@logger\CS{&lt;package&gt;}
\def\ltj@debug@logger#1#2{
  \def#1{\ltj@package@debug{#2}}
}

%% \ltj@afterbox &lt;token&gt;&lt;box&gt;
%% -&gt; \setbox\ltj@afbox&lt;box&gt;&lt;token&gt;
%% idea from the atbegshi package
\newbox\ltj@afbox
\directlua{luatexja.afbox_number=\the\ltj@afbox}
\protected\def\ltj@afterbox#1{%
  \def\ltj@afbox@@arg{#1}\edef\ltj@afbox@@grouplevel{\number\currentgrouplevel}%
  \afterassignment\ltj@afbox@@\setbox\ltj@afbox}
\def\ltj@afbox@@{%
  \ifnum\ltj@afbox@@grouplevel&lt;\currentgrouplevel\expandafter\aftergroup\fi\ltj@afbox@@arg
}


%%------------------ all done
\ltj@base@AtEnd
\endinput
%% EOF
</pre></body></html>