%%
%% This is file `luamml-pdf.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% luamml.dtx  (with options: `package,pdftex')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from luamml-pdf.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file luamml.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% Copyright (C) 2020-2024 by Marcel Krueger
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
\ProvidesExplPackage {luamml-pdf} {2024-08-14} {0.1.0}
  {MathML generation for L̶u̶a̶pdfLaTeX}
\int_new:N \l__luamml_flag_int
\int_new:N \l__luamml_pretty_int
\tl_new:N \l__luamml_root_tl
\tl_set:Nn \l__luamml_root_tl { mrow }
\tl_new:N \l__luamml_label_tl
\int_new:N \g__luamml_formula_id_int

\int_set:Nn \l__luamml_pretty_int { 1 }

\cs_new_protected:Npn \luamml_flag_process: {
  \tl_set:Nn \l__luamml_label_tl {}
  \int_set:Nn \l__luamml_flag_int { 3 }
}
\cs_new:Npn \__luamml_maybe_structelem: {
  (
    8 * \int_mod:nn {
      \int_div_truncate:nn { \l__luamml_flag_int } {8}
    } {2}
  ) +
}
\cs_new:Npn \__luamml_style_to_num:N #1 {
  \token_case_meaning:NnF #1 {
    \displaystyle {0}
    \textstyle {32}
    \scriptstyle {64}
    \scriptscriptstyle {96}
  } {
    \Invalid_mathstyle
  }
}
\cs_new_protected:Npn \luamml_flag_save:n #1 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 1 }
}
\cs_new_protected:Npn \luamml_flag_save:nN #1#2 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 17 + \__luamml_style_to_num:N #2 }
}
\cs_new_protected:Npn \luamml_flag_save:nn #1 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 5 }
  \tl_set:Nn \l__luamml_root_tl
}
\cs_new_protected:Npn \luamml_flag_save:nNn #1#2 {
  \tl_set:Nn \l__luamml_label_tl {#1}
  \int_set:Nn \l__luamml_flag_int { \__luamml_maybe_structelem: 21 + \__luamml_style_to_num:N #2 }
  \tl_set:Nn \l__luamml_root_tl
}
\cs_new_protected:Npn \luamml_flag_ignore: {
  \int_set:Nn \l__luamml_flag_int { 0 }
}
\luamml_flag_process:

\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
    \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:
      \int_set:Nn \l_tmpa_int { \tex_interactionmode:D }
      \int_set:Nn \tex_interactionmode:D { 0 }
      \int_set:Nn \tex_showboxdepth:D { \c_max_int }
      \int_set:Nn \tex_showboxbreadth:D { \c_max_int }
      \tex_showlists:D
      \int_set:Nn \tex_interactionmode:D { \l_tmpa_int }
    \group_end:
  }
}
\cs_generate_variant:Nn \tl_to_str:n { e }
\int_new:N \g__luamml_annotation_id_int
\cs_new_protected:Npn \luamml_annotate:nen #1#2#3 {
  \int_gincr:N \g__luamml_annotation_id_int
  \iow_shipout_x:Nx \l__luamml_pdf_stream {
    LUAMML_MARK_REF:
    \int_use:N \g__luamml_annotation_id_int
    :
  }
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_MARK:
    \int_use:N \g__luamml_annotation_id_int
    :
    count = \int_eval:n {#1},
    #2
    \iow_newline:
    LUAMML_MARK_END
  }
  #3
}
\cs_new_protected:Npn \luamml_annotate:en #1#2 {
  \int_gincr:N \g__luamml_annotation_id_int
  \iow_shipout_x:Nx \l__luamml_pdf_stream {
    LUAMML_MARK_REF:
    \int_use:N \g__luamml_annotation_id_int
    :
  }
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_MARK:
    \int_use:N \g__luamml_annotation_id_int
    :
    count = data.count[\int_use:N \g__luamml_annotation_id_int],
    #1
    \iow_newline:
    LUAMML_MARK_END
  }
  \use:x {
    \iow_now:Nn \l__luamml_pdf_stream {
      LUAMML_COUNT:
      \int_use:N \g__luamml_annotation_id_int
    }
    \__luamml_pdf_showlists:
    \exp_not:n {#2}
    \iow_now:Nn \l__luamml_pdf_stream {
      LUAMML_COUNT_END:
      \int_use:N \g__luamml_annotation_id_int
    }
    \__luamml_pdf_showlists:
  }
}
\cs_new_protected:Npn \luamml_pdf_write: {
  \int_gincr:N \g__luamml_formula_id_int
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_FORMULA_BEGIN:
    \int_use:N \g__luamml_formula_id_int
    :
    \int_use:N \l__luamml_flag_int
    :
    \l__luamml_root_tl
    :
    \l__luamml_label_tl
  }
  \__luamml_pdf_showlists:
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_FORMULA_END
  }
}
\NewDocumentCommand \RegisterFamilyMapping {m m} {
  \iow_now:Nx \l__luamml_pdf_stream {
    LUAMML_INSTRUCTION:REGISTER_MAPPING: \int_use:N #1 : #2
  }
}
\cs_new_protected:Npn \__luamml_patch_package:nn #1 #2 {
  \@ifpackageloaded {#1} {#2} {
    \hook_gput_code:nnn {package/#1/after} {luamml} {#2}
  }
}
\cs_new_protected:Npn \__luamml_patch_package:n #1 {
  \__luamml_patch_package:nn {#1} {
    \RequirePackage { luamml-patches-#1 }
  }
}
\RequirePackage { luamml-patches-kernel }

\endinput
%%
%% End of file `luamml-pdf.sty'.
