latex3 / tagpdf

Tagging support code for LaTeX
59 stars 7 forks source link

[lualatex]: remove empty mc and structures where possible #73

Open u-fischer opened 1 year ago

u-fischer commented 1 year ago

In lualatex some empty mc and related empty parent structures can be detected:

\DocumentMetadata
{uncompress,testphase=phase-III,debug={log=vv}}
\documentclass{article}
\begin{document}

start
\tagmcend
 \tagstructbegin{tag=Span}\tagmcbegin{}\tagmcend
   \tagstructbegin{tag=Span}\tagmcbegin{}\tagmcend\tagstructend
 \tagstructend 
\tagmcbegin{} 
end

\end{document}

gives

12 0 obj
<<  /Type /StructElem /S /Span /P 11 0 R /K [ 13 0 R] /ID (ID.04) >>
endobj
13 0 obj
<<  /Type /StructElem /S /Span /P 12 0 R /K null /ID (ID.05) >> %<--- null
endobj

Removing them is not completly trivial as one has to do it recursively and also check the IDtree, but it should be possible to clean up a bit mode ...