Changes

Jump to navigation Jump to search
1,757 bytes added ,  19:33, 5 October 2023
adapt display to the wiki
ConTeXt provides a dedicated mechanism for chopping them into pieces:
<context source=yes>
\enabledirectives[hyphenators.urls.packslashes] % this avoids consecutive slashes each in a different line
\sethyphenatedurlbefore{/} % but then they seem to be fixed to what comes before and after them
\startTEXpage[width=7em, foregroundstyle=\ttb] % just to display the output better
\hsize\zeropoint % to see where lines may be broken
\hyphenatedurl{http://bits.blogs.nytimes.com/2010/03/05/a-former-book-designer-says-good-riddance-to-print/?hpw}
\stopTEXpage
</context>
 
The previous sample shows all possible line breaks, since horizontal size (text width) has been set to zero ({{cmd|hsize}}{{cmd|zeropoint}}).
=== Hyphenation Rules ===
These special commands can be used in other cases, like {{cmd|useURL}}, too.
 
== Setting Color and Style ==
== Tips and Tricks ==
 
=== Using variable URLs ===
When using variables, or macros in general, it's necessary to consider that <code>\useURL</code> '''doesn't expand''', which means that any commands within will be treated like text and printed plainly, i.e. instead of the hyperlink the command name will be pasted to the browser or mail client. To circumvent this use <code>\expanded{}</code> around <code>\useURL</code>:
 
<texcode>
\expanded{\useURL[][][][]}
</texcode>
 
The following MWE demonstrates the issue.
 
<texcode>
\setupinteraction[state=start]
%
\setvariables[Sender][Mail={ntg-context@ntg.nl}]
%
\useURL[Direct][mailto:ntg-context@ntg.nl][][ntg-context@ntg.nl]
\useURL[Unexpanded][mailto:\getvariable{Sender}{Mail}][][\getvariable{Sender}{Mail}]
% same as above but within \expanded{}:
\expanded{\useURL[Expanded][mailto:\getvariable{Sender}{Mail}][][\getvariable{Sender}{Mail}]}
%
\starttext
\from[Direct] Direct input works\blank
\from[Unexpanded] Unexpanded fails\blank
\from[Expanded] Expanded works\blank
%
In the PDF mind the tooltips and how the wrong line transfers to the mail client.
\stoptext
</texcode>
=== Many Different Hyperrefs ===
But you have to consider one option to make it work:
* Setting <{{cmd>|asciimode</cmd> }} for the whole document.<p>Comments won’t work, because <code>%</code> will be considered a standard character.</p>
* Wrapping all URLs inside <{{cmd>|startasciimode</cmd>}}...<{{cmd>|stopasciimode</cmd>}}.<p>If you use URLs inside footnotes, it is the whole footnote which has to be inside the pair of commands.</p><p>Comments inside the mode won’t work.</p>
=== External Links ===
Create a macro for external links in a colour that is distinct from other document links.
<precontext source="yes">
% Enable document colours
\setupcolors[state=start,]
\def\Google{G\color[red]{o}\color[orange]{o}g\color[green]{l}\color[red]{e}}
%\starttext % makes no sense in the wiki\startTEXpage[offset=1dk, foregroundstyle=\tfb]
\completecontent
% \startchapter[title=chapter]
Search \index{source code}{source code} using \href{\Google{} Website}{http://google.com}! Read about
\index{syntax}{syntax}.
% \stopchapter \blank
\placeindex
\stopTEXpage%\stoptext% makes no sense in the wiki </precontext>
[[Category:Basics]]
[[Category:Interaction]]
139

edits

Navigation menu