Target #
and linking to it ->#
Links usually connect webpages with one another. But sometimes links should lead to a particular spot in the same page instead, for instance to a particular figure or from a table of contents to the different sections of a longer article. You can mark individual words or phrases in your Aneamal file as link targets for that purpose.
How to
Prepend a word with a hash #
to turn it into a target for links. You can also add the hash before a string of words to make that a target. A hash can be placed in front of a number in a numbered list to turn the item into a link target. Create a target without visible text in the webpage by wrapping the target text in curly brackets #{…}
.
A target must be unique in its file, but there can be multiple links to the same target.
Links to a target use the same arrow ->
made of a hyphen and a greater-than sign that is known from regular links. But the link points to a copy of the target instead of to an address. The copy does not need to be perfect: small and capital letters are interchangeable and you do not have to use the same string markup either. For instance, the target #*EEK*
could also be reached by the link ->#eek
.
The target copy is used as link text by default. But you can attach the link arrow to the end of another word or string of words which will be used as link text then.
Link to a target in a different webpage
It is possible to link to a target in a different webpage. But you have to use a regular link and append a hash #
and an URL fragment to the address yourself then. The fragment in the address must be identical to the HTML id that the Aneamal Translator generates for the target.
There are a handful of ways to determine the correct fragment:
- Create a link to the target within the same webpage. Click on that link in your browser, leading you to the target. Now copy the address from your browser’s address bar and use it where you need it.
- Use your browser’s developer tools to inspect the HTML code for the target. Its id attribute contains the fragment.
- If your target is just an English word, then the corresponding fragment is also that word, but using only small letters. Digits in the target are unchanged. Spaces in the target become hyphens in the fragment.
- Copy your target into the textbox below. The corresponding fragment will be generated.
Examples
The first example contains two targets, Minish Woods
and Picori
. Notice that targets do not stand out from the text of the webpage:
#`Minish Woods` is inhabited by #Picori, tiny people who delight in making humans happy by hiding helpful items and rupees under grass and rocks all over the world.
Minish Woods is inhabited by Picori, tiny people who delight in making humans happy by hiding helpful items and rupees under grass and rocks all over the world.
The second example is a numbered list of someone’s favorite books. Its item numbers have been turned into targets for links:
#1. Rem’s Anthology for Sleepless Nights
#2. A Hyrulean Bestiary
#3. Learn to Like Your Like Like: A Good Guide to a Bad Pet
- Rem’s Anthology for Sleepless Nights
- A Hyrulean Bestiary
- Learn to Like Your Like Like: A Good Guide to a Bad Pet
See also the examples for turning a figure and for turning an equation into a target by starting its caption or math label respectively with a hash #
.
Now the third example links to a target:
->#Picori are invisible to adult humans.
Picori are invisible to adult humans.
The term ->#"Picori" is a Hylian exonym.
The term Picori
is a Hylian exonym.
Notice how the link in the fourth example above still points to the same target despite the added quotation marks. The following examples, however, use link texts that completely deviate from the target text:
The eastern hills connect to a lush forest->#`Minish Woods`.
The eastern hills connect to a lush forest.
According to a `zoological compendium`->#2, it is an octorok habitat.
According to a zoological compendium, it is an octorok habitat.
For developers
When Aneamal is converted to HTML, a target is translated to an id attribute. The id attribute usually resides on an HTML span element as you can see in the HTML code for the first example:
<span id='minish-woods'>Minish Woods</span> is inhabited by <span id='picori'>Picori</span>, tiny people who delight in making humans happy by hiding helpful items and rupees under grass and rocks all over the world.
The id corresponding to a target from the very beginning of a file’s caption, the citation of a quotation block or a math block’s label is added to the HTML figure, blockquote or div element respectively which wraps the whole block. The id attribute generated from an item’s number in a numbered list is added to the li element that represents the item in HTML. Hence the second example becomes:
<ol type='1'>
<li id='1' value='1'>Rem’s Anthology for Sleepless Nights</li>
<li id='2' value='2'>A Hyrulean Bestiary</li>
<li id='3' value='3'>Learn to Like Your Like Like: A Good Guide to a Bad Pet</li>
</ol>
Links to a target are translated to HTML a elements whose href attribute addresses the corresponding id elsewhere in the page. The third to sixths examples become:
<a href='#picori'>Picori</a> are invisible to adult humans.
The term <a href='#picori'><q>Picori</q></a> is a Hylian exonym.
The eastern hills connect to a lush <a href='#minish-woods'>forest</a>.
According to a <a href='#2'>zoological compendium</a>, it is an octorok habitat.
Translation of a target to an HTML id
- Normalization step:
- remove soft hyphens (U+00AD)
- replace no-break spaces (U+00A0) by spaces (U+0020)
- convert alphabetic characters to lowercase
- Main step:
- leave ASCII letters and digits untouched
- collapse all other ASCII bytes to single hyphens (U+002D)
- encode non-ASCII bytes as lowercase hexadecimal number
- Remove leading and trailing hyphens.