Changes

Jump to navigation Jump to search
2,513 bytes added ,  07:41, 24 March 2010
please extend!
== Overview ==
URLs can be typeset in various ways. You may specify a URL for later reuse via [[cmd:useURL|\useURL]]:
<texcode>
\useURL[aurl] [http://xkcd.com/149/] [] [I prefer hot dogs.]
</texcode>
where #1 is the identifier, #2 is the URL you want to point to, #3 a file (?, according to [[source:strc-ref.mkiv|strc-ref.mkiv line 1215]]) and #4 the text to be displayed where the URL is used.
Alternatively, you can use only two arguments and the URL will be used as its own text.
<texcode>
\useURL[anotherurl] [http://xkcd.com/224/]
</texcode>
(That way any character may appear inside the URL string without breaking things under certain circumstances, which can happen when you specify the URL itself as the fourth argument.)

Now that you have defined some URLs you are ready to dereference them by their identifier wherever you please. Don't forget to enable interaction for clickable WWW-look-and-feel.
<texcode>
\setupinteraction[state=start]
\starttext
\from[aurl] % typesets the URL description in color
\from[anotherurl] % typesets the URL in color
\stoptext
</texcode>

== Hyphenation ==
URLs tend to become large monsters under many circumstances but you may have a good reason not to conceal them from the reader.
This is where hyphenation comes in handy.
ConTeXt provides a dedicated mechanism for chopping them into pieces:
<texcode>
\hyphenatedurl{http://www.xkcd.com/163/} % not a good example for a huge URL, I know
</texcode>
This has some characters predefined where Hans “likes” URLs to break (see the list at the beginning of [[source:lang-url.lua|lang-url.lua]], cf. [http://www.ntg.nl/pipermail/ntg-context/2008/032959.html a message on ntg-context]).
If you prefer other characters you can add them via:
<texcode>
\sethyphenatedurlnormal{:=?&}
\sethyphenatedurlbefore{?&}
\sethyphenatedurlafter {:=}
</texcode>

URL hyphenation can, of course, be used wherever you need them.
<texcode>
\useURL[yaurl] [http://xkcd.com/638/] [] [\hyphenatedurl{http://xkcd.com/638/}]
\starttext
\from[yaurl]
\stoptext
</texcode>

== Other ways ==
Another way of typesetting URLs is the [[cmd:goto|\goto{#1}[#2]]] command. This expects the description text as first argument and the actual URL as the second one; note that it has to be wrapped in url(#2) to create a clickable link:
<texcode>
\goto{In Lua, array indices start from one.}[url(http://www.xkcd.com/163/)]
</texcode>
You may simply use
<texcode>
\url[yaurl]
</texcode>
as well, which behaves like \from[#1].
188

edits

Navigation menu