[luatex] How to redefine command with optional argument using expl3?

Alexander Kozlovskiy k.sasha1994 at yandex.ru
Thu Nov 5 05:00:00 CET 2020


Hello everybody. I want to redefine \table/tabular environments,to do 
autotagging of this environments. I know,what \tabular have one 
mandatory argument,and one optional,and optional argument use in 
\maketitle command. Please,help me redefine \tabular command,to fix 
error,which happens during compilation in latex.

! LaTeX Error: Illegal character in array arg.

I know,what this error happens because according to debug,first 
argument,which optional, [t] separate to three arguments: [ t and ],but 
i dont know,how to solve this issue. Also i know,what for different 
packages optional argument can be different,but how it handle using 
expl3,i haven't any idea. Thanks everybody very much for any 
help,because i dont know,how to solve this.

\documentclass{article}
\usepackage{tagpdf}
\tagpdfsetup{tabsorder=structure,uncompress,activate-all,add-new-tag=Title/P,interwordspace=true} 

\ExplSyntaxOn
\makeatletter
\prop_gset_from_keyval:Nn{\g__tables_prop}{table=0,endtable=1,table*=0,endtable*=1,tabular=0,endtabular=1,tabular*=0,endtabular*=1,tabbing=0,endtabbing=1,tabbing*=0,endtabbing*=1} 

\prop_map_inline:Nn \g__tables_prop{
\cs_set_eq:cc{orig@#1}{#1}
\int_case:nnF{#2}
{
{0} %somethin with \begin,e.g \begin{tabular}
{
\cs_gset_protected:cpn{#1}##1{
\cs_new_protected:Npn \l__tab_char: {
\tagmcend
\tagstructend
\tagstructend
\tagstructbegin{tag=TD}
\tagstructbegin{tag=P}
\tagmcbegin{tag=P}
     \c_alignment_token
}
\char_set_active_eq:NN \& \l__tab_char:
\char_set_catcode_active:N \&
\tagstructbegin{tag=Table}
\tagstructbegin{tag=TBody}
\use:c{orig@#1}{##1}
\message{argument~##1}
}
}
{1} %somethin with \end,e.g \end{tabular}
{
\cs_gset_protected:cpn{#1}{
\use:c{orig@#1}
\tagstructend
\tagstructend
}
}
}
{}
}
\makeatother
\ExplSyntaxOff
\author{Alexandr Kozlovskiy}
\title{test}
\begin{document}
\tagstructbegin{tag=Document}
\maketitle{} %error
\makeatletter
%this code works ok.
\begin{tabular}{ccc}
1&2&3
\end{tabular}
\tagstructend
\end{document}


More information about the luatex mailing list.