diff options
author | Karl Berry <karl@freefriends.org> | 2018-08-07 22:06:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-08-07 22:06:23 +0000 |
commit | 706448acbd096e1a59cb987e8352abdd43624ebe (patch) | |
tree | b15d896ae27ff72a04f6ffcdc9ed0fc2ccdc689b /Master/texmf-dist | |
parent | 23fec857e8f705b5595264d42d1265077d09654d (diff) |
tagpdf (7aug18)
git-svn-id: svn://tug.org/texlive/trunk@48366 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
29 files changed, 886 insertions, 293 deletions
diff --git a/Master/texmf-dist/doc/latex/tagpdf/README.md b/Master/texmf-dist/doc/latex/tagpdf/README.md index 3801de04b0c..7519cf76fb9 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/README.md +++ b/Master/texmf-dist/doc/latex/tagpdf/README.md @@ -1,6 +1,6 @@ #tagpdf — A package to create tagged pdf -Packageversion: 0.2 -Packagedate: 2018/07/09 +Packageversion: 0.3 +Packagedate: 2018/08/06 Author: Ulrike Fischer ## License diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf Binary files differnew file mode 100644 index 00000000000..048d685cffe --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext-luatex.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.pdf Binary files differnew file mode 100644 index 00000000000..2a9bd8480b8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex new file mode 100644 index 00000000000..38185f5d4ce --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-alt-actualtext.tex @@ -0,0 +1,181 @@ +% !Mode:: "TeX:DE:UTF-8:Main" +%\input{regression-test} +\documentclass{article} +\usepackage{tagpdf} +\tagpdfsetup{tabsorder=structure, + uncompress,activate-all} +\tagpdfifpdftexT + { + %set language / can also be done with hyperref + \pdfcatalog{/Lang (de-DE)} + \usepackage[T1]{fontenc} + \input glyphtounicode + \pdfgentounicode=1 + } + +\tagpdfifluatexT + { + %set language / can also be done with hyperref + \pdfextension catalog{/Lang (de-DE)} + \usepackage{fontspec} + \usepackage{unicode-math} + \usepackage{luacode} + \newfontface\zerowidthfont{freeserif} + } + +\usepackage{graphicx} +% This is not a perfectly tagged document! +% one sentence is not marked (luatex will mark it as artifact) +% with pdflatex there is a encoding problem with the math + +\begin{document} +\pagestyle{empty} + +\tagstructbegin{tag=Document} + +%This isn't read by voice software +Etwas unmarkierter Text. + +%This read ok by voice software +\tagstructbegin{tag=P} + \tagmcbegin{tag=P} + Ein Satz ohne Umlaute. + \tagmcend +\tagstructend + +%This read ok by nvda, but adobe has difficulties with the umlauts +\tagstructbegin{tag=P} + \tagmcbegin{tag=P} + Grüße an die Welt und die öde Wüste. + \tagmcend +\tagstructend + +\newpage +% alttext is read, +% actualtext copy & pasted +\tagstructbegin{tag=P,alttext=Dies ist ein Text,actualtext=Copy} + \tagmcbegin{tag=P} + Test + \tagmcend +\tagstructend + +%alttext is read, +%actualtext copy & pasted +\tagstructbegin{tag=P} + \tagmcbegin{tag=P,alttext=Dies ist ein zweiter Text,actualtext=Copy} + Test + \tagmcend +\tagstructend + + +%nvda: alttext of structure is read +%adobe: alttext of inner mc is read +% result of copy & paste of this page in adobe reader: +% why twice?????? +% Copy Copy +% Copy Copy +% Copystruct Copystruct + +\tagstructbegin{tag=P,alttext=Dies ist der Structuretext,actualtext=Copystruct} + \tagmcbegin{tag=P,alttext=Dies ist der innere Text,actualtext=Copymc} + Test + \tagmcend +\tagstructend + + + +\newpage +% test of "Formula" tag: +% content is more or less ignored. This is not against the documentation: +% Formula is explicitly describes as an "illustration", something with a content +% which can not be read directly. +% But it is a problem that nvda ignores it even with an alt text. + +%test of Formula tag + alttext in the mc +%pdflatex +%nvda: content is ignored +%adobe: reads the alt text but without {} and () + +%luatex (unicode-math): +% nvda: doesn't read +%adobe: doesn't read (warning "empty page") + +\tagstructbegin{tag=Formula} + \tagmcbegin {tag=Formula,alttext={\frac{a}{b}+c + \int_1^n f(x)}} + xxx $\frac{a}{b}+c + \int_1^n f(x)$ + \tagmcend +\tagstructend + +\newpage + +%test of Formula tag + alttext in the struct +\tagstructbegin{tag=Formula,alttext=Dies ist eine Formel} + \tagmcbegin {tag=Formula} + formula + \tagmcend +\tagstructend + +\newpage +% test of Formula tag without alttext +% pdflatex +% adobe: reads it more or less (without commands naturally) +% nvda: ignores it + +%lualatex +%nvda: ignores it +%adobe: ignores it + +\tagstructbegin{tag=Formula} + \tagmcbegin {tag=Formula} + formula: $\frac{a}{b}+c + \int_1^n f(x)$ + \tagmcend +\tagstructend + +\newpage +% luatex: +% nvda: reads the alttext ok, {} and () are only read if the symbol level is (at leat) "most" +% adobe: something is read but it is not understable + +\tagstructbegin{tag=P} + \tagmcbegin {tag=P,alttext={\frac{x}{y}+c + \int_1^n f(x)}} + $\frac{x}{y}+c + \int_1^n f(x)$ + \tagmcend +\tagstructend + +%pdftex +% sum is read as "pi" +%luatex +%adobe: almost nothing read (only 1 and =) +%nvda: similar, obviously both have problems with the unicode math symbols +\tagstructbegin{tag=P} + \tagmcbegin {tag=P} + $\sum_1^n (1) = n $ + \tagmcend +\tagstructend + +\newpage + +\tagmcbegin{tag=P, + actualtext=Ente, + alttext=Dies ist eine Ente} + %% a char is needed so that actualtext works, + \tagpdfifluatexTF + {{\zerowidthfont^^^^200c}}% + {\makebox[0pt][l]{.}}% + %it seems not to be needed for alttext and voice software .... + \includegraphics[width=1cm]{example-image-duck} +\tagmcend + +\tagmcbegin{tag=P, + actualtext=Ente, + alttext=Dies ist eine zweite Ente} + %% a char is needed so that actualtext works, + %\tagpdfifluatexTF + % {{\zerowidthfont^^^^200c}}% + % {\makebox[0pt][l]{.}}% + %it seems not to be needed for alttext and voice software .... + \includegraphics[width=1cm]{example-image-duck} +\tagmcend + +\tagstructend +\end{document} diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf Binary files differnew file mode 100644 index 00000000000..c79f34e4db8 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem-luatex.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex new file mode 100644 index 00000000000..55f9c95c370 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-formula-problem.tex @@ -0,0 +1,59 @@ +% !Mode:: "TeX:DE:UTF-8:Main" +\documentclass{article} +\usepackage{tagpdf} +\tagpdfsetup{tabsorder=structure, + uncompress,activate-all} +\tagpdfifpdftexT + { + %set language / can also be done with hyperref + \pdfcatalog{/Lang (de-DE)} + \usepackage[T1]{fontenc} + \input glyphtounicode + \pdfgentounicode=1 + } + +\tagpdfifluatexT + { + %set language / can also be done with hyperref + \pdfextension catalog{/Lang (de-DE)} + \usepackage{fontspec} + \usepackage{unicode-math} + \usepackage{luacode} + \newfontface\zerowidthfont{freeserif} + } + +\usepackage{graphicx} +% ndva doesn't read the alt text of the formulas +\begin{document} +\pagestyle{empty} + +\tagstructbegin{tag=Document} + +\tagstructbegin{tag=P} + \tagmcbegin{tag=P} + Ein Satz ohne Umlaute. + \tagmcend +\tagstructend + +\tagstructbegin{tag=Formula} + \tagmcbegin {tag=Formula,alttext={Dies ist eine Formel}} + formula + \tagmcend +\tagstructend + +\newpage + +\tagstructbegin{tag=P} + \tagmcbegin{tag=P} + Ein Satz ohne Umlaute. + \tagmcend +\tagstructend + +\tagstructbegin{tag=Formula,alttext=Dies ist eine zweite Formel} + \tagmcbegin {tag=Formula} + formula + \tagmcend +\tagstructend + +\tagstructend +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf Binary files differindex f2752408fb5..23c6c0d6921 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex index e7001f88ed0..9b611c41546 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-mc-manual-para-split.tex @@ -1,4 +1,11 @@ % !Mode:: "TeX:DE:UTF-8:Main" + +% !!!!!!!!!!!!!!!!! +% This test files shows how to add a manual page split. +% It *only* handles the mc-step in the page stream. +% Structure commands and all the related management are not +% involved. So it also only uses activate-mc. + \documentclass{book} \usepackage[english,ngerman]{babel} \usepackage{tagpdf} @@ -18,7 +25,7 @@ \tagpdfsetup{tabsorder=structure, - activate-all, + activate-mc, uncompress } \newsavebox\mybox diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luamode.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luatex.pdf Binary files differindex 238fdba9da5..9cc1417cfec 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luamode.pdf +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma-luatex.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf index 495b2eb4aef..e75c8e7d216 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.pdf @@ -639,7 +639,7 @@ endobj << /Type /StructElem /S /H4 /P 4 0 R /K <</Type /MCR /Pg 39 0 R /MCID 3>>>> endobj 43 0 obj -<< /Type /StructElem /S /P /P 4 0 R /K <</Type /MCR /Pg 39 0 R /MCID 4>>>> +<< /Type /StructElem /S /P /P 4 0 R /K <</Type /MCR /Pg 39 0 R /MCID 4>> /ActualText <FEFF0061006200630021>>> endobj 1 0 obj << /Type /StructTreeRoot /K 4 0 R /ParentTree 2 0 R /RoleMap 3 0 R>> @@ -1193,18 +1193,18 @@ endobj endobj 66 0 obj << -/Producer (pdfTeX-1.40.19) +/Producer (MiKTeX pdfTeX-1.40.19) /Creator (TeX) -/CreationDate (D:20180709211858+02'00') -/ModDate (D:20180709211858+02'00') +/CreationDate (D:20180806192039+02'00') +/ModDate (D:20180806192039+02'00') /Trapped /False -/PTEX.Fullbanner (This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018/W32TeX) kpathsea version 6.3.0) +/PTEX.Fullbanner (This is MiKTeX-pdfTeX 2.9.6668 (1.40.19)) >> endobj xref 0 67 0000000000 65535 f -0000009949 00000 n +0000009984 00000 n 0000007538 00000 n 0000007722 00000 n 0000007742 00000 n @@ -1228,9 +1228,9 @@ xref 0000009298 00000 n 0000005852 00000 n 0000000015 00000 n -0000078300 00000 n -0000077660 00000 n -0000078460 00000 n +0000078335 00000 n +0000077695 00000 n +0000078495 00000 n 0000006132 00000 n 0000005993 00000 n 0000005934 00000 n @@ -1249,32 +1249,32 @@ xref 0000009858 00000 n 0000007420 00000 n 0000006764 00000 n -0000078140 00000 n -0000077980 00000 n -0000077820 00000 n -0000077515 00000 n -0000010033 00000 n -0000010151 00000 n -0000010594 00000 n -0000011032 00000 n -0000011483 00000 n -0000011905 00000 n -0000026874 00000 n -0000027145 00000 n -0000040400 00000 n -0000040637 00000 n -0000054167 00000 n -0000054415 00000 n -0000067219 00000 n -0000067463 00000 n -0000077270 00000 n -0000078546 00000 n -0000078659 00000 n +0000078175 00000 n +0000078015 00000 n +0000077855 00000 n +0000077550 00000 n +0000010068 00000 n +0000010186 00000 n +0000010629 00000 n +0000011067 00000 n +0000011518 00000 n +0000011940 00000 n +0000026909 00000 n +0000027180 00000 n +0000040435 00000 n +0000040672 00000 n +0000054202 00000 n +0000054450 00000 n +0000067254 00000 n +0000067498 00000 n +0000077305 00000 n +0000078581 00000 n +0000078694 00000 n trailer << /Size 67 /Root 65 0 R /Info 66 0 R -/ID [<81DC649643DA754F285C6A424525246A> <81DC649643DA754F285C6A424525246A>] >> +/ID [<D5F0F02AEB96408AC9CC20B0806114F4> <D5F0F02AEB96408AC9CC20B0806114F4>] >> startxref -78926 +78916 %%EOF diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex index 6fccf189d4a..5558f9f2852 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-patch-sectioning-koma.tex @@ -11,18 +11,20 @@ \documentclass{scrbook} \usepackage[english]{babel} -%set language / can also be done with hyperref -\pdfcatalog{/Lang (en-US)} \usepackage{tagpdf} \tagpdfifpdftexT { + %set language / can also be done with hyperref + \pdfcatalog{/Lang (en-US)} \usepackage[T1]{fontenc} } \tagpdfifluatexT { + %set language / can also be done with hyperref + \pdfextension catalog{/Lang (en-US)} \usepackage{fontspec} \usepackage{luacode} } @@ -158,7 +160,7 @@ \subsection{subsection} \subsubsection{subsubsection} - \tagstructbegin{tag=P} + \tagstructbegin{tag=P,actualtext=abc!} \tagmcbegin{tag=P} a paragraph\par x \tagmcend diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf Binary files differnew file mode 100644 index 00000000000..693ecaa3432 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex new file mode 100644 index 00000000000..20f002258b9 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-softhyphen.tex @@ -0,0 +1,40 @@ +% !Mode:: "TeX:DE:UTF-8:Main" +% !! needs lualatex +% this sets the hyphen used by automatic hyphenation to 00AD +% this improves copy&pasting +% the example gives aaaaaaa-aaaaaaaaaaaaa-aaaaaa Ministerpräsident +% when copied from adobe +% open problem: line ends are not copy&pasted as spaces. +% see also pull request #1, branch fake-space + +\documentclass{book} + +\usepackage[ngerman]{babel} %to get some hyphenation +\usepackage{tagpdf} +\tagpdfsetup{tabsorder=structure, + activate-all, %deactivate to see the difference + uncompress + } +\usepackage{lipsum}% +\usepackage{fontspec} + +\prehyphenchar`\^^ad + +\pagestyle{empty} +\textwidth=1cm +\begin{document} +\tagstructbegin{tag=Document} + \tagstructbegin{tag=P} + \tagmcbegin{tag=P} + aaaaaaa-aaaaaa aaaaaaa-aaaaaa + \tagmcend + \tagstructend + + \tagstructbegin{tag=P} + \tagmcbegin{tag=P} + Ministerpräsident + \tagmcend + \tagstructend +\tagstructend +\end{document} + diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf b/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf Binary files differindex 71a860bda76..07932412295 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex b/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex index 8a0bfd1d642..3be554465cb 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex +++ b/Master/texmf-dist/doc/latex/tagpdf/ex-tagpdf-template.tex @@ -1,27 +1,37 @@ % !Mode:: "TeX:DE:UTF-8:Main" +%this is more or less minimal template that can be used as starting point +%it doesn't set everything that would be needed! \documentclass{scrartcl} \usepackage[english]{babel} \usepackage{tagpdf} \tagpdfifpdftexT { + \pdfcatalog{/Lang (en-UK)} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} } \tagpdfifluatexT { + \pdfextension catalog{/Lang (en-UK)} \usepackage{fontspec} } \tagpdfsetup { + tabsorder=structure, activate-all, uncompress } \begin{document} +\pagestyle{empty} % +\tagstructbegin{tag=Document} -blbl +\tagmcbegin{tag=P} + a paragraph +\tagmcend +\tagstructend \end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf Binary files differindex 0d2d8b22388..1a2efc07462 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf +++ b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.pdf diff --git a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex index 36c1cf852f5..5b377f40058 100644 --- a/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex +++ b/Master/texmf-dist/doc/latex/tagpdf/tagpdf.tex @@ -1,6 +1,7 @@ % !Mode:: "TeX:DE:UTF-8:Main" \makeatletter -\def\UlrikeFischer@package@version{0.2} +\def\UlrikeFischer@package@version{0.3} +\def\UlrikeFischer@package@date{2018/08/06} \makeatother \documentclass[DIV=12,parskip=half-,bibliography=totoc]{scrartcl} \usepackage[utf8]{inputenc} @@ -15,7 +16,8 @@ \renewcommand\ttdefault{lmtt} \usepackage{tcolorbox} \usepackage{ydoc-desc} -\usepackage{tabularx, marginnote} +\usepackage{tabularx} +\usepackage[noparboxrestore]{marginnote} \reversemarginpar \usepackage{tikz} \usetikzlibrary{positioning} @@ -31,6 +33,7 @@ \divide\parsep by 2\relax} \makeatother \title{The \pkg{tagpdf} package, v\csname UlrikeFischer@package@version\endcsname} +\date{\csname UlrikeFischer@package@date\endcsname} \author{Ulrike Fischer\thanks{fischer@troubleshooting-tex.de}} \usepackage{listings} \lstset{basicstyle=\ttfamily, columns=fullflexible,language=[LaTeX]TeX} @@ -44,7 +47,7 @@ \begin{tcolorbox}[colframe=red] This package is not meant for normal document production. -You need a current expl3 version to use it. +You need a current expl3 version to use it, you even need the (experimental) \texttt{l3str-convert}. This package is incomplete, experimental and quite probably contains bugs. @@ -136,6 +139,11 @@ Feedback, contribuations and corrections are welcome! All examples should use the tagpdfsetup key \PrintKeyName{uncompress} described in the next section so that uncompressed pdf are created and the internal objects and structures can be inspected and -- hopefully soon -- be compared by the l3build checks. +\subsection{Changes in 0.3} + +In this version I improved the handling of alternative and actual text. See section~\ref{sec:alttext}. This change means that the package now relies on the experimental expl3 package \texttt{l3str-convert}. + +I no longer try to (pdf-)escape the tag names: it is a bit unclear how to do it at best with luatex. This will perhaps later change again. \section{Setup} @@ -171,6 +179,7 @@ The key-val list understands the following keys: \item[\PrintKeyName{add-new-tag}] See section \ref{sec:new-tag} for a description. \item[\PrintKeyName{check-tags}] Boolean, initially true. Activates some safety checks (but doesn't very much currently. It will perhaps be merged with the log-level key). \item[\PrintKeyName{compresslevel}] Value is an integer between 0 and 9. It sets both the pdfcompresslevel and the pdfobjcompresslevel. +\item[\PrintKeyName{inputencoding}] Some keys convert their value and so need to know the encoding of the file. The default encoding is utf8. When using pdflatex you can switch to another encoding with this key. The value should be one of names allowed by \texttt{l3str}. There is no checking that the name is valid (I don't think that it sensible to use something else than utf8). \item[\PrintKeyName{log}] Choice key, possible values \PrintKeyName{none}, \PrintKeyName{v}, \PrintKeyName{vv}, \PrintKeyName{vvv}, \PrintKeyName{all}. Setups the log level. Changing the value affects currently mostly the luamode: \enquote{higher} values gives more messages in the log. The current levels and messages have been setup in a quite ad-hoc manner and will need improvement. \item[\PrintKeyName{tabsorder}] Choice key, possible values are \PrintKeyName{row}, \PrintKeyName{column}, \PrintKeyName{structure}, \PrintKeyName{none}. This decides if a \verb+/Tabs+ value is written to the dictionary of the page objects. Not really needed for tagging itself, but one of the things you probably need for accessibility checks. So I added it. Currently the tabsorder is the same for all pages. Perhaps this should be changed \ldots. \item[\PrintKeyName{tagunmarked}] Boolean,\marginnote{luamode} initially true. When this boolean is true, the lua code will try to mark everything that has not been marked yet as an artifact. The benefit is that one doesn't have to mark up every deco rule oneself. The danger is that it perhaps marks things that shouldn't be marked -- it hasn't been tested yet with complicated documents containing annotations etc. @@ -361,7 +370,8 @@ Such markers should not be nested. The command will warn you if this happens. The key-val list understands the following keys: \begin{description} - \item[\PrintKeyName{tag}] This is required, unless you use the \PrintKeyName{artifact} key. The value of the key is normally one of the standard type listed in section \ref{sec:new-tag}. It is possible to setup new tags, see the same section. + \item[\PrintKeyName{tag}] This is required, unless you use the \PrintKeyName{artifact} key. The value of the key is normally one of the standard type listed in section \ref{sec:new-tag}. It is possible to setup new tags, see the same section. The value of the key is expanded, so it can be a command. The expansion is passed unchanged to the pdf, so it should with a starting slash give a valid pdf name (some ascii with numbers like \texttt{H4} is fine). + \item[\PrintKeyName{artifact}] This will setup the marked content as an artifact. The key should be used for content that should be ignored. The key can take one of the values \PrintKeyName{pagination}, \PrintKeyName{layout}, \PrintKeyName{page}, \PrintKeyName{background} and \PrintKeyName{notype} (this is the default). Text in the header and footer should be marked with \PrintKeyName{artifact=pagination}. It is not quite clear if rules and other decorative graphical objects needs to be marked up as artifacts. Acrobat seems not to mind if not, but PAC~3 complained. @@ -374,6 +384,28 @@ The key-val list understands the following keys: \item[\PrintKeyName{label}] This key sets a label by which you can call the marked content later in another structure (if it has been stashed with the previous key). Internally the label name will start with \texttt{tagpdf-}. + \item[\PrintKeyName]{alttext}] This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded. + + \item[\PrintKeyName]{alttext-o} This key inserts an \texttt{/Alt} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName]{alttext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you do something like this: + + \begin{lstlisting} + \newcommand\myalttext{\frac{a}{b}} + \tagmcbegin{tag=P,alttext-o=\myalttext} + \end{lstlisting} + + and it will insert \verb+\frac{a}{b}+ (hex encoded) in the pdf. + + \item[\PrintKeyName]{actualtext}] This key inserts an \texttt{/ActualText} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded. + + \item[\PrintKeyName]{actualtext-o} This key inserts an \texttt{/ActualText} value in the property dictionary of the BDC operator. See section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName]{actualtext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you do something like this: + + \begin{lstlisting} + \newcommand\myactualtext{X} + \tagmcbegin{tag=P,alttext-o=\myactualtext} + \end{lstlisting} + + and it will insert \verb+X+ (hex encoded) in the pdf. + \item[\PrintKeyName{raw}] This key allows you to add more entries to the properties dictionary. The value must be correct, low-level pdf. E.g. \verb+raw=/Alt (Hello)+ will insert an alternative Text. (I will probably add keys for \texttt{/Alt} and \texttt{/Actualtext} later, but I haven't made up my mind regarding the encoding yes). \end{description} @@ -426,6 +458,8 @@ If this is really the way to go one would need some script to add the mark-up as But I'm not sure that this is the best way to do math. It looks rather odd that a document should have to tell a screen reader in such detail how to read an equation. It would be much more efficient, sensible and flexible if a complete representation of the equation in mathML could be stored in the pdf and the task how to read this aloud delegated to the screen reader. More investigations are needed here. +See also section~\ref{sec:alttext} for some more remarks and tests. + \subsubsection{Split paragraphs}\label{sec:splitpara} A\marginnote{Generic mode only} problem are paragraphs with page breaks. As already mentioned the end marker \texttt{EMC} must be added on the same page as the begin marker. But it is in pdflatex \emph{very} difficult to inject something at the page break automatically. One can manipulate the shipout box to some extend in the output routine, but this is not easy and it gets even more difficult if inserts like footnotes and floats are involved: the end of the paragraph is then somewhere in the middle of the box. @@ -503,7 +537,31 @@ The key-val list understands the following keys: \item[\PrintKeyName{tag}] This is required. The value of the key is normally one of the standard type listed in section \ref{sec:new-tag}. It is possible to setup new tags/types, see the same section. \item[\PrintKeyName{stash}] Normally a new structure inserts itself as a kid into the currently active structure. This key prohibits this. The structure is nevertheless from now on \enquote{the current active structure} and parent for following marked content and structures. \item[\PrintKeyName{label}] This key sets a label by which you can use the structure later in another structure. Internally the label name will start with \texttt{tagpdfstruct-}. - \item[\PrintKeyName{title},\PrintKeyName{alttext},\PrintKeyName{actualtext}] These keys allow to set the dictionary entries \texttt{/Title}, \texttt{/Alt} and \texttt{/Actualtext}. But I haven't yet decided which is the suitable format for the values, so currently you must ensure yourself that the values lead to valid pdf content. + \item[\PrintKeyName{alttext}] This key inserts an \texttt{/Alt} value in the dictionary of structure object. See section~\ref{sec:alttext}. The value is handled as verbatim string and hex encoded. + + \item[\PrintKeyName{alttext-o}] This key inserts an \texttt{/Alt} value in the dictionary of structure object. See section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName]{alttext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you do something like this: + + \begin{lstlisting} + \newcommand\myalttext{\frac{a}{b}} + \tagstructbegin{tag=P,alttext-o=\myalttext} + \end{lstlisting} + + and it will insert \verb+\frac{a}{b}+ (hex encoded) in the pdf. + + \item[\PrintKeyName{actualtext}] This key inserts an \texttt{/ActualText} value in the dictionary of structure object. See section~\ref{sec:alttext}. The value is handled as verbatim string, commands are not expanded. + + \item[\PrintKeyName{actualtext-o}] This key inserts an \texttt{/ActualText} value in the dictionary of structure object. See section~\ref{sec:alttext}. The value is handled as verbatim string like the key \PrintKeyName]{actualtext} but expanded once (the \texttt{o} refers to the \texttt{o} type in expl3). That means that you do something like this: + + \begin{lstlisting} + \newcommand\myactualtext{X} + \tagstructbegin{tag=P,alttext-o=\myactualtext} + \end{lstlisting} + + and it will insert \verb+X+ (hex encoded) in the pdf. + \item[\PrintKeyName{title}] This key allows to set the dictionary entry \texttt{/Title} in the structure object. + The value is handled as verbatim string and hex encoded. Commands are not expanded. + \item[\PrintKeyName{title-o}] This key allows to set the dictionary entry \texttt{/Title} in the structure object. + The value is expanded once and then handled as verbatim string like the \PrintKeyName{title} key. \end{description} @@ -588,10 +646,31 @@ The following shows the marking need for a section, a sentence and a list with t \tagstructend %Sect \tagstructend %Document -\tagfinish \end{document} \end{lstlisting} +\section{Alternative text, ActualText and text-to-speech software}\label{sec:alttext} + +The pdf format allows to add alternative text through the \PrintKeyName{/Alt} and the \PrintKeyName{/ActualText} key\footnote{There is also the \PrintKeyName{/E} key for acronyms but I will ignore it for now}. Both can be added either to the marked content in the page stream or to the object describing the structure. + +The value of \PrintKeyName{/ActualText} (inserted by \texttt{tagpdf} with \PrintKeyName{actualtext}) is meant to replace single characters or rather small pieces of text. It can be used also without any tagging (e.g. with the package accsupp). If the pdf reader support this (adobe reader does, sumatra not) one can change with it how a piece of text is copied and pasted e.g. to split up a ligature. + +\PrintKeyName{/Alt} (inserted by \texttt{tagpdf} with \PrintKeyName{alttext}) is a key to improve accessibility: with it one can add to a picture or something else an alternative text. + +The file \texttt{ex-alt-actualtext.tex} shows some experiments I made with with both keys and text-to-speech software (the in-built of adobe and nvda). +To sum them up: + +\begin{itemize} +\item The keys have an impact on text-to-speech software only if the document is fully tagged. +\item \PrintKeyName{/ActualText} should be at best used around short pieces of marked content. +\item \PrintKeyName{/Alt} is used at best with a structure -- this avoids problems with luatex where marked contents blocks can be split over pages. +\item To some extend one can get a not so bad reading of math with the alternative text. +\end{itemize} + + + + + \section{Standard type and new tags}\label{sec:new-tag} @@ -624,7 +703,7 @@ New tags can be defined in the setup command with the key \texttt{add-new-tag}. and perhaps some\verb+\pdfglyphtounicode+ commands. \item Hard and soft hyphen must be distinct. \item Spaces between words should be space glyphs and not only a horizontal movement. - \item Various small infos must be present in the catalog dictionary, info dictionary and the page dictionaries, e.g. metadata like title. + \item Various small infos must be present in the catalog dictionary, info dictionary and the page dictionaries, e.g. metadata like title. \end{itemize} If suitable I will add code for this tasks to this packages. But some of them can also be done already with existing packages like hyperref, hyperxmp, pdfx. diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty index 107dcb3ab80..cd0ee0d70ab 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-checks-code.sty @@ -1,37 +1,37 @@ -\ProvidesExplPackage {tagpdf-checks-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-checks-code} {2018/08/06} {0.3} {part of tagpdf - code related to checks and messages} %messages % mc -\msg_new:nnn { tagpdf } { mc-nested } { nested~marked~content~found~-~mcid~#1 } -\msg_new:nnn { tagpdf } { mc-tag-missing } { required~tag~missing~-~mcid~#1 } -\msg_new:nnn { tagpdf } { mc-label-unknown }{ label~#1~unknown~-~rerun } -\msg_new:nnn { tagpdf } { mc-used-twice } { mc~#1~has~been~already~used } -\msg_new:nnn { tagpdf } { mc-not-open } { there~is~no~mc~to~end~at~#1 } +\msg_new:nnn {uftag} {mc-nested} { nested~marked~content~found~-~mcid~#1 } +\msg_new:nnn {uftag} {mc-tag-missing} { required~tag~missing~-~mcid~#1 } +\msg_new:nnn {uftag} {mc-label-unknown} { label~#1~unknown~-~rerun } +\msg_new:nnn {uftag} {mc-used-twice} { mc~#1~has~been~already~used } +\msg_new:nnn {uftag} {mc-not-open} { there~is~no~mc~to~end~at~#1 } % structures -\msg_new:nnn { tagpdf } { struct-no-objnum } { objnum~missing~for~structure~#1 } -\msg_new:nnn { tagpdf } { struct-faulty-nesting } { there~is~no~open~structure~on~the~stack } -\msg_new:nnn { tagpdf } { struct-missing-tag } { a~structure~must~have~a~tag! } -\msg_new:nnn { tagpdf } { struct-show-closing } { closing~structure~#1~tagged~\prop_item:cn{g__uftag_struct_#1_prop}{S} } -\msg_new:nnn { tagpdf } { struct-used-twice} { structure~with~label~#1~has~already~been~used} -\msg_new:nnn { tagpdf } { struct-label-unknown} { structure~with~label~#1~is~unknown~rerun} +\msg_new:nnn {uftag} {struct-no-objnum} { objnum~missing~for~structure~#1 } +\msg_new:nnn {uftag} {struct-faulty-nesting} { there~is~no~open~structure~on~the~stack } +\msg_new:nnn {uftag} {struct-missing-tag} { a~structure~must~have~a~tag! } +\msg_new:nnn {uftag} {struct-show-closing} { closing~structure~#1~tagged~\prop_item:cn{g__uftag_struct_#1_prop}{S} } +\msg_new:nnn {uftag} {struct-used-twice} { structure~with~label~#1~has~already~been~used} +\msg_new:nnn {uftag} {struct-label-unknown} { structure~with~label~#1~is~unknown~rerun} %Roles -\msg_new:nnn { tagpdf } { role-missing } { tag~#1~has~no~role~assigned } -\msg_new:nnn { tagpdf } { role-unknown } { role~#1~is~not~known } -\msg_new:nnn { tagpdf } { role-unknown-tag } { tag~#1~is~not~known } -\msg_new:nnn { tagpdf } { role-new-tag } { adding~new~tag~#1~mapped~to~role~#2 } +\msg_new:nnn {uftag} {role-missing} { tag~#1~has~no~role~assigned } +\msg_new:nnn {uftag} {role-unknown} { role~#1~is~not~known } +\msg_new:nnn {uftag} {role-unknown-tag} { tag~#1~is~not~known } +\msg_new:nnn {uftag} {role-new-tag} { adding~new~tag~#1~mapped~to~role~#2 } % trees -\msg_new:nnn { tagpdf } {tree-mcid-index-wrong } {something~is~wrong~with~the~mcid} +\msg_new:nnn {uftag} {tree-mcid-index-wrong} {something~is~wrong~with~the~mcid} % obj -\msg_new:nnn { tagpdf } {obj-write-num } {write~obj~#1~to~pdf} +\msg_new:nnn {uftag} {obj-write-num} {write~obj~#1~to~pdf} %checks @@ -42,28 +42,28 @@ \prop_if_in:cnF { g__uftag_struct_#1_prop } {S} { - \msg_error:nn { tagpdf }{ struct-missing-tag } + \msg_error:nn {uftag} {struct-missing-tag} } } \cs_new:Nn \__uftag_check_structure_tag:N { - \prop_if_in:NoF \g__uftag_role_tags_prop { #1 } + \prop_if_in:NoF \g__uftag_role_tags_prop {#1} { - \msg_warning:nnx {tagpdf}{role-unknown-tag} { #1 } + \msg_warning:nnx {uftag} {role-unknown-tag} {#1} } } \cs_new:Nn \__uftag_check_info_closing_struct:n %#1 struct num { - \msg_info:nnn {tagpdf}{struct-show-closing}{#1} + \msg_info:nnn {uftag} {struct-show-closing} {#1} } \cs_generate_variant:Nn \__uftag_check_info_closing_struct:n {o,x} \cs_new:Nn \__uftag_check_no_open_struck: { - \msg_error:nn {tagpdf}{ struct-faulty-nesting } + \msg_error:nn {uftag} {struct-faulty-nesting} } \cs_new:Nn \__uftag_check_struct_used:n %#1 label @@ -72,24 +72,24 @@ {g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop} {P} \l_tmpa_tl - {\msg_warning:nnn {tagpdf}{struct-used-twice}{#1}} + { \msg_warning:nnn {uftag} {struct-used-twice} {#1} } } %roles \cs_new:Nn \__uftag_check_add_tag_role:nn %#1 tag, #2 role { - \tl_if_empty:nTF { #2 } + \tl_if_empty:nTF {#2} { - \msg_warning:nnn { tagpdf }{ role-missing } { #1 } + \msg_warning:nnn {uftag} {role-missing} {#1} } { - \prop_get:NnNF \g__uftag_role_tags_prop { #2 } \l_tmpa_tl + \prop_get:NnNF \g__uftag_role_tags_prop {#2} \l_tmpa_tl { - \msg_warning:nnn { tagpdf }{ role-unknown } { #2 } + \msg_warning:nnn {uftag} {role-unknown} {#2} } { - \msg_info:nnnn { tagpdf }{ role-new-tag } { #1 }{ #2 } + \msg_info:nnnn {uftag} {role-new-tag} {#1} {#2} } } } @@ -99,7 +99,7 @@ { \_uftag_mc_if_in:T { - \msg_warning:nnx {tagpdf}{mc-nested}{ \__uftag_get_mc_abs_cnt: } + \msg_warning:nnx {uftag} {mc-nested} { \__uftag_get_mc_abs_cnt: } } } @@ -107,7 +107,7 @@ { \_uftag_mc_if_in:F { - \msg_warning:nnx {tagpdf}{mc-not-open}{ \__uftag_get_mc_abs_cnt: } + \msg_warning:nnx {uftag} {mc-not-open} { \__uftag_get_mc_abs_cnt: } } } @@ -115,23 +115,23 @@ { \tl_if_empty:NT #1 { - \msg_error:nnx {tagpdf}{mc-tag-missing}{ \__uftag_get_mc_abs_cnt: } + \msg_error:nnx {uftag} {mc-tag-missing} { \__uftag_get_mc_abs_cnt: } } - \prop_if_in:NoF \g__uftag_role_tags_prop { #1 } + \prop_if_in:NoF \g__uftag_role_tags_prop {#1} { - \msg_warning:nnx {tagpdf}{role-unknown-tag} { #1 } + \msg_warning:nnx {uftag} {role-unknown-tag} {#1} } } \seq_new:N \g__uftag_check_mc_used_seq \cs_new:Nn \__uftag_check_mc_used:n { - \seq_if_in:NnTF \g__uftag_check_mc_used_seq { #1 } + \seq_if_in:NnTF \g__uftag_check_mc_used_seq {#1} { - \msg_warning:nnn {tagpdf}{mc-used-twice}{ #1 } + \msg_warning:nnn {uftag} {mc-used-twice} {#1} } { - \seq_gput_right:Nx\g__uftag_check_mc_used_seq { #1 } + \seq_gput_right:Nx \g__uftag_check_mc_used_seq {#1} } } @@ -174,11 +174,11 @@ } } -\cs_new:Nn\__uftag_check_record_pdfobj_num:n +\cs_new:Nn \__uftag_check_record_pdfobj_num:n { - \int_compare:nT {\l__uftag_loglevel_int >= 3 } + \int_compare:nT { \l__uftag_loglevel_int >= 3 } { - \msg_info:nnx { tagpdf }{obj-write-num}{#1} + \msg_info:nnx {uftag} {obj-write-num} {#1} } } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def index 4590d0cc21f..cee2e931e9a 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-luatex.def @@ -1,4 +1,4 @@ -\ProvidesExplFile {tagpdf-luatex.def} {2018/07/09} {0.2} +\ProvidesExplFile {tagpdf-luatex.def} {2018/08/06} {0.3} {tagpdf driver for luatex} \newattribute \g__uftag_mc_type_attr %the value represent the type @@ -10,6 +10,12 @@ %%%% driver (lualatex) commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% needed for \str_set_convert:Nnon +\tl_new:N \g__uftag_inputencoding_tl +\tl_gset:Nn \g__uftag_inputencoding_tl {} + + +% literals \cs_new:Nn \__uftag_pdfliteral_page:n {\__uftag_tex_pdfextension:D literal~page {#1}} \cs_new:Nn \__uftag_pdfcatalog:n {\__uftag_tex_pdfextension:D catalog {#1}} diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty index 29309cfba33..b8839782ca1 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-generic.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-mc-code-generic} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-mc-code-generic} {2018/08/06} {0.3} {part of tagpdf - code related to marking chunks - generic mode} % for the label system @@ -7,7 +7,7 @@ \int_new:N \g__uftag_MCID_tmp_bypage_int \zref@newprop {tagmcid} [0] { \int_use:N \g__uftag_MCID_tmp_bypage_int } -\zref@addprop {tagpdf} {tagmcid} +\zref@addprop {uftagzrl} {tagmcid} % will hold the current maximum on a page % it will contain key-value of type "abspagenum=max mcid on this page" @@ -18,12 +18,13 @@ % they insert literals and so a are specific to generic mode % checking if the type is defined will done somewhere else % #1 is the type/tag +% change 04.08.2018: I don't try to escape the name, but assume that it is valid. +% Checks/conversions should perhaps be done on a higher level \cs_new:Nn \__uftag_mc_bmc:n { - \__uftag_pdf_escape_name:Nn\l_uttag_tmpa_tl { #1 } \__uftag_pdfliteral_page:n { - /\l_uttag_tmpa_tl\c_space_tl BMC + /#1\c_space_tl BMC } } @@ -36,14 +37,13 @@ } % #1 tag, #2 properties -% I escape the name. But the dictionary content +% change 04.08.2018: I don't escape the name. Also the dictionary content % must imho be done at a higher level \cs_new:Nn \__uftag_mc_bdc:nn { - \__uftag_pdf_escape_name:Nn\l_uttag_tmpa_tl { #1 } \__uftag_pdfliteral_page:n { - /\l_uttag_tmpa_tl\c_space_tl<<#2>>~BDC + /#1\c_space_tl<<#2>>~BDC } } @@ -92,16 +92,16 @@ { mcid-\int_use:N \c@g__uftag_MCID_abs_int } - {tagpdf} + {uftagzrl} \__uftag_mc_bdc:nn - { #1 } + {#1} { /MCID~\int_eval:n { \g__uftag_MCID_tmp_bypage_int }~#2 } } % only /MCID \cs_new:Nn \__uftag_mc_bdc_mcid:n { - \__uftag_mc_bdc_mcid:nn { #1 } {} + \__uftag_mc_bdc_mcid:nn {#1} {} } %artifact without type @@ -122,42 +122,88 @@ % keyval definitions for the user commands: \tl_new:N \l__uftag_mc_key_tag_tl - +\tl_new:N \l__uftag_mc_key_properties_tl %Attention! definitions are different in luamode. -\keys_define:nn { tagpdf / mc } -{ - tag .code:n = % the name (H,P,Span etc - { - \__uftag_pdf_escape_name:Nn \l__uftag_mc_key_tag_tl { #1 } - }, - raw .tl_set:N = \l__uftag_mc_key_properties_tl, - label .tl_set:N = \l__uftag_mc_key_label_tl, - artifact .meta:n = { artifact-bool, artifact-type=#1 }, - artifact .default:n = {notype} -} +% tag and raw are expanded as \directlua in lua does it too. +\keys_define:nn { uftag / mc } + { + tag .code:n = % the name (H,P,Span etc + { + %%????????? \pdfescapename?? + \tl_set:Nx \l__uftag_mc_key_tag_tl { #1 } + }, + raw .code:n = + { + \tl_put_right:Nx \l__uftag_mc_key_properties_tl { #1 } + } + , + alttext .code:n = % Alt property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + alttext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + actualtext .code:n = % ActualText property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /ActualText~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + actualtext-o .code:n = % ActualText property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /ActualText~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + }, + label .tl_set:N = \l__uftag_mc_key_label_tl, + artifact .code:n = { \exp_args:Nnx \keys_set:nn { uftag / mc } { artifact-bool, artifact-type=#1 } }, + artifact .default:n = {notype} + } \cs_new:Nn \__uftag_mc_handle_artifact:N %#1 contains the artifact type { \tl_if_empty:NTF #1 { \__uftag_mc_bmc_artifact: } - { \exp_args:No\__uftag_mc_bmc_artifact:n { #1 } } + { \exp_args:No\__uftag_mc_bmc_artifact:n {#1} } } \cs_new:Nn \__uftag_mc_handle_mcid:nn %#1 tag, #2 properties { - \__uftag_mc_bdc_mcid:nn { #1 }{ #2 } + \__uftag_mc_bdc_mcid:nn {#1} {#2} } % puts the absolute number of an mcid in the current structure \cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum { - \__uftag_check_mc_used:n { #1 } + \__uftag_check_mc_used:n {#1} \__uftag_struct_kid_mc_gput_right:nn { \g__uftag_struct_stack_current_tl } - { #1 } + {#1} \prop_gput:Nxx \g__uftag_mc_parenttree_prop - { #1 } + {#1} { \g__uftag_struct_stack_current_tl } } @@ -166,7 +212,7 @@ \group_begin: \__uftag_check_mc_if_nested: \bool_gset_true:N \g__uftag_in_mc_bool - \keys_set:nn { tagpdf / mc }{ #1 } + \keys_set:nn { uftag / mc } {#1} \bool_if:NTF \l__uftag_mc_artifact_bool { %handle artifact \__uftag_mc_handle_artifact:N \l__uftag_mc_artifact_type_tl @@ -186,25 +232,25 @@ \group_end: } -\cs_new:Nn\uftag_mc_end: +\cs_new:Nn \uftag_mc_end: { \__uftag_check_mc_if_open: \bool_gset_false:N \g__uftag_in_mc_bool \__uftag_mc_emc: } -\cs_new:Nn\uftag_mc_use:n %#1: label name +\cs_new:Nn \uftag_mc_use:n %#1: label name { \tl_set:Nx \l_tmpa_tl { \zref@extractdefault{tagpdf-#1}{tagmcabs}{} } \tl_if_empty:NTF\l_tmpa_tl { - \msg_warning:nnn {tagpdf} {mc-label-unknown} { #1 } + \msg_warning:nnn {uftag} {mc-label-unknown} {#1} } { \prop_gput:Nxx \g__uftag_mc_parenttree_prop { - \zref@extractdefault{tagpdf-#1}{tagmcabs}{} + \zref@extractdefault {tagpdf-#1} {tagmcabs} {} } { \g__uftag_struct_stack_current_tl @@ -214,7 +260,7 @@ \g__uftag_struct_stack_current_tl } { - \zref@extractdefault{tagpdf-#1}{tagmcabs}{} + \zref@extractdefault {tagpdf-#1} {tagmcabs} {} } } } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty index 3b252c59739..eeee1bd80a8 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-lua.sty @@ -1,14 +1,14 @@ -\ProvidesExplPackage {tagpdf-mc-code-lua} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-mc-code-lua} {2018/08/06} {0.3} {tagpdf - mc code only for the luamode } -%the two attibutes are defined in the driver file. -%it also load the lua (as it can also contain functions needed by generic mode. -%\newattribute \g__uftag_mc_type_attr %the value represent the type -%\newattribute \g__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value +% the two attibutes are defined in the driver file. +% it also load the lua (as it can also contain functions needed by generic mode. +% \newattribute \g__uftag_mc_type_attr %the value represent the type +% \newattribute \g__uftag_mc_cnt_attr %will hold the \c@g__uftag_MCID_abs_int value -%An attribute for the current structure probably doesn't make sense as mc chunks can be used later. -%\newattribute \g__uftag_struct_type_attr %represent the current structure type. Not sure if needed -%\newattribute \g__uftag_struct_cnt_attr %will hold \c@g__uftag_struct_abs_int a cnt +% An attribute for the current structure probably doesn't make sense as mc chunks can be used later. +% \newattribute \g__uftag_struct_type_attr %represent the current structure type. Not sure if needed +% \newattribute \g__uftag_struct_cnt_attr %will hold \c@g__uftag_struct_abs_int a cnt % handling attribute needs a different system to number the page wise mcid's: % a tagmcbegin ... tagmcend pair no longer surrounds exactly one mc chunk: it can be split @@ -30,82 +30,152 @@ % The main function which wanders through the shipout box to inject the literals. \AtBeginDocument -{ - \bool_if:NT\g_uftag_active_mc_bool { - \AtBeginShipout - { - \directlua{uftag.func.mark_shipout ()} - } + \bool_if:NT\g_uftag_active_mc_bool + { + \AtBeginShipout + { + \directlua{uftag.func.mark_shipout ()} + } + } } -} % the keys \tl_new:N \l__uftag_mc_key_tag_tl \tl_new:N \l__uftag_mc_key_label_tl \tl_new:N \l__uftag_mc_key_properties_tl -\keys_define:nn { tagpdf / mc } -{ - tag .code:n = % - { - \__uftag_pdf_escape_name:Nn \l__uftag_mc_key_tag_tl { #1 } - \directlua - { - uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"tag","#1") - } - }, - raw .code:n = - { - \tl_set:Nn\l__uftag_mc_key_properties_tl { #1 } - \directlua +\keys_define:nn { uftag / mc } + { + tag .code:n = % + {%%????????? \pdfescapename?? + \tl_set:Nx \l__uftag_mc_key_tag_tl { #1 } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"tag","#1") + } + }, + raw .code:n = + { + \tl_put_right:Nx \l__uftag_mc_key_properties_tl { #1 } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"raw","#1") + } + }, + alttext .code:n = % Alt property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__uftag_tmpa_str>") + } + }, + alttext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"alt","/Alt~<\str_use:N \l__uftag_tmpa_str>") + } + }, + actualtext .code:n = % Alt property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__uftag_tmpa_str>") + } + }, + actualtext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \tl_put_right:Nn \l__uftag_mc_key_properties_tl { /Alt~< } + \tl_put_right:No \l__uftag_mc_key_properties_tl { \l__uftag_tmpa_str>~ } + \directlua + { + uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"actualtext","/ActualText~<\str_use:N \l__uftag_tmpa_str>") + } + }, + label .code:n = + { + \tl_set:Nn\l__uftag_mc_key_label_tl { #1 } + \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"label","#1")} + }, + __artifact-store .code:n = + { + \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"artifact","#1")} + }, + artifact .code:n = { - uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"raw","#1") - } - }, - label .code:n = - { - \tl_set:Nn\l__uftag_mc_key_label_tl { #1 } - \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"label","#1")} - }, - __artifact-store .code:n = - { - \directlua {uftag.func.store_mc_data(\__uftag_get_mc_abs_cnt:,"artifact","#1")} - }, - artifact .meta:n = { artifact-bool, artifact-type=#1,__artifact-store=#1, tag=Artifact }, - artifact .default:n = { notype } -} + \exp_args:Nnx \keys_set:nn {uftag / mc} { artifact-bool, artifact-type=#1, tag=Artifact } + \exp_args:Nnx \keys_set:nn {uftag / mc }{ __artifact-store=\l__uftag_mc_artifact_type_tl } + }, + artifact .default:n = { notype } + } % attributes % set the mc from a tag name +\cs_set_protected:Npn \__uftag_attribute_gset:Nn #1 #2 + { + \tex_global:D \setattribute #1 #2 + } + +\cs_set_protected:Npn \__uftag_attribute_gunset:N #1 + { + \tex_global:D \unsetattribute #1 + } + \cs_new:Nn \__uftag_mc_lua_gset_mc_type_attr:n % #1 is a tag name { - \global\setattribute \g__uftag_mc_type_attr { \directlua {uftag.func.output_num_from ("#1") } } - \global\setattribute \g__uftag_mc_cnt_attr { \__uftag_get_mc_abs_cnt: } + \__uftag_attribute_gset:Nn \g__uftag_mc_type_attr { \directlua {uftag.func.output_num_from ("#1") } } + \__uftag_attribute_gset:Nn \g__uftag_mc_cnt_attr { \__uftag_get_mc_abs_cnt: } } \cs_generate_variant:Nn\__uftag_mc_lua_gset_mc_type_attr:n { o } \cs_new:Nn \__uftag_mc_lua_gunset_mc_type_attr: { - \global\unsetattribute \g__uftag_mc_type_attr - \global\unsetattribute \g__uftag_mc_cnt_attr + \__uftag_attribute_gunset:N \g__uftag_mc_type_attr + \__uftag_attribute_gunset:N \g__uftag_mc_cnt_attr } %This command will in the finish code replace the dummy for a mc by the real mcid kids \cs_new:Nn \__uftag_mc_insert_mcid_kids:n - { - \directlua {uftag.func.mc_insert_kids (#1) } - } + { + \directlua {uftag.func.mc_insert_kids (#1) } + } % puts an mcid absolute number in the current structure \cs_new:Nn \__uftag_mc_handle_stash:n %1 mcidnum { \__uftag_check_mc_used:n { #1 } - \seq_gput_right:cn % Don't fill a lua table due to the command in the item, so the kernel command + \seq_gput_right:cn % Don't fill a lua table due to the command in the item, so the kernel command { g__uftag_struct_kids_\g__uftag_struct_stack_current_tl _seq } { \__uftag_mc_insert_mcid_kids:n {#1} @@ -128,7 +198,7 @@ \__uftag_check_mc_if_nested: \bool_gset_true:N \g__uftag_in_mc_bool \int_gincr:N \c@g__uftag_MCID_abs_int - \keys_set:nn { tagpdf / mc }{ label={}, #1 } + \keys_set:nn { uftag / mc }{ label={}, #1 } %check that a tag or artifact has been used \__uftag_check_mc_tag:N \l__uftag_mc_key_tag_tl %set the attributes (is done globally!): @@ -148,19 +218,19 @@ \group_end: } -\cs_new:Nn\uftag_mc_end: +\cs_new:Nn \uftag_mc_end: { \__uftag_check_mc_if_open: \bool_gset_false:N \g__uftag_in_mc_bool \__uftag_mc_lua_gunset_mc_type_attr: } -\cs_new:Nn\uftag_mc_use:n %#1: label name +\cs_new:Nn \uftag_mc_use:n %#1: label name { \tl_set:Nx \l_tmpa_tl { \zref@extractdefault{tagpdf-#1}{tagmcabs}{} } \tl_if_empty:NTF\l_tmpa_tl { - \msg_warning:nnn {tagpdf} {mc-label-unknown} { #1 } + \msg_warning:nnn {uftag} {mc-label-unknown} { #1 } } { \__uftag_mc_handle_stash:o { \l_tmpa_tl } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty index 8c5013ec0a3..173967b945d 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-mc-code-shared.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-mc-code-shared} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-mc-code-shared} {2018/08/06} {0.3} {part of tagpdf - code related to marking chunks - code shared by generic and luamode } % I use a latex counter for the absolute count, so that it is added to @@ -9,18 +9,18 @@ % the absolute counter can be used to label and to check if the page % counter needs a reset. -\newcounter { g__uftag_MCID_abs_int } -\cs_new:Nn \__uftag_get_mc_abs_cnt: { \int_use:N \c@g__uftag_MCID_abs_int } +\newcounter { g__uftag_MCID_abs_int } +\cs_new:Nn \__uftag_get_mc_abs_cnt: { \int_use:N \c@g__uftag_MCID_abs_int } % tagmcabs is the label name of the absolute count which is used to identify the chunk \zref@newprop {tagmcabs} [0] { \int_use:N \c@g__uftag_MCID_abs_int } -\zref@addprop {tagpdf} {tagmcabs} +\zref@addprop {uftagzrl} {tagmcabs} \zref@addprop {LastPage} {tagmcabs} %stores labels of mcid. \cs_new:Nn \__uftag_mc_handle_mc_label:n { - \zref@labelbylist{tagpdf-#1}{tagpdf} + \zref@labelbylist{tagpdf-#1}{uftagzrl} } % will hold the structure numbers for the parenttree @@ -31,7 +31,7 @@ %to test nesting mc: \bool_new:N \g__uftag_in_mc_bool -\prg_new_conditional:Nnn \_uftag_mc_if_in: {p,T,F,TF} +\prg_new_conditional:Nnn \_uftag_mc_if_in: {p,T,F,TF} { \bool_if:NTF \g__uftag_in_mc_bool { \prg_return_true: } @@ -39,10 +39,10 @@ } %shared keys -%the rest are in the splitted code -\tl_new:N \l__uftag_mc_artifact_type_tl +%the rest are in the splitted code +\tl_new:N \l__uftag_mc_artifact_type_tl -\keys_define:nn { tagpdf / mc } +\keys_define:nn { uftag / mc } { stash .bool_set:N = \l__uftag_mc_key_stash_bool, artifact-bool .bool_set:N = \l__uftag_mc_artifact_bool, diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def index 61dc45b2a6b..af9382748e6 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-pdftex.def @@ -1,10 +1,15 @@ -\ProvidesExplFile {tagpdf-pdftex.def} {2018/07/09} {0.2} +\ProvidesExplFile {tagpdf-pdftex.def} {2018/08/06} {0.3} {tagpdf driver for pdftex} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% driver (pdflatex) commands %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% needed for \str_set_convert:Nnon +\tl_new:N \g__uftag_inputencoding_tl +\tl_gset:Nn \g__uftag_inputencoding_tl {utf8} + + %literal \cs_new:Nn \__uftag_pdfliteral_page:n { \__uftag_tex_pdfliteral:D page { #1} } \cs_new:Nn \__uftag_pdfcatalog:n { \__uftag_tex_pdfcatalog:D { #1 } } diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty index 93180cc8576..bd8c680f963 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-roles-code.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-roles-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-roles-code} {2018/08/06} {0.3} {part of tagpdf - code related to roles and structure names} \__uftag_seq_new:N \g__uftag_role_tags_seq %to get names from numbers @@ -107,7 +107,7 @@ \cs_generate_variant:Nn \__uftag_role_add_tag:nn {xx} -\keys_define:nn { tagpdf-setup } +\keys_define:nn { uftag / setup } { add-new-tag .code:n = { diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty index 3c92767a107..898f33a7115 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-struct-code.sty @@ -1,4 +1,4 @@ -\ProvidesExplPackage {tagpdf-struct-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-struct-code} {2018/08/06} {0.3} {part of tagpdf - code related to storing structure} % I will use a latex counter for the structure count @@ -9,8 +9,8 @@ \zref@newprop {tagstruct} [0] { \int_use:N \c@g__uftag_struct_abs_int } -\zref@newlist {tagpdfstruct} -\zref@addprop {tagpdfstruct}{tagstruct} +\zref@newlist {uftagzrlstruct} +\zref@addprop {uftagzrlstruct}{tagstruct} % a sequence stores structnum -> the obj numbers % to allow easy mapping over the structures @@ -243,19 +243,19 @@ } } { - \msg_error:nnn { tagpdf } { struct-no-objnum } { #1} + \msg_error:nnn {uftag} { struct-no-objnum } { #1} } } % keys for the user commands -% why did I call the submodule elem instead of struct? -\keys_define:nn { tagpdf / elem } +% should I pass the values (e.g. the tag) through an escape command? +\keys_define:nn { uftag / struct } { label .tl_set:N = \l__uftag_struct_key_label_tl, stash .bool_set:N = \l__uftag_struct_elem_stash_bool, tag .code:n = % S property - { - \__uftag_pdf_escape_name:Nn \l__uftag_tmpa_tl { #1 } + {%%????????? \pdfescapename?? + \tl_set:Nx \l__uftag_tmpa_tl { #1 } \bool_if:NT \g__uftag_check_tags_bool { \__uftag_check_structure_tag:N \l__uftag_tmpa_tl @@ -267,30 +267,75 @@ }, title .code:n = % T property { - \__uftag_pdf_escape_string:Nn \l__uftag_tmpa_tl { #1 } - \tl_put_left:Nn \l__uftag_tmpa_tl {(^^fe^^ff} - \__uftag_prop_gput:cno + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx + { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } + { T } + { <\l__uftag_tmpa_str> } + }, + title-o .code:n = % T property + { + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } { T } - { \l__uftag_tmpa_tl) } + { <\l__uftag_tmpa_str> } }, alttext .code:n = % Alt property { - \__uftag_pdf_escape_string:Nn \l__uftag_tmpa_tl { #1 } - \tl_put_left:Nn \l__uftag_tmpa_tl {(^^fe^^ff} - \__uftag_prop_gput:cno + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } { Alt } - { \l__uftag_tmpa_tl) } + { <\l__uftag_tmpa_str> } + }, + alttext-o .code:n = % Alt property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx + { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } + { Alt } + { <\l__uftag_tmpa_str> } }, actualtext .code:n = % ActualText property { - \__uftag_pdf_escape_hex:Nn \l__uftag_tmpa_tl {#1 } - \tl_put_left:Nn \l__uftag_tmpa_tl {<FEFF } - \__uftag_prop_gput:cno + \str_set_convert:Nnon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx + { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } + { ActualText } + { <\l__uftag_tmpa_str>} + }, + actualtext-o .code:n = % ActualText property + { + \str_set_convert:Noon + \l__uftag_tmpa_str + { #1 } + { \g__uftag_inputencoding_tl } + { utf16/hex } + \__uftag_prop_gput:cnx { g__uftag_struct_\int_eval:n {\c@g__uftag_struct_abs_int}_prop } { ActualText } - { \l__uftag_tmpa_tl>} + { <\l__uftag_tmpa_str>} }, } @@ -319,19 +364,19 @@ { g__uftag_struct_\int_eval:n { \c@g__uftag_struct_abs_int }_prop } { entries } { StructElem } - \keys_set:nn {tagpdf / elem} { #1 } + \keys_set:nn {uftag / struct} { #1 } \__uftag_check_structure_has_tag:n { \int_eval:n {\c@g__uftag_struct_abs_int} } \tl_if_empty:NF {\l__uftag_struct_key_label_tl} { - \zref@labelbylist{tagpdfstruct-\l__uftag_struct_key_label_tl}{tagpdfstruct} + \zref@labelbylist{tagpdfstruct-\l__uftag_struct_key_label_tl}{uftagzrlstruct} } %get the potential parent from the stack: \seq_get:NNF \g__uftag_struct_stack_seq \l__uftag_struct_stack_parent_tmp_tl { - \msg_error:nn { tagpdf } { struct-faulty-nesting } + \msg_error:nn { uftag } { struct-faulty-nesting } } \seq_gpush:NV \g__uftag_struct_stack_seq \c@g__uftag_struct_abs_int \tl_gset:NV \g__uftag_struct_stack_current_tl \c@g__uftag_struct_abs_int @@ -381,7 +426,7 @@ \cs_new:Nn \uftag_struct_use:n %#1 is the label { \prop_if_exist:cTF - { g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop } + { g__uftag_struct_\zref@extractdefault{tagpdfstruct-#1}{tagstruct}{unknown}_prop } %?????????? { \__uftag_check_struct_used:n {#1} %add the label structure as kid to the current structure (can be the root) @@ -396,7 +441,7 @@ \prop_item:cn { g__uftag_struct_\g__uftag_struct_stack_current_tl _prop} { objnum }~0~R } } - {\msg_warning:nnn{tagpdf}{struct-label-unknown}{#1}} + {\msg_warning:nnn{uftag}{struct-label-unknown}{#1}} } \endinput diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty index 2fd82d27f66..d30b82a004e 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-tree-code.sty @@ -1,14 +1,14 @@ -\ProvidesExplPackage {tagpdf-tree-code} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-tree-code} {2018/08/06} {0.3} {part of tagpdf - code related to writing trees and dictionaries to the pdf} %this does the actual finishing: \AtBeginDocument -{ - \bool_if:NT \g_uftag_active_tree_bool - { - \AfterEndDocument { \uftag_finish_structure: } - } -} + { + \bool_if:NT \g_uftag_active_tree_bool + { + \AfterEndDocument { \uftag_finish_structure: } + } + } % the StructTreeRoot @@ -18,10 +18,10 @@ \cs_new:Nn \__uftag_tree_write_structtreeroot: -{ - \__uftag_pdfcatalog:n { /StructTreeRoot~\c_uftag_tree_obj_structtreeroot_tl\c_space_tl0~R } - \__uftag_struct_write_obj:n { 0 } -} + { + \__uftag_pdfcatalog:n { /StructTreeRoot~\c_uftag_tree_obj_structtreeroot_tl\c_space_tl0~R } + \__uftag_struct_write_obj:n { 0 } + } \cs_new:Nn \__uftag_tree_write_structelements: { @@ -39,43 +39,43 @@ \tl_new:N \l__uftag_parenttree_content_tl \cs_new:Nn \__uftag_tree_fill_parenttree: -{ - \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{abspage}{-1}} %not quite clear if labels are needed. See lua code - { %page ##1\par - \prop_clear:N \l_tmpa_prop - \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{tagmcabs}{-1}} - { - %mcid####1 - \int_compare:nT%F - {\zref@extractdefault{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page - {% yes\par - \prop_put:Nxx \l_tmpa_prop - {\zref@extractdefault{mcid-####1}{tagmcid}{-1}} - {\prop_item:Nn \g__uftag_mc_parenttree_prop {####1}} - } - } - %\prop_show:N \l_tmpa_prop - \tl_put_right:Nx\l__uftag_parenttree_content_tl - {\int_eval:n {##1-1}\c_space_tl[\c_space_tl} %%brackt - \int_step_inline:nnnn {0}{1}{ \prop_map_function:NN \l_tmpa_prop\__uftag_prop_count:nn -1 } + { + \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{abspage}{-1}} %not quite clear if labels are needed. See lua code + { %page ##1\par + \prop_clear:N \l_tmpa_prop + \int_step_inline:nnnn{1}{1}{\zref@extractdefault{LastPage}{tagmcabs}{-1}} { - \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl - {% page#1:mcid##1:\l_tmpb_tl :content - \tl_put_right:Nx \l__uftag_parenttree_content_tl - { - \prop_item:cn { g__uftag_struct_\l_tmpb_tl _prop } {objnum}~0~R~ - } - } - {\msg_warning:nn {tagpdf} {tree-mcid-index-wrong} } + %mcid####1 + \int_compare:nT%F + {\zref@extractdefault{mcid-####1}{tagabspage}{-1}=##1} %mcid is on current page + {% yes\par + \prop_put:Nxx \l_tmpa_prop + {\zref@extractdefault{mcid-####1}{tagmcid}{-1}} + {\prop_item:Nn \g__uftag_mc_parenttree_prop {####1}} + } } - \tl_put_right:Nn\l__uftag_parenttree_content_tl{]^^J} % + %\prop_show:N \l_tmpa_prop + \tl_put_right:Nx\l__uftag_parenttree_content_tl + {\int_eval:n {##1-1}\c_space_tl[\c_space_tl} %%brackt + \int_step_inline:nnnn {0}{1}{ \prop_map_function:NN \l_tmpa_prop\__uftag_prop_count:nn -1 } + { + \prop_get:NnNTF \l_tmpa_prop {####1} \l_tmpb_tl + {% page#1:mcid##1:\l_tmpb_tl :content + \tl_put_right:Nx \l__uftag_parenttree_content_tl + { + \prop_item:cn { g__uftag_struct_\l_tmpb_tl _prop } {objnum}~0~R~ + } + } + {\msg_warning:nn {uftag} {tree-mcid-index-wrong} } + } + \tl_put_right:Nn \l__uftag_parenttree_content_tl {]^^J} % + } } -} %lua mode must/can do it differently \cs_new:Nn \__uftag_tree_lua_fill_parenttree: { - \tl_set:Nn\l__uftag_parenttree_content_tl + \tl_set:Nn \l__uftag_parenttree_content_tl { \directlua{uftag.func.output_parenttree(\int_use:N\g__uftag_abspage_int)} } @@ -136,12 +136,16 @@ %StructParents + tabs order. Tabs order should be probably be changeable by page. \cs_new:Nn \__uftag_tree_write_pageattr: -{ + { \__uftag_get_pdfpageattr:N \l_tmpa_tl \regex_replace_once:nnN {/StructParents\s*\d+} {}\l_tmpa_tl \regex_replace_once:nnN {/Tabs\s*/[SCR]} {}\l_tmpa_tl \__uftag_gset_pdfpageattr:x - {\l_tmpa_tl/StructParents\c_space_tl \int_eval:n{\g__uftag_abspage_int }\l__uftag_tree_tabs_order_tl} -} + { + \l_tmpa_tl / StructParents \c_space_tl + \int_eval:n { \g__uftag_abspage_int } + \l__uftag_tree_tabs_order_tl + } + } \endinput diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty index 137d636cc64..1b01e1521b6 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf-user.sty @@ -1,9 +1,9 @@ -\ProvidesExplPackage {tagpdf-user} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf-user} {2018/08/06} {0.3} {tagpdf - user commands} \NewDocumentCommand \tagpdfsetup { m } { - \keys_set:nn { tagpdf-setup } { #1 } + \keys_set:nn { uftag / setup } { #1 } } \cs_set_eq:NN\tagpdfifluatexTF \sys_if_engine_luatex:TF @@ -24,7 +24,8 @@ \NewDocumentCommand \tagmcend { } { - \unskip\uftag_mc_end: + \unskip % this unskip appears to mess up some spacing; can we do this in another way? + \uftag_mc_end: } \NewDocumentCommand \tagmcuse { m } @@ -54,34 +55,34 @@ %%%% debug/show commands \NewDocumentCommand\showtagpdfmcdata { O {\__uftag_get_mc_abs_cnt:} } -{ - \bool_if:NT \g__uftag_mode_lua_bool { - \sys_if_engine_luatex:T - { - \directlua{uftag.trace.show_all_mc_data(#1)} - } + \bool_if:NT \g__uftag_mode_lua_bool + { + \sys_if_engine_luatex:T + { + \directlua{uftag.trace.show_all_mc_data(#1)} + } + } } -} \NewDocumentCommand\showtagpdfattributes { } -{ - \bool_if:NT \g__uftag_mode_lua_bool { - \sys_if_engine_luatex:T - { - \directlua + \bool_if:NT \g__uftag_mode_lua_bool { - uftag.trace.log( - "showtagpdfattributes: MC=>abscnt=\__uftag_get_mc_abs_cnt:=>attr=\the\g__uftag_mc_cnt_attr=>tag=" .. - tostring(uftag.func.get_tag_from (\the\g__uftag_mc_type_attr)) .. - "=\the\g__uftag_mc_type_attr",0 - ) + \sys_if_engine_luatex:T + { + \directlua + { + uftag.trace.log( + "showtagpdfattributes: MC=>abscnt=\__uftag_get_mc_abs_cnt:=>attr=\the\g__uftag_mc_cnt_attr=>tag=" .. + tostring(uftag.func.get_tag_from (\the\g__uftag_mc_type_attr)) .. + "=\the\g__uftag_mc_type_attr",0 + ) + } + \ignorespaces + } } - \ignorespaces - } } -} diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua index ca49eb887be..0bd8c1441ca 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.lua @@ -1,5 +1,5 @@ --- Packageversion: 0.2 --- Packagedate: 2018/07/09 +-- Packageversion: 0.3 +-- Packagedate: 2018/08/06 -- tagpdf.lua -- Ulrike Fischer @@ -213,7 +213,7 @@ function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mcty if uftag.mc[mccnt] then if uftag.mc[mccnt]["artifact"] then uftag.trace.log("THIS IS AN ARTIFACT of type "..tostring(uftag.mc[mccnt]["artifact"]),3) - if uftag.mc[mccnt]["artifact"] == "notype" then + if uftag.mc[mccnt]["artifact"] == "" then box.list = __uftag_insert_bmc_node (box.list,n,"Artifact") else box.list = __uftag_insert_bdc_node (box.list,n,"Artifact", "/Type /"..uftag.mc[mccnt]["artifact"]) @@ -222,7 +222,20 @@ function uftag.func.mark_page_elements (box,mcpagecnt,mccntprev,mcopen,name,mcty uftag.trace.log("THIS IS A TAG "..tostring(tag),3) mcpagecnt = mcpagecnt +1 uftag.trace.log ("INSERT BDC "..mcpagecnt,2) - box.list = __uftag_insert_bdc_node (box.list,n,tag, "/MCID "..mcpagecnt) + local dict= "/MCID "..mcpagecnt + if uftag.mc[mccnt]["raw"] then + uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["raw"]),3) + dict= dict .. " " .. uftag.mc[mccnt]["raw"] + end + if uftag.mc[mccnt]["alt"] then + uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["alt"]),3) + dict= dict .. " " .. uftag.mc[mccnt]["alt"] + end + if uftag.mc[mccnt]["actualtext"] then + uftag.trace.log("RAW CONTENT"..tostring(uftag.mc[mccnt]["actualtext"]),3) + dict= dict .. " " .. uftag.mc[mccnt]["actualtext"] + end + box.list = __uftag_insert_bdc_node (box.list,n,tag, dict) uftag.func.store_mc_kid (mccnt,mcpagecnt,abspage) uftag.func.store_mc_in_page(mccnt,mcpagecnt,abspage) uftag.trace.show_mc_data (mccnt) diff --git a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty index 15c87eb3fed..cc91ad5cee1 100644 --- a/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty +++ b/Master/texmf-dist/tex/latex/tagpdf/tagpdf.sty @@ -1,6 +1,6 @@ \RequirePackage{expl3}[2018/06/14] -\ProvidesExplPackage {tagpdf} {2018/07/09} {0.2} +\ProvidesExplPackage {tagpdf} {2018/08/06} {0.3} {A package to experiment with pdf tagging} % storing internal names to my name space: @@ -34,13 +34,18 @@ \RequirePackage{zref-base,zref-lastpage} \RequirePackage{etoolbox} \RequirePackage{pdfescape} +\RequirePackage{pdftexcmds} + +\RequirePackage{l3str-convert} +\cs_generate_variant:Nn \str_set_convert:Nnnn {Nonn, Noon, Nnon } + %%% absolute page numbers \int_new:N \g__uftag_abspage_int \int_gset:Nn \g__uftag_abspage_int { 0 } -\zref@newlist {tagpdf} +\zref@newlist {uftagzrl} %zrl=zreflist \zref@newprop*{tagabspage} [0] { \int_use:N \g__uftag_abspage_int } -\zref@addprop {tagpdf} {tagabspage} +\zref@addprop {uftagzrl} {tagabspage} %%% tagpdfsetup, @@ -48,7 +53,7 @@ \int_new:N \l__uftag_loglevel_int \tl_new:N \l__uftag_tree_tabs_order_tl -\keys_define:nn { tagpdf-setup } +\keys_define:nn { uftag / setup } { activate-mc .bool_gset:N = \g_uftag_active_mc_bool, activate-tree .bool_gset:N = \g_uftag_active_tree_bool, @@ -69,6 +74,7 @@ tabsorder / column .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/C}}, tabsorder / structure .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {/Tabs/S}}, tabsorder / none .code:n = {\tl_set:Nn \l__uftag_tree_tabs_order_tl {}}, + tabsorder .initial:n = structure, compresslevel .choices:nn = {0,1,2,3,4,5,6,7,8,9} { \__uftag_pdfcompresslevel:n {#1} @@ -76,16 +82,31 @@ }, compresslevel .value_required:n = true, uncompress .meta:n = { compresslevel = 0 }, + inputencoding .code:n = + { + \sys_if_engine_pdftex:T + { \tl_gset:Nn \g__uftag_inputencoding_tl { #1 } } + }, } - +% escape commands are a bit engine specific so have been moved to the driver files. % commands to escape strings so that they can be safely used in pdf % currently not much used. But will be needed later, when alt and actualtext are added. % we probably need the equivalent \pdfescapestring, \pdfescapename \pdfescapehex % the commands of pdfescape adds an additional layout to allow for babel shorthands -\cs_set_eq:NN \__uftag_pdf_escape_string:Nn \EdefEscapeString -\cs_set_eq:NN \__uftag_pdf_escape_name:Nn \EdefEscapeName -\cs_set_eq:NN \__uftag_pdf_escape_hex:Nn \EdefEscapeHex +%\cs_set_eq:NN \__uftag_pdf_escape_string:Nn \EdefEscapeString +%\cs_set_eq:NN \__uftag_pdf_escape_name:Nn \EdefEscapeName +%\cs_set_eq:NN \__uftag_pdf_escape_hex:Nn \EdefEscapeHex + +%\cs_set_eq:NN \__uftag_pdf_escape_string:n \EdefEscapeString +%\cs_set_eq:NN \__uftag_pdf_escape_name:Nn \EdefEscapeName + +%escape command. They are driver specific as \pdf@escapehex would ignore most chars +%outside the "pdflatex" range + + + + % a hook for later code and an absolute page counter % should be executed before counters are resetted. @@ -95,7 +116,10 @@ \AtBeginShipout { \__uftag_finish_page_hook: - \__uftag_tree_write_pageattr: + \bool_if:NT\g_uftag_active_tree_bool + { + \__uftag_tree_write_pageattr: + } \int_gincr:N \g__uftag_abspage_int } @@ -141,6 +165,7 @@ \tl_new:N \l__uftag_tmpc_tl \tl_new:N \l__uftag_tmpd_tl \tl_new:N \l__uftag_tmpe_tl +\str_new:N \l__uftag_tmpa_str % helper function to get the propcount. % use as \prop_map_function:NN PROP { \__uftag_prop_count:nn -1 } |