summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/hyperlinks.opm
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/optex/hyperlinks.opm')
-rw-r--r--macros/luatex/optex/hyperlinks.opm76
1 files changed, 41 insertions, 35 deletions
diff --git a/macros/luatex/optex/hyperlinks.opm b/macros/luatex/optex/hyperlinks.opm
index 02b33600bd..316e36745e 100644
--- a/macros/luatex/optex/hyperlinks.opm
+++ b/macros/luatex/optex/hyperlinks.opm
@@ -1,16 +1,14 @@
%% This is part of OpTeX project, see http://petr.olsak.net/optex
-\_codedecl \ulink {Hyperlinks <2020-03-15>} % preloaded in format
-
-\_newcount \_tocrefnum
+\_codedecl \ulink {Hyperlinks <2020-04-22>} % preloaded in format
\_doc ----------------------------
- `\dest[<type>:<spec>]` creates a destination of internal links. The
- destination is declared by `<type>:<spec>`. If `\hyperlinks` are not
- declared, then `\dest` does nothing else it is set to `\_destactive`.
- The `\_destactive` is implemented by `\_pdfdest` primitive. It creates a box
- in which the destination is shifted by `\_destheight`. The reason is that
- the destination is exactly at top border of the PDF viewer but we want to se
+ \`\dest``[<type>:<spec>]` creates a destination of internal links. The
+ destination is declared in the format `<type>:<spec>`. If the \^`\hyperlinks`
+ command in not used, then `\dest` does nothing else it is set to `\_destactive`.
+ The \`\_destactive` is implemented by `\_pdfdest` primitive. It creates a box
+ in which the destination is shifted by \`\_destheight`. The reason is that
+ the destination is exactly at top border of the PDF viewer but we want to see
the line where destination is. The destination box is positioned by
different way dependent on current vertical or horizontal mode.
\_cod ----------------------------
@@ -27,15 +25,16 @@
\_public \dest ;
\_doc ----------------------------
- `\_link[<type>:<spec>]{<color>}{<text>}` creates an internal link to `\dest`
+ \`\link``[<type>:<spec>]{<color>}{<text>}` creates an internal link to \^`\dest`
with the same `<type>:<spec>`. You can have more links with the same
- `<type>:<spec>` but only one `\dest` in the document. If `\hyperlinks` are
- not declared, then `\link` only prints <text> else it is set to `\_linkactive`.
- The `\_linkactive` is implemented by `\_pdfstartlink...\_pdfendlink`
+ `<type>:<spec>` but only one `\dest` in the document. If \^`\hyperlinks`
+ command is not used, then `\link` only prints `<text>` else it is set to
+ `\_linkactive`.
+ The \`\_linkactive` is implemented by `\_pdfstartlink...\_pdfendlink`
primitives.
-
- `\ilink[<type>:<spec>]{<text>}` is equivalent to `\_link` but <color> is
- used from `\hyperlinks` decaration.
+ \nl
+ \`\ilink``[<type>:<spec>]{<text>}` is equivalent to `\_link` but
+ the `<color>` is used from \^`\hyperlinks` declaration.
\_cod ----------------------------
\_protected\_def\_linkactive[#1:#2]#3#4{\_leavevmode\_pdfstartlink height.9em depth.3em
@@ -43,14 +42,14 @@
}
\_protected\_def\_link[#1]#2#3{\_leavevmode{#3}}
\_protected\_def\_ilink[#1]#2{\_leavevmode{#2}}
-\_public \ilink ;
+\_public \ilink \link ;
\_doc ----------------------------
- `\ulink[<url>]{<text>}` creates external link. It prints only <text> by default but
- the `\hyperlinks` declaration defines it as `\_urlactive[url:<url>]{<text>}`.
- The external link is created by `\_pdfstartlink...\pdfendlink` primitives.
- The <url> is detokenized with `\escapechar=-1` before it is used, so
- `\%`, `\#` etc. can be used in the <url>.
+ \`\ulink``[<url>]{<text>}` creates external link. It prints only te `<text>` by default but
+ the \^`\hyperlinks` declaration defines it as \`\_urlactive``[url:<url>]{<text>}`.
+ The external link is created by the `\_pdfstartlink...\pdfendlink` primitives.
+ The `<url>` is detokenized with `\escapechar=-1` before it is used, so
+ `\%`, `\#` etc. can be used in the `<url>`.
\_cod ----------------------------
\_protected\_def\_urlactive[#1:#2]#3#4{\_leavevmode{\_escapechar=-1
@@ -64,9 +63,11 @@
\_doc ----------------------------
The `\_pdfstartlink` primitive uses `\_pdfborder{<type>}` in its parameter
- (see `\_linkactive` or `\_urlactive` macros). The `\_pdfbordef{<type>}`
+ (see \^`\_linkactive` or \^`\_urlactive` macros). The \`\_pdfborder``{<type>}`
expands to `attr{/C[? ? ?] /Border[0 0 .6]}` if the
- `\<type>border` is defined. User can define it in
+ `\<type>border` (i.e.\ \`\refborder`, \`\citeborder`, \`\tocborder`, \`\pgborder`,
+ \`\urlborder`, \`\fntborder` or \`\fnfborder`)
+ is defined. User can define it in
order to create colored frames around active links. For example
`\def\tocborder{1 0 0}` causes red frames in TOC (not printed, only visible
in PDF viewers).
@@ -79,7 +80,7 @@
}
\_doc ----------------------------
- `\hyperlinks{<ilink_color>}{<ulink_color>}` activates `\dest`, `\link`,
+ \`\hyperlinks``{<ilink_color>}{<ulink_color>}` activates `\dest`, `\link`,
`\ilink`, `\ulink` in order they create links. These macros are redefined
here to their \"active" version.
\_cod ----------------------------
@@ -93,20 +94,21 @@
\_public \hyperlinks ;
\_doc ----------------------------
- `\url{<url>}` does approximately the same as `\ulink[<url>]{<url>}`, but
+ \`\url``{<url>}` does approximately the same as \^`\ulink``[<url>]{<url>}`, but
more work is done before the `\ulink` is processed. The link-version of <url>
is saved to `\_tmpa` and the printed version in `\_tmpb`. The printed
- version is modified in order to set a breakpoints in special places of the
- <url>. For example `//` is replaced by `\_urlskip/\_urlskip/\_urlbskip`
+ version is modified in order to set a breakpoints to special places of the
+ `<url>`. For example `//` is replaced by `\_urlskip/\_urlskip/\_urlbskip`
where `\urlskip` adds a small nobreakable glue between these two slashes and
before them and `\_urlbskip` adds a breakable glue after them.
- \_cod \_fin ----------------------
+ \nl
+ The text version of the `<url>` is printed in \`\_urlfont`.
+ \_cod ----------------------------
\_def\_url#1{{%
\_def\_tmpa{#1}\_replstring\_tmpa {\|}{}%
- \_def\_tmpb{#1}\_replstring\_tmpb {\|}{\\|}%
- {\_escapechar=-1 \_ea}\_ea\_edef\_ea\_tmpb\_ea{\detokenize\_ea{\_tmpb}}%
- \_let\_tmpa=\_tmpb
+ {\_escapechar=-1 \_ea}\_ea\_edef\_ea\_tmpa\_ea{\detokenize\_ea{\_tmpa}}%
+ \_def\_tmpb{#1}\_replstring\_tmpb {\|}{\_urlbskip}%
\_replstring\_tmpb {//} {{\_urlskip\_urlslashslash\_urlbskip}}%
\_replstring\_tmpb {/} {{\_urlskip/\_urlbskip}}%
\_replstring\_tmpb {.} {{\_urlskip.\_urlbskip}}%
@@ -141,11 +143,15 @@ There are four types of the internal links and one type of external link:
see also the end of this section.
\enditems
-The <tocrefnum>, <gpageno> and <bibnum> are numbers starting from one and
-globally incremented by one in whole document. The registers `\_tocrefnum`,
-`\_gpageno` and `\_bibnum` are used for these numbers.
+The `<tocrefnum>`, `<gpageno>` and `<bibnum>` are numbers starting from one and
+globally incremented by one in whole document. The registers \^`\tocrefnum`,
+\^`\gpageno` and \^`\bibnum` are used for these numbers.
When a chap/sec/secc title is prefixed by `\label[<label>]`, then both types
of internal links are created at the same destination place:
`toc:<tocrefnum>` and `ref:<label>`.
+\_endinput
+
+2020-04-22 \| in \url: bug fixed
+2020-03-15 introduced \ No newline at end of file