%%
%% This is file `tagpdf-user.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tagpdf.dtx  (with options: `user')
%% 
%% Copyright (C) 2019 Ulrike Fischer
%% 
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version.  The latest
%% version of this license is in the file:
%% 
%%    https://www.latex-project.org/lppl.txt
%% 
%% This file is part of the "tagpdf bundle" (The Work in LPPL)
%% and all files in that bundle must be distributed together.
%% 
%% File: tagpdf.dtx
\ProvidesExplPackage {tagpdf-user} {2021/02/23} {0.80}
  {tagpdf - user commands}

\NewDocumentCommand \tagpdfsetup { m }
  {
    \keys_set:nn { __tag / setup } { #1 }
  }

\cs_set_eq:NN\tagpdfifluatexTF \sys_if_engine_luatex:TF
\cs_set_eq:NN\tagpdfifluatexT  \sys_if_engine_luatex:T
\cs_set_eq:NN\tagpdfifpdftexT  \sys_if_engine_pdftex:T

%%% stop tagging
\bool_new:N \l__tag_stop_bool

\prg_new_conditional:Nnn \__tag_if_stop: {p,T,F,TF}
  {
    \bool_if:NTF \l__tag_stop_bool
      { \prg_return_true:  }
      { \prg_return_false: }
  }

\prg_new_eq_conditional:NNn \tag_if_stop: \__tag_if_stop: {p,T,F,TF}

\cs_new_protected:Npn \__tag_stop:
  {
    \bool_set_true:N \l__tag_stop_bool
    \cs_set_eq:NN \tag_mc_begin:n     \use_none:n
    \cs_set_eq:NN \tag_mc_end:        \prg_do_nothing:
    \cs_set_eq:NN \tag_mc_use:n       \use_none:n
    \cs_set_eq:NN \tag_struct_begin:n \use_none:n
    \cs_set_eq:NN \tag_struct_end:    \prg_do_nothing:
    \cs_set_eq:NN \tag_struct_use:n   \use_none:n
    %deprecated
    \cs_set_eq:NN \uftag_mc_begin:n \tag_mc_begin:n
    \cs_set_eq:NN \uftag_mc_end:    \tag_mc_end:
    \cs_set_eq:NN \uftag_mc_use:n \tag_mc_use:n
    \cs_set_eq:NN \uftag_struct_begin:n \tag_struct_begin:n
    \cs_set_eq:NN \uftag_struct_end: \tag_struct_end:
    \cs_set_eq:NN  \uftag_struct_use:n \tag_struct_use:n
  }

\cs_new_protected:Npn \tag_stop_group_begin:
  {
    \group_begin:
    \__tag_stop:
  }

\cs_set_eq:NN \tag_stop_group_end: \group_end:

%%% a generic command to retrieve data

\cs_new:Npn \tagpdfget #1   { \use:c {__tag_get_data_#1: } }
\cs_new:Npn \tag_get:n #1   { \use:c {__tag_get_data_#1: } }
\cs_new:Npn \uftag_get:n #1 { \use:c {__tag_get_data_#1: } }

%%%% mc related user commands
\NewDocumentCommand \tagmcifinTF { m m }
  {
    \__tag_mc_if_in:TF { #1 } { #2 }
  }

\NewDocumentEnvironment{tagmcartifact}{m}
 {
  \tag_mc_artifact_group_begin:n { #1}\ignorespaces
 }
 {
  \tag_mc_artifact_group_end:
 }

\NewDocumentCommand \tagmcbegin { m }
  {
    \tag_mc_begin:n {#1}\ignorespaces
  }

\NewDocumentCommand \tagmcend {  }
  {
    \unskip % this unskip appears to mess up some spacing; can we do this in another way?
    \tag_mc_end:
  }

\NewDocumentCommand \tagmcuse { m }
  {
    \tag_mc_use:n {#1}
  }

%%%% structure related commands

\NewDocumentCommand \tagstructbegin { m }
  {
    \tag_struct_begin:n {#1}
  }

\NewDocumentCommand \tagstructend {  }
  {
   \tag_struct_end:
  }

\NewDocumentCommand \tagstructuse { m }
  {
    \tag_struct_use:n {#1}
  }

%%%% debug/show commands
\NewDocumentCommand\showtagpdfmcdata { O {\__tag_tag_get_mc_abs_cnt:} }
  {
    \bool_if:NT \g__tag_mode_lua_bool
      {
        \sys_if_engine_luatex:T
          {
            \directlua{ltx.__tag.trace.show_all_mc_data(#1)}
          }
      }
  }

\NewDocumentCommand\showtagpdfattributes { }
  {
    \bool_if:NT \g__tag_mode_lua_bool
      {
        \sys_if_engine_luatex:T
          {
            \directlua
              {
                ltx.__tag.trace.log
                 (
                   "showtagpdfattributes:
                    MC=>abscnt=\__tag_get_mc_abs_cnt:
                    =>attr=\the\l__tag_mc_cnt_attr=>tag="
                    ..
                    tostring(ltx.__tag.func.get_tag_from (\the\l__tag_mc_type_attr))
                    ..
                    "=\the\l__tag_mc_type_attr",0
                 )
             }
            \ignorespaces
          }
      }
   }

\sys_if_engine_luatex:T
  {
    \NewDocumentCommand\pdffakespace { }
      {
        \__tag_fakespace:
      }
  }

%% 
%%
%% End of file `tagpdf-user.sty'.
