Skip to content

Commit

Permalink
test existence of props, latex3/latex3#1455
Browse files Browse the repository at this point in the history
  • Loading branch information
u-fischer committed Feb 19, 2024
1 parent 1e75d36 commit 3d5c4d7
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 276 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ this project uses date-based 'snapshot' version identifiers.
### Fixed
- missing slashes in dvilualatex backend, issue #96
- lua error with large object numbers, issue #97
- existence tests for unknown props (issue latex3/latex3#1455)

### Changed
- speed gain by using linked properties
Expand Down
5 changes: 3 additions & 2 deletions tagpdf-checks.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@
% Message if an attribute i sunknown.
% \end{function}
%
% \begin{function}{role-missing,role-unknown,role-unknown-tag,role-tag,new-tag,
% \begin{function}{role-missing,role-unknown,role-unknown-tag,role-unknown-NS,role-tag,new-tag,
% role-parent-child,role-remapping}
% Messages related to role mapping.
% \end{function}
Expand Down Expand Up @@ -500,12 +500,13 @@
% \end{macro}
%
% \subsection{Roles}
% \begin{macro}{role-missing,role-unknown,role-unknown-tag}
% \begin{macro}{role-missing,role-unknown,role-unknown-tag,role-unknown-NS}
% Warning message if either the tag or the role is missing
% \begin{macrocode}
\msg_new:nnn { tag } {role-missing} { tag~#1~has~no~role~assigned }
\msg_new:nnn { tag } {role-unknown} { role~#1~is~not~known }
\msg_new:nnn { tag } {role-unknown-tag} { tag~#1~is~not~known }
\msg_new:nnn { tag } {role-unknown-NS} { \tl_if_empty:nTF{#1}{Empty~NS}{NS~#1~is~not~known} }
% \end{macrocode}
% \end{macro}
% \begin{macro}{role-parent-child}
Expand Down
106 changes: 67 additions & 39 deletions tagpdf-roles.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,16 @@
{
\msg_info:nnn { tag }{new-tag}{#1}
}
\prop_get:cnN { g_@@_role_NS_#4_class_prop } {#3}\l_@@_tmpa_tl
\quark_if_no_value:NT \l_@@_tmpa_tl
{
\tl_set:Nn\l_@@_tmpa_tl{--UNKNOWN--}
}
\prop_if_exist:cTF
{ g_@@_role_NS_#4_class_prop }
{
\prop_get:cnN { g_@@_role_NS_#4_class_prop } {#3}\l_@@_tmpa_tl
\quark_if_no_value:NT \l_@@_tmpa_tl
{
\tl_set:Nn\l_@@_tmpa_tl{--UNKNOWN--}
}
}
{ \tl_set:Nn\l_@@_tmpa_tl{--UNKNOWN--} }
\@@_role_alloctag:nnV {#1}{#2}\l_@@_tmpa_tl
% \end{macrocode}
% Do not remap standard tags. TODO add warning?
Expand Down Expand Up @@ -579,15 +584,24 @@
%#3 tlvar which hold the role tag
%#4 tlvar which hold the name of the target NS
{
\prop_get:cnNTF {g_@@_role_NS_#2_prop} {#1}\l_@@_tmpa_tl
{
\tl_set:Ne #3 {\exp_last_unbraced:NV\use_i:nn \l_@@_tmpa_tl}
\tl_set:Ne #4 {\exp_last_unbraced:NV\use_ii:nn \l_@@_tmpa_tl}
}
{
\tl_set:Nn #3 {#1}
\tl_set:Nn #4 {#2}
}
\prop_if_exist:cTF {g_@@_role_NS_#2_prop}
{
\prop_get:cnNTF {g_@@_role_NS_#2_prop} {#1}\l_@@_tmpa_tl
{
\tl_set:Ne #3 {\exp_last_unbraced:NV\use_i:nn \l_@@_tmpa_tl}
\tl_set:Ne #4 {\exp_last_unbraced:NV\use_ii:nn \l_@@_tmpa_tl}
}
{
\msg_warning:nnn { tag } {role-unknown-tag} { #1 }
\tl_set:Nn #3 {#1}
\tl_set:Nn #4 {#2}
}
}
{
\msg_warning:nnn { tag } {role-unknown-NS} { #2 }
\tl_set:Nn #3 {#1}
\tl_set:Nn #4 {#2}
}
}
\cs_generate_variant:Nn \@@_role_get:nnNN {VVNN}
}
Expand Down Expand Up @@ -1106,20 +1120,27 @@
\tl_set:Nn \l_@@_tmpa_tl {#1}
}
{
\prop_get:cnNTF
{ g_@@_role_NS_#2_prop }
{#1}
\l_@@_tmpa_tl
{
\tl_set:Ne \l_@@_tmpa_tl {\tl_head:N\l_@@_tmpa_tl}
\tl_if_empty:NT\l_@@_tmpa_tl
{
\tl_set:Nn \l_@@_tmpa_tl {#1}
}
}
{
\tl_set:Nn \l_@@_tmpa_tl {\q_no_value}
}
\prop_if_exist:cTF { g_@@_role_NS_#2_prop }
{
\prop_get:cnNTF
{ g_@@_role_NS_#2_prop }
{#1}
\l_@@_tmpa_tl
{
\tl_set:Ne \l_@@_tmpa_tl {\tl_head:N\l_@@_tmpa_tl}
\tl_if_empty:NT\l_@@_tmpa_tl
{
\tl_set:Nn \l_@@_tmpa_tl {#1}
}
}
{
\tl_set:Nn \l_@@_tmpa_tl {\q_no_value}
}
}
{
\msg_warning:nnn { tag } {role-unknown-NS} { #2}
\tl_set:Nn \l_@@_tmpa_tl {\q_no_value}
}
}
% \end{macrocode}
% and the same for the child
Expand All @@ -1131,20 +1152,27 @@
\tl_set:Nn \l_@@_tmpb_tl {#3}
}
{
\prop_get:cnNTF
{ g_@@_role_NS_#4_prop }
{#3}
\l_@@_tmpb_tl
\prop_if_exist:cTF { g_@@_role_NS_#4_prop }
{
\tl_set:Ne \l_@@_tmpb_tl { \tl_head:N\l_@@_tmpb_tl }
\tl_if_empty:NT\l_@@_tmpb_tl
{
\tl_set:Nn \l_@@_tmpb_tl {#3}
}
\prop_get:cnNTF
{ g_@@_role_NS_#4_prop }
{#3}
\l_@@_tmpb_tl
{
\tl_set:Ne \l_@@_tmpb_tl { \tl_head:N\l_@@_tmpb_tl }
\tl_if_empty:NT\l_@@_tmpb_tl
{
\tl_set:Nn \l_@@_tmpb_tl {#3}
}
}
{
\tl_set:Nn \l_@@_tmpb_tl {\q_no_value}
}
}
{
{
\msg_warning:nnn { tag } {role-unknown-NS} { #4}
\tl_set:Nn \l_@@_tmpb_tl {\q_no_value}
}
}
}
% \end{macrocode}
% and now get the relation
Expand Down
6 changes: 3 additions & 3 deletions testfiles-pdftex/test-get_role-20.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ xxx
\tl_show:N \l_tmpa_tl\tl_show:N \l_tmpb_tl
}

\TEST{get~standard~role:~Sect}
\TEST{get~standard~role:~Sect,~unknown~NS}
{
\__tag_role_get:nnNN {Sect}{xxx}\l_tmpa_tl\l_tmpb_tl
\tl_show:N \l_tmpa_tl\tl_show:N \l_tmpb_tl
}

\TEST{get~standard~role:~Aside}
\TEST{get~standard~role:~Aside,~empty~NS}
{
\__tag_role_get:nnNN {Aside}{xxx}\l_tmpa_tl\l_tmpb_tl
\__tag_role_get:nnNN {Aside}{}\l_tmpa_tl\l_tmpb_tl
\tl_show:N \l_tmpa_tl\tl_show:N \l_tmpb_tl
}
\ExplSyntaxOff
Expand Down
Loading

0 comments on commit 3d5c4d7

Please sign in to comment.