Skip to content

Commit

Permalink
local lists: page numbers & links
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Apr 22, 2020
1 parent 9311c42 commit 297f7fd
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 96 deletions.
7 changes: 3 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
- page numbers and local lists
- make-links and local lists
- add gender property and extend article mechanism?
- allow pseudo style `first' for single-style

undocumented:
- trailing token: comma
- trailing token: comma, \acgobbletrail
option acro/trailing/fnpct-check
\acfootnote
- options acro/commands
- pdfstring templates and \acsimple
- load-time options debug and final
11 changes: 1 addition & 10 deletions code/acro.definitions.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -115,22 +115,13 @@
\acrowrite {short}
\acroiffirstT
{
% for fnpct: check if punctuation follows and insert it directly after
% the footnote
\tl_set:Ne \l__acro_tmpa_tl
{
\aciftrailing {dot} { . \acgobbletrail } {}
\aciftrailing {comma} { , \acgobbletrail } {}
}
\exp_last_unbraced:Nno
\footnote
\acfootnote
{
\acroifT {alt} { \acrotranslate {or} ~ \acrowrite {alt} :~ }
\acroifT {foreign} { \acrowrite {foreign} ,~ }
\acrowrite {long}
\acrogroupcite
}
\l__acro_tmpa_tl
}
}

Expand Down
3 changes: 3 additions & 0 deletions code/acro.interface.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
\NewExpandableDocumentCommand \aciftrailing {}
{ \acro_trailing_if_tokens:nTF }

\NewDocumentCommand \acfootnote {m}
{ \acro_footnote:n {#1} }

\NewDocumentCommand \acgobbletrail {}
{ \bool_gset_true:N \g__acro_gobble_trail_bool }

Expand Down
4 changes: 2 additions & 2 deletions code/acro.list.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
\seq_map_inline:Nn #1
{
\__acro_check_tags:Nn \l__acro_tmpa_bool {##1}
\bool_if:nT
\bool_lazy_and:nnT
{ \l__acro_list_local_bool }
{
\l__acro_list_local_bool &&
\int_compare_p:nNn
{ \intarray_count:c {g__acro_##1_barriers_intarray} } > 0
}
Expand Down
54 changes: 41 additions & 13 deletions code/acro.pages.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
% #1: id
\cs_new_protected:Npn \acro_record_page:n #1
{
\seq_if_in:ceF {g__acro_#1_pages_seq} { \arabic{abspage} @ \thepage }
\seq_if_in:ceF {g__acro_#1_pages_seq}
{ \arabic{abspage} @ \int_use:N \g_acro_barrier_int @ \thepage }
{
\seq_gput_right:ce {g__acro_#1_pages_seq}
{ \arabic{abspage} @ \thepage }
{ \arabic{abspage} @ \int_use:N \g_acro_barrier_int @ \thepage }
}
\seq_gremove_duplicates:c {g__acro_#1_pages_seq}
\acro_at_end_document:n
Expand All @@ -25,13 +26,16 @@
}
}

\cs_new:Npn \__acro_page:w #1@#2 \q_stop
\cs_new:Npn \__acro_page_name:w #1@#2@#3 \q_stop
{
\acro_package_if_loaded:nTF {hyperref}
{ \exp_not:N \hyperpage { \exp_not:n {#2} } }
{ \exp_not:n {#2} }
{ \exp_not:N \hyperpage { \exp_not:n {#3} } }
{ \exp_not:n {#3} }
}
\cs_new:Npn \__acro_page_value:w #1@#2 \q_stop {#1}

\cs_new:Npn \__acro_absolute_page:w #1@#2@#3 \q_stop {#1}

\cs_new:Npn \__acro_barrier:w #1@#2@#3 \q_stop {#2}

\group_end:

Expand Down Expand Up @@ -72,20 +76,44 @@
\seq_map_inline:Nn \l__acro_tmpa_seq
{
\intarray_gset:Nnn \g__acro_pages_intarray
{ \__acro_page_value:w ##1 \q_stop + 1 }
{ 1 }
{ \__acro_absolute_page:w ##1 \q_stop + 1 }
{
\bool_if:NTF \l__acro_list_local_bool
{
\int_compare:nNnTF
{ \__acro_barrier:w ##1 \q_stop }
=
\g_acro_barrier_int
{1}
{0}
}
{1}
}
}
\bool_if:NT \l__acro_list_local_bool
{
\seq_clear:N \l__acro_tmpb_seq
\seq_map_inline:Nn \l__acro_tmpa_seq
{
\int_compare:nNnT
{ \__acro_barrier:w ##1 \q_stop }
=
\g_acro_barrier_int
{ \seq_put_right:Nn \l__acro_tmpb_seq {##1} }
}
\seq_set_eq:NN \l__acro_tmpa_seq \l__acro_tmpb_seq
}
\seq_clear:N \l__acro_tmpb_seq
\int_zero:N \l__acro_tmpb_int
\seq_map_inline:Nn \l__acro_tmpa_seq
{
% the current page
\int_set:Nn \l__acro_tmpa_int
{ \__acro_page_value:w ##1 \q_stop + 1 }
{ \__acro_absolute_page:w ##1 \q_stop + 1 }
\int_compare:nNnTF \l__acro_tmpa_int = 1
{ % first page, start range
\seq_put_right:Ne \l__acro_tmpb_seq
{ \__acro_page:w ##1 \q_stop }
{ \__acro_page_name:w ##1 \q_stop }
\int_incr:N \l__acro_tmpb_int
}
{ % not first page
Expand All @@ -98,7 +126,7 @@
{ % start range
\int_zero:N \l__acro_tmpb_int
\seq_put_right:Ne \l__acro_tmpb_seq
{ \__acro_page:w ##1 \q_stop }
{ \__acro_page_name:w ##1 \q_stop }
\int_incr:N \l__acro_tmpb_int
}
{ % continue range
Expand Down Expand Up @@ -154,7 +182,7 @@
{
\exp_not:V \l__acro_tmpa_tl
--
\__acro_page:w #3 \q_stop
\__acro_page_name:w #3 \q_stop
}
}
}
Expand All @@ -171,7 +199,7 @@
\seq_put_right:Ne \l__acro_tmpb_seq
{ \exp_not:V \l__acro_tmpa_tl }
\seq_put_right:Ne \l__acro_tmpb_seq
{ \__acro_page:w #3 \q_stop }
{ \__acro_page_name:w #3 \q_stop }
}
}
}
Expand Down
59 changes: 42 additions & 17 deletions code/acro.pdfsupport.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,30 @@
\msg_new:nnn {acro} {pdf-template-undefined}
{ The~ pdfstring~ template~ `#1'~ is~ not~ defined~ \msg_line_context: }

