- Debug CrossRef.

- Miscellaneous improvements.
This commit is contained in:
2025-09-19 16:20:17 -05:00
parent 1093a0a909
commit 277f021589
13 changed files with 476 additions and 39 deletions

View File

@@ -29,7 +29,7 @@
\str_const:Nn \c_@@_label_delimiter_str {/}
\str_const:Nn \c_@@_label_parent_str {.}
\str_const:Nn \c_@@_label_wildcard_str {*}
\str_const:Nn \c_@@_label_placeholder_str {*}
\str_const:Nn \c_@@_appendices_label_str {appendices}
\seq_new:N \g_@@_label_seq
@@ -65,7 +65,9 @@
}
\NewDocumentCommand{\Appendices}{}{
\@@_heading:nnnnn {part} {\c_true_bool} {\c_false_bool} {Appendices} {\c_@@_appendices_label_str}
\@@_heading:nnnnn {part} {\c_true_bool} {\c_false_bool} {Appendices} {
\c_@@_appendices_label_str
}
}
\NewDocumentCommand{\GetCurrentLabel}{}{
@@ -81,10 +83,17 @@
\seq_set_split:Nnn \g_@@_label_seq {#1} {#2}
}
% MATCH delimiter, parent, and wildcard symbols, but CAPTURE only
% parents and wildcards, NOT delimiters.
\regex_const:Nn \c_@@_ref_regex {\/|(\.|\*)} %{\\\c_@@_label_delimiter_str|(\\\c_@@_label_parent_str|\\\c_@@_label_wildcard_str)}
%\regex_show:N \c_@@_ref_regex
\str_new:N \l_@@_esc_parent_str
\exp_args:Nnne \str_concat:NNN \l_@@_esc_parent_str \c_backslash_str \c_@@_label_parent_str
\str_new:N \l_@@_esc_placeholder_str
\exp_args:Nnne \str_concat:NNN \l_@@_esc_placeholder_str \c_backslash_str \c_@@_label_placeholder_str
% MATCH delimiter, parent, and placeholder symbols, but CAPTURE only
% parents and placeholders, NOT delimiters.
%\regex_const:Nn \c_@@_ref_regex {\/|(\.|\*)}
\exp_args:Nne \regex_const:Nn \c_@@_ref_regex {\c_@@_label_delimiter_str|(\l_@@_esc_parent_str|\l_@@_esc_placeholder_str)}
\regex_log:N \c_@@_ref_regex
\seq_new:N \l_@@_label_seq
\seq_new:N \l_@@_ref_seq
@@ -104,12 +113,16 @@
% Output the section name only if no star is passed.
\bool_if:nF {#1} {
\str_if_eq:nnTF {\seq_item:Nn \l_@@_ref_seq {1}} {\c_@@_appendices_label_str} {
\str_if_eq:nnTF {
\seq_item:Nn \l_@@_ref_seq {1}} {\c_@@_appendices_label_str
} {
% If the part label is "appendices", the section name is "Appendix".
\prop_item:Nn \c_@@_section_names_prop {9}
}{
} {
% Otherwise, look up the correct section name.
\prop_item:Nn \c_@@_section_names_prop {\seq_count:N \l_@@_ref_seq - 1}
\prop_item:Nn \c_@@_section_names_prop {
\seq_count:N \l_@@_ref_seq - 1
}
}
}
% Create a reference with the string we just created.
@@ -135,9 +148,11 @@
% Split the string on the delimiters.
\exp_args:NNNe \seq_set_regex_split:NNn \l_@@_ref_seq \c_@@_ref_regex {#2}
% The regex split creates a lot of empty items, so remove them.
\seq_remove_all:Nn \l_@@_ref_seq {}
\str_log:N \l_@@_ref_str
% Log the input and output of the split process for debugging.
\str_log:n {#2}
\seq_log:N \l_@@_ref_seq
% Copy the current label sequence to a local variable.
@@ -149,22 +164,32 @@
% end of the temporary label sequence for each parent symbol.
\seq_map_indexed_function:NN \l_@@_ref_seq \@@_seq_map:nn
% Add the shortened temporary label sequence to the beginning of the
% reference sequence.
\str_if_eq:eeT {\str_head:N \l_@@_ref_str} {\c_@@_label_parent_str} {
\str_set:Ne \l_@@_ref_head_str {\str_head:n {#2}}
\str_log:N \l_@@_ref_head_str
% If the reference is relative (i.e. does not start with / or *), add the
% shortened temporary label sequence to the beginning of the reference
% sequence.
\exp_args:Ne \bool_if:nF {
\str_if_eq_p:NN \l_@@_ref_head_str \c_@@_label_delimiter_str
|| \str_if_eq_p:NN \l_@@_ref_head_str \c_@@_label_placeholder_str
} {
\seq_concat:NNN \l_@@_ref_seq \l_@@_label_seq \l_@@_ref_seq
}
\seq_log:N \l_@@_ref_seq
% Join the reference sequence back into a delimited string.
\str_set:Ne \l_@@_ref_str {\seq_use:Ne \l_@@_ref_seq {\c_@@_label_delimiter_str}}
\str_set:Ne \l_@@_ref_str {
\seq_use:Ne \l_@@_ref_seq {\c_@@_label_delimiter_str}
}
\str_if_eq:eeF {\str_head:N \l_@@_ref_str} {\c_@@_label_delimiter_str} {
\str_put_left:Ne \l_@@_ref_str {\c_@@_label_delimiter_str}
}
\str_set_eq:NN #1 \l_@@_ref_str
\str_set_eq:NN #1 \l_@@_ref_str
}
\tl_new:N \l_@@_trash_tl
@@ -175,7 +200,7 @@
\seq_pop_right:NN \l_@@_label_seq \l_@@_trash_tl
\seq_pop_left:NN \l_@@_ref_seq \l_@@_trash_tl
}
{\c_@@_label_wildcard_str} {
{\c_@@_label_placeholder_str} {
%\message{wildcard~map}
\seq_pop_left:NN \l_@@_label_seq \l_tmpa_tl
% \seq_pop_left:NN \l_@@_ref_seq \l_@@_trash_tl