pdfmml \showstream support

This commit is contained in:
Marcel Fabian Krüger 2021-06-06 06:23:13 +02:00
parent e0705c210b
commit dfee31b4b8
3 changed files with 34 additions and 18 deletions

View File

@ -1,7 +1,22 @@
\ProvidesExplPackage {luamml-pdf} {2021-05-31} {0.0.1-alpha} \ProvidesExplPackage {luamml-pdf} {2021-05-31} {0.0.1-alpha}
{MathML generation for L̶u̶a̶pdfLaTeX} {MathML generation for L̶u̶a̶pdfLaTeX}
\cs_new:Npn \__luamml_pdf_showlists: { \cs_if_exist:NTF \showstream {
\iow_new:N \l__luamml_pdf_stream
\iow_open:Nn \l__luamml_pdf_stream { \jobname .tml }
\cs_new_protected:Npn \__luamml_pdf_showlists: {
\group_begin:
\int_set:Nn \tex_showboxdepth:D { \c_max_int }
\int_set:Nn \tex_showboxbreadth:D { \c_max_int }
\showstream = \l__luamml_pdf_stream
\tex_showlists:D
\iow_now:Nx \l__luamml_pdf_stream {}
\group_end:
}
} {
\cs_set_eq:NN \l__luamml_pdf_stream \c_log_iow
\cs_set_eq:NN \__luamml_pdf_set_showstream: \scan_stop:
\cs_new_protected:Npn \__luamml_pdf_showlists: {
\group_begin: \group_begin:
\int_set:Nn \l_tmpa_int { \tex_interactionmode:D } \int_set:Nn \l_tmpa_int { \tex_interactionmode:D }
\int_set:Nn \tex_interactionmode:D { 0 } \int_set:Nn \tex_interactionmode:D { 0 }
@ -10,17 +25,18 @@
\tex_showlists:D \tex_showlists:D
\int_set:Nn \tex_interactionmode:D { \l_tmpa_int } \int_set:Nn \tex_interactionmode:D { \l_tmpa_int }
\group_end: \group_end:
}
} }
\int_new:N \g__luamml_formula_id_int \int_new:N \g__luamml_formula_id_int
\cs_new_protected:Npn \luamml_pdf_write: { \cs_new_protected:Npn \luamml_pdf_write: {
\int_gincr:N \g__luamml_formula_id_int \int_gincr:N \g__luamml_formula_id_int
\iow_log:x { \iow_now:Nx \l__luamml_pdf_stream {
LUAMML_FORMULA_BEGIN: LUAMML_FORMULA_BEGIN:
\int_use:N \g__luamml_formula_id_int \int_use:N \g__luamml_formula_id_int
} }
\__luamml_pdf_showlists: \__luamml_pdf_showlists:
\iow_log:x { \iow_now:Nx \l__luamml_pdf_stream {
LUAMML_FORMULA_END LUAMML_FORMULA_END
} }
} }
@ -38,7 +54,7 @@
\int_new:N \g__luamml_annotation_id_int \int_new:N \g__luamml_annotation_id_int
\cs_new_protected:Npn \luamml_pdf_annotate:nnn #1#2#3 { \cs_new_protected:Npn \luamml_pdf_annotate:nnn #1#2#3 {
\int_gincr:N \g__luamml_annotation_id_int \int_gincr:N \g__luamml_annotation_id_int
\iow_shipout_x:Nx \c_log_iow { \iow_shipout_x:Nx \l__luamml_pdf_stream {
\tl_to_str:e { \tl_to_str:e {
LUAMML_MARK: LUAMML_MARK:
\int_use:N \g__luamml_annotation_id_int \int_use:N \g__luamml_annotation_id_int
@ -58,7 +74,7 @@
% THIS VERSION IS SIGNIFICANTLY SLOWER % THIS VERSION IS SIGNIFICANTLY SLOWER
\cs_new_protected:Npn \luamml_pdf_annotate:nn #1#2 { \cs_new_protected:Npn \luamml_pdf_annotate:nn #1#2 {
\int_gincr:N \g__luamml_annotation_id_int \int_gincr:N \g__luamml_annotation_id_int
\iow_shipout_x:Nx \c_log_iow { \iow_shipout_x:Nx \l__luamml_pdf_stream {
\tl_to_str:e { \tl_to_str:e {
LUAMML_MARK: LUAMML_MARK:
\int_use:N \g__luamml_annotation_id_int \int_use:N \g__luamml_annotation_id_int
@ -69,20 +85,20 @@
\exp_not:N \iow_newline: \exp_not:N \iow_newline:
LUAMML_MARK_END LUAMML_MARK_END
} }
\iow_now:Nx \c_log_iow { \iow_now:Nx \l__luamml_pdf_stream {
LUAMML_COUNT: LUAMML_COUNT:
\int_use:N \g__luamml_annotation_id_int \int_use:N \g__luamml_annotation_id_int
} }
\__luamml_pdf_showlists: \__luamml_pdf_showlists:
#2 #2
\iow_now:Nn \c_log_iow { \iow_now:Nx \l__luamml_pdf_stream {
LUAMML_COUNT_END LUAMML_COUNT_END
} }
\__luamml_pdf_showlists: \__luamml_pdf_showlists:
} }
\NewDocumentCommand \RegisterFamilyMapping {m m} { \NewDocumentCommand \RegisterFamilyMapping {m m} {
\iow_log:x { \iow_now:Nx \l__luamml_pdf_stream {
LUAMML_INSTRUCTION:REGISTER_MAPPING: \int_use:N #1 : #2 LUAMML_INSTRUCTION:REGISTER_MAPPING: \int_use:N #1 : #2
} }
} }

View File

@ -3,7 +3,7 @@ local l = lpeg or require'lpeg'
local line = (1-l.P'\n')^0 * '\n' local line = (1-l.P'\n')^0 * '\n'
local id = l.R'09'/tonumber local id = l.R'09'/tonumber
local non_final_list_block = (l.C((1-l.P'\n')^0) * '\n' - '### ')^0 local non_final_list_block = (l.C((1-l.P'\n')^1) * '\n' - '### ' + '\n')^0
local math_lists_block = l.Ct('### ' * l.Cg(l.C'display' * ' ', 'display')^-1 * 'math mode entered at line ' * l.Cg(l.R'09'^1 / tonumber, 'line') * '\n' local math_lists_block = l.Ct('### ' * l.Cg(l.C'display' * ' ', 'display')^-1 * 'math mode entered at line ' * l.Cg(l.R'09'^1 / tonumber, 'line') * '\n'
* non_final_list_block)^1 * non_final_list_block)^1
local generic_list_block = '### ' * (line - 'current page:') * non_final_list_block local generic_list_block = '### ' * (line - 'current page:') * non_final_list_block

View File

@ -64,7 +64,7 @@ local fraction_noad = l.Ct('\\fraction, thickness '
local mathchoice_noad = l.Ct('\\mathchoice' * l.Cg(l.Cc'choice', 'id') * -1) local mathchoice_noad = l.Ct('\\mathchoice' * l.Cg(l.Cc'choice', 'id') * -1)
local mark_whatsit = '\\write-{LUAMML_MARK:' * (l.R'09'^1/tonumber) * ':' local mark_whatsit = '\\write' * ('-' + l.R'09'^1) * '{LUAMML_MARK:' * (l.R'09'^1/tonumber) * ':'
local parse_list local parse_list
local function parse_kernel(lines, i, prefix, parsed) local function parse_kernel(lines, i, prefix, parsed)