summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luatexja/addons/luatexja-adjust.sty
blob: a9262106618075b3e410091b176d95e9bff94a82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
%
% luatexja-adjust.sty
%

%% Avoid multiple loading.
\csname\if11luatexjaadjustLoaded\fi\endcsname
\edef\x{%
\catcode32=\the\catcode32%
\catcode33=\the\catcode33%
\catcode35=\the\catcode35%
\catcode40=\the\catcode40%
\catcode41=\the\catcode41%
\catcode42=\the\catcode42%
\catcode43=\the\catcode43%
\catcode44=\the\catcode44%
\catcode45=\the\catcode45%
\catcode46=\the\catcode46%
\catcode58=\the\catcode58%
\catcode59=\the\catcode59%
\catcode60=\the\catcode60%
\catcode61=\the\catcode61%
\catcode62=\the\catcode62%
\catcode64=\the\catcode64%
\catcode91=\the\catcode91%
\catcode93=\the\catcode93%
\catcode94=\the\catcode94%
\catcode95=\the\catcode95%
\catcode126=\the\catcode126%
\endlinechar=\the\endlinechar
\relax}
\catcode32=10 %< >
\catcode33=12 %<">
\catcode35=6  %<#>
\catcode40=12 %<(>
\catcode41=12 %<)>
\catcode42=12 %<*>
\catcode43=12 %<+>
\catcode44=12 %<,>
\catcode45=12 %<->
\catcode46=12 %<.>
\catcode58=12 %<:>
\catcode59=12 %<;>
\catcode60=12 %<<>
\catcode61=12 %<=>
\catcode62=12 %<>>
\catcode64=11 %<@>
\catcode91=12 %<[>
\catcode93=12 %<]>
\catcode94=7  %<^>
\catcode95=8  %<_>
\catcode126=13 %<~>
\endlinechar=-1 %

\edef\ltj@adjust@AtEnd{\x
  \noexpand\let\noexpand\ltj@adjust@AtEnd\relax}
\def\luatexjaadjustLoaded{\endinput}

%% Check if LaTeX is used.
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname RequirePackage\endcsname\relax %<*!LaTeX>
  \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
    \csname iffalse\endcsname
\else                           %<*LaTeX>
  \expandafter\let\csname ifltj@in@latex\expandafter\endcsname
    \csname iftrue\endcsname
  \NeedsTeXFormat{LaTeX2e}
  \ProvidesPackage{luatexja-adjust}[2013/05/14]
\fi                             %</LaTeX>

% Load core module if not yet.
\ifx\luatexjacoreLoaded\@undefined
  \ifltj@in@latex                 %<*LaTeX>
    \RequirePackage{luatexja}[2013/05/14]
  \else                           %<*!LaTeX>
    \input luatexja.sty %
  \fi                             %</LaTeX>
\fi

%% When environment check fails, exit now.
\ifx\LuaTeXjaAvailable\@undefined
  \ltj@otf@AtEnd
\expandafter\endinput\fi\relax

%%------------------
\RequirePackage{expl3}
%! Main part of luatexja-adjust
\RequireLuaTeXjaSubmodule{adjust}

% enable/disable ``advanced'' line adjustment
\protected\def\ltjdisableadjust{\directlua{luatexja.adjust.disable_cb()}}
\protected\def\ltjenableadjust{\directlua{luatexja.adjust.enable_cb()}}
\ltjenableadjust
% there is also a key for \ltjsetparameter, for same effect
\define@boolkey[ltj]{japaram}{adjust}[true]{%
  \ifltj@japaram@adjust\ltjenableadjust\else\ltjdisableadjust\fi
}

\ExplSyntaxOn
\cs_new:Nn \ltj_adjust_inittable: {
  % To be filled...
}
\cs_new:Nn \ltj_adjust_appendtable:n {
  % To be filled
}

\clist_new:N \l_ltj_adjust_priority
\define@key[ltj]{japaram}{adjustpriority}{% COMMA LIST
  \clist_set:Nx \l_ltj_adjust_priority {#1}
  \ltj_adjust_inittable:
  \clist_map_function:NN \l_ltj_adjust_priority \ltj_adjust_appendtable:n
}

\ExplSyntaxOff


%%------------------ all done
\ltj@adjust@AtEnd
\endinput
%% EOF