Debian Codegraph @

texmf-dist/tex/lualatex/luamml/luamml-pdf.sty

raw
1 %%
2 %% This is file `luamml-pdf.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% luamml.dtx (with options: `package,pdftex')
8 %%
9 %% IMPORTANT NOTICE:
10 %%
11 %% For the copyright see the source file.
12 %%
13 %% Any modified versions of this file must be renamed
14 %% with new filenames distinct from luamml-pdf.sty.
15 %%
16 %% For distribution of the original source see the terms
17 %% for copying and modification in the file luamml.dtx.
18 %%
19 %% This generated file may be distributed as long as the
20 %% original source files, as listed above, are part of the
21 %% same distribution. (The sources need not necessarily be
22 %% in the same archive or directory.)
23 %% Copyright (C) 2020-2026 by Marcel Krueger
24 %%
25 %% This file may be distributed and/or modified under the
26 %% conditions of the LaTeX Project Public License, either
27 %% version 1.3c of this license or (at your option) any later
28 %% version. The latest version of this license is in:
29 %%
30 %% http://www.latex-project.org/lppl.txt
31 %%
32 %% and version 1.3 or later is part of all distributions of
33 %% LaTeX version 2005/12/01 or later.
34 \ProvidesExplPackage {luamml-pdf} {2026-02-27} {0.8.0}
35 {MathML generation for L̶u̶a̶pdfLaTeX}
36 \int_new:N \l__luamml_flag_int
37 \int_new:N \l__luamml_pretty_int
38 \tl_new:N \l__luamml_root_tl
39 \tl_set:Nn \l__luamml_root_tl { mrow }
40 \tl_new:N \l__luamml_label_tl
41 \int_new:N \g__luamml_formula_id_int
42
43 \int_set:Nn \l__luamml_pretty_int { 1 }
44
45 \cs_new_protected:Npn \luamml_process: {
46 \tl_set:Nn \l__luamml_label_tl {}
47 \int_set:Nn \l__luamml_flag_int { 3 }
48 }
49 \cs_set_eq:NN \luamml_flag_process: \luamml_process:
50 \cs_new:Npn \__luamml_maybe_structelem: {
51 (
52 8 * \int_mod:nn {
53 \int_div_truncate:nn { \l__luamml_flag_int } {8}
54 } {2}
55 ) +
56 }
57 \cs_new:Npn \__luamml_style_to_num:N #1 {
58 \token_case_meaning:NnF #1 {
59 \displaystyle {0}
60 \textstyle {32}
61 \scriptstyle {64}
62 \scriptscriptstyle {96}
63 } {
64 \Invalid_mathstyle
65 }
66 }
67 \cs_new_protected:Npn \luamml_save:n #1 {
68 \tl_set:Nn \l__luamml_label_tl {#1}
69 \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 1 }
70 }
71 \cs_new_protected:Npn \luamml_save:nN #1#2 {
72 \tl_set:Nn \l__luamml_label_tl {#1}
73 \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 17 + \__luamml_style_to_num:N #2 }
74 }
75 \cs_new_protected:Npn \luamml_save:nn #1 {
76 \tl_set:Nn \l__luamml_label_tl {#1}
77 \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 5 }
78 \tl_set:Nn \l__luamml_root_tl
79 }
80 \cs_new_protected:Npn \luamml_save:nNn #1#2 {
81 \tl_set:Nn \l__luamml_label_tl {#1}
82 \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 21 + \__luamml_style_to_num:N #2 }
83 \tl_set:Nn \l__luamml_root_tl
84 }
85 \cs_set_eq:NN \luamml_flag_save:n \luamml_save:n
86 \cs_set_eq:NN \luamml_flag_save:nN \luamml_save:nN
87 \cs_set_eq:NN \luamml_flag_save:nn \luamml_save:nn
88 \cs_set_eq:NN \luamml_flag_save:nNn \luamml_save:nNn
89 \cs_new_protected:Npn \luamml_ignore: {
90 \int_set:Nn \l__luamml_flag_int { 0 }
91 }
92 \cs_set_eq:NN \luamml_flag_ignore: \luamml_ignore:
93 \luamml_process:
94
95 \cs_if_exist:NTF \showstream {
96 \iow_new:N \l__luamml_pdf_stream
97 \iow_open:Nn \l__luamml_pdf_stream { \jobname .tml }
98 \cs_new_protected:Npn \__luamml_pdf_showlists: {
99 \group_begin:
100 \int_set:Nn \tex_showboxdepth:D { \c_max_int }
101 \int_set:Nn \tex_showboxbreadth:D { \c_max_int }
102 \showstream = \l__luamml_pdf_stream
103 \tex_showlists:D
104 \group_end:
105 }
106 } {
107 \cs_set_eq:NN \l__luamml_pdf_stream \c_log_iow
108 \cs_set_eq:NN \__luamml_pdf_set_showstream: \scan_stop:
109 \cs_new_protected:Npn \__luamml_pdf_showlists: {
110 \group_begin:
111 \int_set:Nn \l_tmpa_int { \tex_interactionmode:D }
112 \int_set:Nn \tex_interactionmode:D { 0 }
113 \int_set:Nn \tex_showboxdepth:D { \c_max_int }
114 \int_set:Nn \tex_showboxbreadth:D { \c_max_int }
115 \tex_showlists:D
116 \int_set:Nn \tex_interactionmode:D { \l_tmpa_int }
117 \group_end:
118 }
119 }
120 \cs_generate_variant:Nn \tl_to_str:n { e }
121 \int_new:N \g__luamml_annotation_id_int
122 \cs_new_protected:Npn \luamml_annotate:nen #1#2#3 {
123 \int_gincr:N \g__luamml_annotation_id_int
124 \iow_shipout_x:Nx \l__luamml_pdf_stream {
125 LUAMML_MARK_REF:
126 \int_use:N \g__luamml_annotation_id_int
127 :
128 }
129 \iow_now:Nx \l__luamml_pdf_stream {
130 LUAMML_MARK:
131 \int_use:N \g__luamml_annotation_id_int
132 :
133 count = \int_eval:n {#1},
134 #2
135 \iow_newline:
136 LUAMML_MARK_END
137 }
138 #3
139 }
140 \cs_new_protected:Npn \luamml_annotate:en #1#2 {
141 \int_gincr:N \g__luamml_annotation_id_int
142 \iow_shipout_x:Nx \l__luamml_pdf_stream {
143 LUAMML_MARK_REF:
144 \int_use:N \g__luamml_annotation_id_int
145 :
146 }
147 \iow_now:Nx \l__luamml_pdf_stream {
148 LUAMML_MARK:
149 \int_use:N \g__luamml_annotation_id_int
150 :
151 count = data.count[\int_use:N \g__luamml_annotation_id_int],
152 #1
153 \iow_newline:
154 LUAMML_MARK_END
155 }
156 \use:x {
157 \iow_now:Nn \l__luamml_pdf_stream {
158 LUAMML_COUNT:
159 \int_use:N \g__luamml_annotation_id_int
160 }
161 \__luamml_pdf_showlists:
162 \exp_not:n {#2}
163 \iow_now:Nn \l__luamml_pdf_stream {
164 LUAMML_COUNT_END:
165 \int_use:N \g__luamml_annotation_id_int
166 }
167 \__luamml_pdf_showlists:
168 }
169 }
170 \cs_new_protected:Npn \luamml_pdf_write: {
171 \int_gincr:N \g__luamml_formula_id_int
172 \iow_now:Nx \l__luamml_pdf_stream {
173 LUAMML_FORMULA_BEGIN:
174 \int_use:N \g__luamml_formula_id_int
175 :
176 \int_use:N \l__luamml_flag_int
177 :
178 \l__luamml_root_tl
179 :
180 \l__luamml_label_tl
181 }
182 \__luamml_pdf_showlists:
183 \iow_now:Nx \l__luamml_pdf_stream {
184 LUAMML_FORMULA_END
185 }
186 }
187 \NewDocumentCommand \RegisterFamilyMapping {m m} {
188 \iow_now:Nx \l__luamml_pdf_stream {
189 LUAMML_INSTRUCTION:REGISTER_MAPPING: \int_use:N #1 : #2
190 }
191 }
192 \NewTaggingSocketPlug{math/luamml/save/nNn}{luamml}
193 {
194 \luamml_save:nNn #1
195 }
196 \AssignTaggingSocketPlug{math/luamml/save/nNn}{luamml}
197 \NewTaggingSocketPlug{math/luamml/save/nn}{luamml}
198 {
199 \luamml_save:nn #1
200 }
201 \AssignTaggingSocketPlug{math/luamml/save/nn}{luamml}
202
203
204 \cs_new_protected:Npn \__luamml_patch_package:nn #1 #2 {
205 \@ifpackageloaded {#1} {#2} {
206 \hook_gput_code:nnn {package/#1/after} {luamml} {#2}
207 }
208 }
209 \cs_new_protected:Npn \__luamml_patch_package:n #1 {
210 \__luamml_patch_package:nn {#1} {
211 \RequirePackage { luamml-patches-#1 }
212 }
213 }
214 \RequirePackage { luamml-patches-kernel }
215
216 \endinput
217 %%
218 %% End of file `luamml-pdf.sty'.