From 996c9b239bde82dc3ef3e5b69cd525e87fdb61a8 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 19 Sep 2021 03:01:05 +0000 Subject: CTAN sync 202109190301 --- macros/luatex/optex/pdfextra/pdfextra.opm | 144 ++++++++++++++++++------------ 1 file changed, 85 insertions(+), 59 deletions(-) (limited to 'macros/luatex/optex/pdfextra/pdfextra.opm') diff --git a/macros/luatex/optex/pdfextra/pdfextra.opm b/macros/luatex/optex/pdfextra/pdfextra.opm index b7cf70a981..bccf096484 100644 --- a/macros/luatex/optex/pdfextra/pdfextra.opm +++ b/macros/luatex/optex/pdfextra/pdfextra.opm @@ -1,17 +1,35 @@ % vim: tw=80 -\_def\_pdfextra_version{0.1} +\_def\_pdfextra_version{0.2} \_codedecl \RM {Extra PDF features (v\_pdfextra_version)} +\_namespace{pdfextra} + \_doc \sec Package initialization + We ensure that hyperlinking is active. Our fallback \`\_linkcolor` must + exist. We also use it for `\hyperlinks` if the user didn't enable + `\hyperlinks` yet (we don't want to override user setting). + \_cod + +\_ifdefined\_ilinkcolor\_else + \_ifdefined\_linkcolor + \_ea\_let\_ea\_linkcolor \_ifdefined\Blue\Blue\_else\_empty\_fi + \_else + \_let\_linkcolor\linkcolor + \_fi +\_fi + +\_ifx\_dest\_destactive\_else + \_hyperlinks\_linkcolor\_linkcolor +\_fi + + \_doc We are in the \OpTeX/ package namespace. A couple of shortcuts are defined here: \`\.isdefined`, \`\.trycs`, \`\.cs` \`\.slet`, \`\.slet`, \`\.sdef` and - \`\.xdef`. They all hard code the package name, because we already have too + \`\.sxdef`. They all hard code the package name, because we already have too many levels of indirection. \_cod -\_namespace{pdfextra} - \_def\.isdefined#1{\_isdefined{_pdfextra_#1}} \_def\.trycs#1{\_trycs{_pdfextra_#1}} \_def\.cs#1{\_cs{_pdfextra_#1}} @@ -67,7 +85,8 @@ \_doc \`\.xaddto``\macro`{} is a natural extension of \OpTeX's `\addto` that - expands and is global. + expands and is global.\nl + \`\.tmp` is used throught the package for temporary values. \_cod \_def\.xaddto#1#2{\_edef\.tmp{#2}% @@ -115,10 +134,6 @@ rough estimate we take the current page~-- this actually works well for slides where page breaks are manual. - `\.pageof` is expandable, but we want to let the user know, that the document - needs to be processed twice. Therefore we use \LuaTeX's - `\immediateassignment` to increment the counter of unresolved references. - When `.ref` file is read along with the defintion of `\.Xpageof` this package has not been loaded yet. Hence we can't use namespaced variants of `\.isdefined`, etc. @@ -134,7 +149,6 @@ \_def\.pageof#1{% \.trycs{pageof:#1}{% - \_immediateassignment\_incr\_unresolvedrefs \_the\_numexpr\_gpageno+1\_relax % best effort = current page num }% } @@ -368,14 +382,12 @@ \_doc \label[actions-link] \secc Link annotations - The main use of actions~-- annotations of `/Subtype /Link`. - Annotation of this type creates an active rectangular area on the page that - executes a PDF action (or chain of them in the general case). - \`\hlinkactive``[]` is a natural extension of \OpTeX/'s - `\linkactive`, that supports the classic \"jump" actions of types `ref`, - `bib`, etc. But also other types of actions. No distinction between - \"internal" (`\ilink`) and external (`\ulink`) links is made. The mechanism is - completely generic. + The main use of actions~-- annotations of `/Subtype /Link`. Annotation of + this type creates an active rectangular area on the page that executes a PDF + action (or chain of them in the general case). + \`\hlink``[]` is macro that typesets and makes area + occupied by it active according to . All action types are + supported, the mechanism is completely generic. The `\pdfstartlink`/`\pdfendlink` primitives are used to denote the part of the page where appears as active. \LuaTeX/ will then handle even the @@ -383,7 +395,7 @@ multiple rectangular annotations to cover all `\hbox`es). \_cod -\_def\.hlinkactive[#1]#2{\_bgroup\_def\#{\_csstring\#}% +\_def\.hlink[#1]#2{\_bgroup\_def\#{\_csstring\#}% \_edef\.type{\.pdfactiontype[#1]}% \_quitvmode\_pdfstartlink \.linkdimens attr{\_pdfborder{\.type}}% @@ -391,25 +403,25 @@ \_localcolor\.linkcolor{\.type}#2\_pdfendlink\_egroup } +\_nspublic \hlink ; + \_doc - `\hlinkactive` itself is dormant before `\hyperlinks` occurs. Until then, a - dummy \`\hlink` is used. \OpTeX/'s `\hyperlinks` is extended to hook `\hlink` - activation. The colors of internal/external links are remembered for - compatibility with \OpTeX/. + Use `\hlink` as the backing command for OpTeX's \"higher level" linking + commands (`\ilink` and `\ulink`). + + The lower level ones (`\xlink` and its predecessor `\link` actually have + completely different semantics with regards to color, so we keep them as they + are. \_cod -\_def\.hlink[#1]#2{\_quitvmode{#2}} -\_nspublic \hlink ; +\_protected\_def\_ilink[#1]#2{\.hlink[#1]{#2}} +\_protected\_def\_ulink[#1]#2{{\_escapechar=-1 \_ea}\_expanded + {\_noexpand\.hlink[url:\_detokenize{#1}]}{#2}} -\_let\.oldhyperlinks\_hyperlinks -\_def\_hyperlinks#1#2{% - \.oldhyperlinks#1#2 - \_let\.ilinkcolor=#1% - \_let\.elinkcolor=#2% - \_let\.hlink=\.hlinkactive - \_let\hlink=\.hlink -} -\_public \hyperlinks ; +\_public \link \ilink \ulink ; + +%\_protected\_def\_link[#1]#2#3{\_hlink[#1]{#3}} +%\_protected\_def\_xlink#1#2#3#4{\_hlink[#1:#2]{#4}} \_doc Two customizations of `\hlinks` are possible: @@ -421,10 +433,12 @@ running text~-- it covers all space of a line using `\baselineskip`. \`\nolininglinks` sets no dimensions, this is useful for buttons, that may have larger height/depth than a line. - * The color is determined from the type of link (that is the first action in - ) by checking `\_linkcolor` (compatible with \OpTeX/) or - `\_pdfextra_linkcolor`. - As a fallback \`\.ilinkcolor` is used (set by `\hyperlinks`). + * The color is determined from the type of link (that is, the first action in + ) by checking `\_linkcolor` (compatible with \OpTeX/). + As a fallback `\_ilinkcolor` is used (set by \OpTeX's `\hyperlinks`) for all links + except for URLs, where `\_elinkcolor` is used instead. If even these + fallback colors are not defined (`\hyperlinks` isn't used), then the most + generic `\_linkcolor` will be taken or no color will be set. \enditems \_cod @@ -436,8 +450,10 @@ \_nspublic \lininglinks \nolininglinks ; -\_def\.linkcolor#1{\_trycs{_#1linkcolor}{\.trycs{#1linkcolor}{\.ilinkcolor}}} -\_def\.ilinkcolor{} +\_def\.linkcolor#1{\_trycs{_#1linkcolor}{\_trycs{_ilinkcolor}{\_trycs{_linkcolor}{}}}} + + % \_urllinkcolor = \_elinkcolor with fallbacks +\_def\_urllinkcolor{\.linkcolor{e}} \_doc \secc Open action @@ -683,7 +699,8 @@ \.pdfpageattributesetters Dur \defaultpageduration \pageduration {#1} \_doc - \sec Attachments and document level JavaScript + \label[nametrees] + \sec Name trees -- attachments and document level JavaScript These don't have any last place to be in, so they are documented separately, here. Attaching files using `/FileAttachment` annotations: @@ -711,7 +728,7 @@ \`\dljavascript``[]{