\msg_new:nnn {acro} {local-links}
{
You~ are~ using~ the~ option~ `make-links'~ in~ combination~ with~ local~
acronym~ lists.~ Please~ make~ sure~ to~ also~ set \\
\ \ \ \ barriers/single~ =~ true \\
for~ referencing~ only~ existing~ and~ unique~ links.
}

% --------------------------------------------------------------------------
% hyper linking
\bool_new:N \l__acro_hyperref_use_bool

\cs_new_eq:NN \__acro_hyper_target:nn \use_ii:nn
\cs_new_eq:NN \__acro_hyper_link:nn \use_ii:nn

% TODO: respect barriers, maybe with testing \l__acro_barriers_bool
% and prepending or appending the current barrier number to links. In that
% case the `target-set' option could not be used any more as we would need to
% be able to set several targets; maybe then make records like we do for page
% numbers?
% TODO: only list page numbers from within the barriers
\acro_property_declare:nnnnn
{ \c_false_bool } % not unique
{ \c_true_bool } % boolean
{ \c_false_bool } % not mandatory
{ \c_false_bool } % dynamic
{target-set}
\cs_generate_variant:Nn \__acro_hyper_target:nn {e}
\cs_generate_variant:Nn \__acro_hyper_link:nn {e}

% \acro_property_declare:nnnnn
% { \c_false_bool } % not unique
% { \c_true_bool } % boolean
% { \c_false_bool } % not mandatory
% { \c_false_bool } % dynamic
% {target-set}

\cs_new_protected:Npn \__acro_activate_hyperref_support:
{
Expand Down Expand Up @@ -59,15 +64,24 @@
{
\bool_if:NTF \l__acro_list_bool
{
\acro_boolean_property_if:nnTF {#1} {target-set}
{#3}
\__acro_hyper_target:en
{
\__acro_hyper_target:nn {acro:#1} {#3}
\acro_property_set:nnn {#1} {target-set} {true}
acro : #1
\bool_lazy_and:nnT
{ \l__acro_list_local_bool }
{ \l__acro_usage_local_bool }
{ : \int_use:N \g_acro_barrier_int }
}
{#3}
}
{
\__acro_hyper_link:nn {acro:#1} { \phantom {#3} }
\__acro_hyper_link:en
{
acro : #1
\bool_if:NT \l__acro_usage_local_bool
{ : \int_use:N \g_acro_barrier_int }
}
{ \phantom {#3} }
\__acro_color_link:n { \hbox_overlap_left:n {#3} }
}
}
Expand All @@ -76,6 +90,17 @@
{#3}
}

\acro_at_begin_document:n
{
\bool_if:nT
{
\l__acro_hyperref_use_bool &&
\l__acro_barriers_bool &&
! \l__acro_usage_local_bool
}
{ \msg_warning:nn {acro} {local-links} }
}

% #1: text
\cs_new:Npn \__acro_color_link:n #1
{
Expand Down
Loading

0 comments on commit 297f7fd

Please sign in to comment.