diff options
Diffstat (limited to 'tex/context/base/strc-ref.mkvi')
-rw-r--r-- | tex/context/base/strc-ref.mkvi | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi index 65c0837d3..0a0f0a546 100644 --- a/tex/context/base/strc-ref.mkvi +++ b/tex/context/base/strc-ref.mkvi @@ -123,7 +123,14 @@ \expandafter\gobblefourarguments \fi} -\def\strc_references_set_named_reference_indeed#kind#labels#userdata#text% labels userdata text -> todo: userdata +\newbox\b_strc_destination_nodes + +\unexpanded\def\strc_references_flush_destination_nodes + {\ifvoid\b_strc_destination_nodes \else + \unhbox\b_strc_destination_nodes + \fi} + +\unexpanded\def\strc_references_set_named_reference_indeed#kind#labels#userdata#text% labels userdata text -> todo: userdata {\ifreferencing % we could have a more efficient one for page references but for the moment % we don't care too much @@ -149,8 +156,9 @@ \fi % beware, the structures.references.set writes a % \setnextinternalreference - \ctxlua{structures.references.setandgetattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels", - { + \setbox\b_strc_destination_nodes\hbox\bgroup % messybut we need the delay + \ctxlua{structures.references.setandgetattribute("\currentreferencekind", "\referenceprefix","\currentreferencelabels", + { references = { % internal = \nextinternalreference, % no need for an internal as we have an explicit block = "\currentsectionblock", @@ -172,25 +180,31 @@ userdata = structures.helpers.touserdata(\!!bs\detokenize{#userdata}\!!es) \fi },"\interactionparameter\c!focus") - }% + }% + \egroup \fi \else + \setbox\b_strc_destination_nodes\emptyhbox \lastdestinationattribute\attributeunsetvalue \fi % will become obsolete: \xdef\currentdestinationattribute{\number\lastdestinationattribute}% % will become an option: \ifnum\lastdestinationattribute>\zerocount - \dontleavehmode\hbox attr \destinationattribute\lastdestinationattribute{}% + \dontleavehmode\hbox attr \destinationattribute\lastdestinationattribute\bgroup + \strc_references_flush_destination_nodes + \egroup \fi} \def\strc_references_set_page_only_destination_attribute#labels% could in fact be fully expandable {\ifreferencing \edef\currentreferencelabels{#labels}% \ifx\currentreferencelabels\empty + \setbox\b_strc_destination_nodes\emptyhbox \lastdestinationattribute\attributeunsetvalue \else - \ctxlua{structures.references.setandgetattribute("page", "\referenceprefix","\currentreferencelabels", + \setbox\b_strc_destination_nodes\hbox\bgroup % messybut we need the delay + \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","\currentreferencelabels", { references = { block = "\currentsectionblock", @@ -200,9 +214,11 @@ kind = "page", }, },"\interactionparameter\c!focus") - }% + }% + \egroup \fi \else + \setbox\b_strc_destination_nodes\emptyhbox \lastdestinationattribute\attributeunsetvalue \fi} @@ -223,10 +239,11 @@ %D For internal usage: -\def\dosetsimplepagereference#label% beware, not that ok as it injects a dummy ... brrr +\def\strc_references_set_simple_page_reference#label% {\iflocation - \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","#label", - { + \setbox\b_strc_destination_nodes\hbox\bgroup + \ctxlua{structures.references.setandgetattribute("\s!page", "\referenceprefix","#label", + { references = { % block = "\currentsectionblock", % section = structures.sections.currentid(), @@ -234,14 +251,16 @@ metadata = { % we could assume page to have no metadata kind = "\s!page", }, - },"\interactionparameter\c!focus") - }% + },"\interactionparameter\c!focus") + }% + \egroup \xdef\currentdestinationattribute{\number\lastdestinationattribute}% \else + \setbox\b_strc_destination_nodes\emptyhbox \xdef\currentdestinationattribute{\number\attributeunsetvalue}% \fi} -\def\dogetsimplepagereference#label% +\def\strc_references_get_simple_page_reference#label% {\iflocation \ctxlua{structures.references.inject("\referenceprefix","#label",\number\ht\strutbox,\number\dp\strutbox,\extrareferencearguments)}% \xdef\currentreferenceattribute{\number\lastreferenceattribute}% |