1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <!-- This file was generated automatically. -->
3 <!-- Developers should not commit sundry patches against this file. -->
4 <!-- The source file (with documentation!) is in the admin directory. -->
5 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform" version=
"1.0">
6 <doc:reference xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0" id=
"scape">
8 <releaseinfo role=
"meta">
9 $Id: scape.mod.xsl,v
1.4 2004/
01/
23 11:
36:
06 j-devenish Exp $
13 <firstname>James
</firstname>
14 <surname>Devenish
</surname>
20 <holder>Ramon Casellas
</holder>
23 <title><productname condition=
"noindex">LaTeX
</productname> Active-character Escaping
</title>
25 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
26 <refpurpose>General text escaping for
<productname condition=
"noindex">LaTeX
</productname> active characters
</refpurpose>
29 Certain characters must be escaped so that
<productname condition=
"noindex">LaTeX
</productname> will typeset
30 them verbatim rather than attempting to interpret them as commands.
34 <title>Mapping Source
</title>
35 <programlisting><![CDATA[
<template name=
"scape">
37 <map from=
"<" to=
"\textless{}"/>
39 <map from=
">" to=
"\textgreater{}"/>
41 <map from=
"~" to=
"\textasciitilde{}"/>
43 <map from=
"^" to=
"\textasciicircum{}"/>
45 <map from=
"&" to=
"\&"/>
47 <map from=
"#" to=
"\#"/>
49 <map from=
"_" to=
"\_"/>
51 <map from=
"$" to=
"\$"/>
53 <map from=
"%" to=
"\%"/>
55 <map from=
"|" to=
"\docbooktolatexpipe{}"/>
57 <map from=
"{" to=
"\{"/>
59 <map from=
"}" to=
"\}"/>
61 <map from=
"\textbackslash " to=
"\textbackslash \ "/>
63 <map from=
"\" to=
"\textbackslash "/>
65 </template>]]
></programlisting>
68 <xsl:template name=
"scape">
69 <xsl:param name=
"string"/>
70 <xsl:call-template name=
"string-replace">
71 <xsl:with-param name=
"from"><</xsl:with-param>
72 <xsl:with-param name=
"to">\textless{}
</xsl:with-param>
73 <xsl:with-param name=
"string">
74 <xsl:call-template name=
"string-replace">
75 <xsl:with-param name=
"from">></xsl:with-param>
76 <xsl:with-param name=
"to">\textgreater{}
</xsl:with-param>
77 <xsl:with-param name=
"string">
78 <xsl:call-template name=
"string-replace">
79 <xsl:with-param name=
"from">~
</xsl:with-param>
80 <xsl:with-param name=
"to">\textasciitilde{}
</xsl:with-param>
81 <xsl:with-param name=
"string">
82 <xsl:call-template name=
"string-replace">
83 <xsl:with-param name=
"from">^
</xsl:with-param>
84 <xsl:with-param name=
"to">\textasciicircum{}
</xsl:with-param>
85 <xsl:with-param name=
"string">
86 <xsl:call-template name=
"string-replace">
87 <xsl:with-param name=
"from">&</xsl:with-param>
88 <xsl:with-param name=
"to">\
&</xsl:with-param>
89 <xsl:with-param name=
"string">
90 <xsl:call-template name=
"string-replace">
91 <xsl:with-param name=
"from">#
</xsl:with-param>
92 <xsl:with-param name=
"to">\#
</xsl:with-param>
93 <xsl:with-param name=
"string">
94 <xsl:call-template name=
"string-replace">
95 <xsl:with-param name=
"from">_
</xsl:with-param>
96 <xsl:with-param name=
"to">\_
</xsl:with-param>
97 <xsl:with-param name=
"string">
98 <xsl:call-template name=
"string-replace">
99 <xsl:with-param name=
"from">$
</xsl:with-param>
100 <xsl:with-param name=
"to">\$
</xsl:with-param>
101 <xsl:with-param name=
"string">
102 <xsl:call-template name=
"string-replace">
103 <xsl:with-param name=
"from">%
</xsl:with-param>
104 <xsl:with-param name=
"to">\%
</xsl:with-param>
105 <xsl:with-param name=
"string">
106 <xsl:call-template name=
"string-replace">
107 <xsl:with-param name=
"from">|
</xsl:with-param>
108 <xsl:with-param name=
"to">\docbooktolatexpipe{}
</xsl:with-param>
109 <xsl:with-param name=
"string">
110 <xsl:call-template name=
"string-replace">
111 <xsl:with-param name=
"from">{
</xsl:with-param>
112 <xsl:with-param name=
"to">\{
</xsl:with-param>
113 <xsl:with-param name=
"string">
114 <xsl:call-template name=
"string-replace">
115 <xsl:with-param name=
"from">}
</xsl:with-param>
116 <xsl:with-param name=
"to">\}
</xsl:with-param>
117 <xsl:with-param name=
"string">
118 <xsl:call-template name=
"string-replace">
119 <xsl:with-param name=
"from">\textbackslash
</xsl:with-param>
120 <xsl:with-param name=
"to">\textbackslash \
</xsl:with-param>
121 <xsl:with-param name=
"string">
122 <xsl:call-template name=
"string-replace">
123 <xsl:with-param name=
"from">\
</xsl:with-param>
124 <xsl:with-param name=
"to">\textbackslash
</xsl:with-param>
125 <xsl:with-param name=
"string" select=
"$string"/>
154 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
155 <refpurpose>Escape characters for use with
<function condition=
"latex">index
</function>
156 <productname condition=
"noindex">LaTeX
</productname> command
</refpurpose>
159 In addition to the characters from
<xref linkend=
"template.scape"/>,
160 certain extra characters must be escaped so that
<productname condition=
"noindex">LaTeX
</productname> will not treat
161 them as indexing directives.
165 <title>Mapping Source
</title>
166 <programlisting><![CDATA[
<template name=
"scape-indexterm">
168 <map from=
"!" to=
""!"/>
170 <map from=
"|" to=
"\ensuremath{"|}"/>
172 <map from=
"@" to=
""@"/>
174 <map from=
"<" to=
"\textless{}"/>
176 <map from=
">" to=
"\textgreater{}"/>
178 <map from=
"~" to=
"\textasciitilde{}"/>
180 <map from=
"^" to=
"\textasciicircum{}"/>
182 <map from=
"&" to=
"\&"/>
184 <map from=
"#" to=
"\#"/>
186 <map from=
"_" to=
"\_"/>
188 <map from=
"$" to=
"\$"/>
190 <map from=
"%" to=
"\%"/>
192 <map from=
"\}" to=
"\textbraceright{}"/>
194 <map from=
"{" to=
"\textbraceleft{}"/>
196 <map from=
"}" to=
"\}"/>
198 <map from=
""" to=
""""/>
200 <map from=
"\textbackslash " to=
"\textbackslash \ "/>
202 <map from=
"\" to=
"\textbackslash "/>
204 </template>]]
></programlisting>
207 <xsl:template name=
"scape-indexterm">
208 <xsl:param name=
"string"/>
209 <xsl:call-template name=
"string-replace">
210 <xsl:with-param name=
"from">!
</xsl:with-param>
211 <xsl:with-param name=
"to">"!</xsl:with-param>
212 <xsl:with-param name="string
">
213 <xsl:call-template name="string-replace
">
214 <xsl:with-param name="from
">|</xsl:with-param>
215 <xsl:with-param name="to
">\ensuremath{"|}
</xsl:with-param>
216 <xsl:with-param name=
"string">
217 <xsl:call-template name=
"string-replace">
218 <xsl:with-param name=
"from">@
</xsl:with-param>
219 <xsl:with-param name=
"to">"@</xsl:with-param>
220 <xsl:with-param name="string
">
221 <xsl:call-template name="string-replace
">
222 <xsl:with-param name="from
"><</xsl:with-param>
223 <xsl:with-param name="to
">\textless{}</xsl:with-param>
224 <xsl:with-param name="string
">
225 <xsl:call-template name="string-replace
">
226 <xsl:with-param name="from
">></xsl:with-param>
227 <xsl:with-param name="to
">\textgreater{}</xsl:with-param>
228 <xsl:with-param name="string
">
229 <xsl:call-template name="string-replace
">
230 <xsl:with-param name="from
">~</xsl:with-param>
231 <xsl:with-param name="to
">\textasciitilde{}</xsl:with-param>
232 <xsl:with-param name="string
">
233 <xsl:call-template name="string-replace
">
234 <xsl:with-param name="from
">^</xsl:with-param>
235 <xsl:with-param name="to
">\textasciicircum{}</xsl:with-param>
236 <xsl:with-param name="string
">
237 <xsl:call-template name="string-replace
">
238 <xsl:with-param name="from
">&</xsl:with-param>
239 <xsl:with-param name="to
">\&</xsl:with-param>
240 <xsl:with-param name="string
">
241 <xsl:call-template name="string-replace
">
242 <xsl:with-param name="from
">#</xsl:with-param>
243 <xsl:with-param name="to
">\#</xsl:with-param>
244 <xsl:with-param name="string
">
245 <xsl:call-template name="string-replace
">
246 <xsl:with-param name="from
">_</xsl:with-param>
247 <xsl:with-param name="to
">\_</xsl:with-param>
248 <xsl:with-param name="string
">
249 <xsl:call-template name="string-replace
">
250 <xsl:with-param name="from
">$</xsl:with-param>
251 <xsl:with-param name="to
">\$</xsl:with-param>
252 <xsl:with-param name="string
">
253 <xsl:call-template name="string-replace
">
254 <xsl:with-param name="from
">%</xsl:with-param>
255 <xsl:with-param name="to
">\%</xsl:with-param>
256 <xsl:with-param name="string
">
257 <xsl:call-template name="string-replace
">
258 <xsl:with-param name="from
">\}</xsl:with-param>
259 <xsl:with-param name="to
">\textbraceright{}</xsl:with-param>
260 <xsl:with-param name="string
">
261 <xsl:call-template name="string-replace
">
262 <xsl:with-param name="from
">{</xsl:with-param>
263 <xsl:with-param name="to
">\textbraceleft{}</xsl:with-param>
264 <xsl:with-param name="string
">
265 <xsl:call-template name="string-replace
">
266 <xsl:with-param name="from
">}</xsl:with-param>
267 <xsl:with-param name="to
">\}</xsl:with-param>
268 <xsl:with-param name="string
">
269 <xsl:call-template name="string-replace
">
270 <xsl:with-param name="from
">"</xsl:with-param>
271 <xsl:with-param name=
"to">""</xsl:with-param>
272 <xsl:with-param name=
"string">
273 <xsl:call-template name=
"string-replace">
274 <xsl:with-param name=
"from">\textbackslash
</xsl:with-param>
275 <xsl:with-param name=
"to">\textbackslash \
</xsl:with-param>
276 <xsl:with-param name=
"string">
277 <xsl:call-template name=
"string-replace">
278 <xsl:with-param name=
"from">\
</xsl:with-param>
279 <xsl:with-param name=
"to">\textbackslash
</xsl:with-param>
280 <xsl:with-param name=
"string" select=
"$string"/>
317 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
318 <refpurpose>Verbatim-text escaping for
<productname condition=
"noindex">LaTeX
</productname> active characters
</refpurpose>
320 <title>Mapping Source
</title>
321 <programlisting><![CDATA[
<template name=
"scape-verbatim">
323 <map from=
"~" to=
"\textasciitilde{}"/>
325 <map from=
"^" to=
"\textasciicircum{}"/>
327 <map from=
"&" to=
"\&"/>
329 <map from=
"#" to=
"\#"/>
331 <map from=
"_" to=
"\_\dbz{}"/>
333 <map from=
"$" to=
"\$"/>
335 <map from=
"%" to=
"\%"/>
337 <map from=
"/" to=
"/\dbz{}"/>
339 <map from=
"-" to=
"-\dbz{}"/>
341 <map from=
"+" to=
"+\dbz{}"/>
343 <map from=
"." to=
".\dbz{}"/>
345 <map from=
"(" to=
"(\dbz{}"/>
347 <map from=
")" to=
")\dbz{}"/>
349 <map from=
"{" to=
"\docbooktolatexgobble\string\{"/>
351 <map from=
"}" to=
"\docbooktolatexgobble\string\}"/>
353 <map from=
"\" to=
"\docbooktolatexgobble\string\\"/>
355 </template>]]
></programlisting>
358 <xsl:template name=
"scape-verbatim">
359 <xsl:param name=
"string"/>
360 <xsl:call-template name=
"string-replace">
361 <xsl:with-param name=
"from">~
</xsl:with-param>
362 <xsl:with-param name=
"to">\textasciitilde{}
</xsl:with-param>
363 <xsl:with-param name=
"string">
364 <xsl:call-template name=
"string-replace">
365 <xsl:with-param name=
"from">^
</xsl:with-param>
366 <xsl:with-param name=
"to">\textasciicircum{}
</xsl:with-param>
367 <xsl:with-param name=
"string">
368 <xsl:call-template name=
"string-replace">
369 <xsl:with-param name=
"from">&</xsl:with-param>
370 <xsl:with-param name=
"to">\
&</xsl:with-param>
371 <xsl:with-param name=
"string">
372 <xsl:call-template name=
"string-replace">
373 <xsl:with-param name=
"from">#
</xsl:with-param>
374 <xsl:with-param name=
"to">\#
</xsl:with-param>
375 <xsl:with-param name=
"string">
376 <xsl:call-template name=
"string-replace">
377 <xsl:with-param name=
"from">_
</xsl:with-param>
378 <xsl:with-param name=
"to">\_\dbz{}
</xsl:with-param>
379 <xsl:with-param name=
"string">
380 <xsl:call-template name=
"string-replace">
381 <xsl:with-param name=
"from">$
</xsl:with-param>
382 <xsl:with-param name=
"to">\$
</xsl:with-param>
383 <xsl:with-param name=
"string">
384 <xsl:call-template name=
"string-replace">
385 <xsl:with-param name=
"from">%
</xsl:with-param>
386 <xsl:with-param name=
"to">\%
</xsl:with-param>
387 <xsl:with-param name=
"string">
388 <xsl:call-template name=
"string-replace">
389 <xsl:with-param name=
"from">/
</xsl:with-param>
390 <xsl:with-param name=
"to">/\dbz{}
</xsl:with-param>
391 <xsl:with-param name=
"string">
392 <xsl:call-template name=
"string-replace">
393 <xsl:with-param name=
"from">-
</xsl:with-param>
394 <xsl:with-param name=
"to">-\dbz{}
</xsl:with-param>
395 <xsl:with-param name=
"string">
396 <xsl:call-template name=
"string-replace">
397 <xsl:with-param name=
"from">+
</xsl:with-param>
398 <xsl:with-param name=
"to">+\dbz{}
</xsl:with-param>
399 <xsl:with-param name=
"string">
400 <xsl:call-template name=
"string-replace">
401 <xsl:with-param name=
"from">.
</xsl:with-param>
402 <xsl:with-param name=
"to">.\dbz{}
</xsl:with-param>
403 <xsl:with-param name=
"string">
404 <xsl:call-template name=
"string-replace">
405 <xsl:with-param name=
"from">(
</xsl:with-param>
406 <xsl:with-param name=
"to">(\dbz{}
</xsl:with-param>
407 <xsl:with-param name=
"string">
408 <xsl:call-template name=
"string-replace">
409 <xsl:with-param name=
"from">)
</xsl:with-param>
410 <xsl:with-param name=
"to">)\dbz{}
</xsl:with-param>
411 <xsl:with-param name=
"string">
412 <xsl:call-template name=
"string-replace">
413 <xsl:with-param name=
"from">{
</xsl:with-param>
414 <xsl:with-param name=
"to">\docbooktolatexgobble\string\{
</xsl:with-param>
415 <xsl:with-param name=
"string">
416 <xsl:call-template name=
"string-replace">
417 <xsl:with-param name=
"from">}
</xsl:with-param>
418 <xsl:with-param name=
"to">\docbooktolatexgobble\string\}
</xsl:with-param>
419 <xsl:with-param name=
"string">
420 <xsl:call-template name=
"string-replace">
421 <xsl:with-param name=
"from">\
</xsl:with-param>
422 <xsl:with-param name=
"to">\docbooktolatexgobble\string\\
</xsl:with-param>
423 <xsl:with-param name=
"string" select=
"$string"/>
456 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
457 <refpurpose>Escape characters for use with the
<productname>hyperref
</productname>
458 <productname condition=
"noindex">LaTeX
</productname> package
</refpurpose>
460 <title>Mapping Source
</title>
461 <programlisting><![CDATA[
<template name=
"scape-href">
463 <map from=
"&" to=
"\&"/>
465 <map from=
"%" to=
"\%"/>
467 <map from=
"[" to=
"\["/>
469 <map from=
"]" to=
"\]"/>
471 <map from=
"{" to=
"\{"/>
473 <map from=
"}" to=
"\}"/>
475 <map from=
"\" to=
"\docbooktolatexgobble\string\\"/>
477 </template>]]
></programlisting>
480 <xsl:template name=
"scape-href">
481 <xsl:param name=
"string"/>
482 <xsl:call-template name=
"string-replace">
483 <xsl:with-param name=
"from">&</xsl:with-param>
484 <xsl:with-param name=
"to">\
&</xsl:with-param>
485 <xsl:with-param name=
"string">
486 <xsl:call-template name=
"string-replace">
487 <xsl:with-param name=
"from">%
</xsl:with-param>
488 <xsl:with-param name=
"to">\%
</xsl:with-param>
489 <xsl:with-param name=
"string">
490 <xsl:call-template name=
"string-replace">
491 <xsl:with-param name=
"from">[
</xsl:with-param>
492 <xsl:with-param name=
"to">\[
</xsl:with-param>
493 <xsl:with-param name=
"string">
494 <xsl:call-template name=
"string-replace">
495 <xsl:with-param name=
"from">]
</xsl:with-param>
496 <xsl:with-param name=
"to">\]
</xsl:with-param>
497 <xsl:with-param name=
"string">
498 <xsl:call-template name=
"string-replace">
499 <xsl:with-param name=
"from">{
</xsl:with-param>
500 <xsl:with-param name=
"to">\{
</xsl:with-param>
501 <xsl:with-param name=
"string">
502 <xsl:call-template name=
"string-replace">
503 <xsl:with-param name=
"from">}
</xsl:with-param>
504 <xsl:with-param name=
"to">\}
</xsl:with-param>
505 <xsl:with-param name=
"string">
506 <xsl:call-template name=
"string-replace">
507 <xsl:with-param name=
"from">\
</xsl:with-param>
508 <xsl:with-param name=
"to">\docbooktolatexgobble\string\\
</xsl:with-param>
509 <xsl:with-param name=
"string" select=
"$string"/>
524 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
525 <refpurpose>Escape characters for use with the
<productname>url
</productname>
526 <productname condition=
"noindex">LaTeX
</productname> package
</refpurpose>
528 <title>Mapping Source
</title>
529 <programlisting><![CDATA[
<template name=
"scape-url">
531 <map from=
"&" to=
"\string&"/>
533 <map from=
"%" to=
"\%"/>
535 <map from=
"{" to=
"\{"/>
537 <map from=
"}" to=
"\}"/>
539 <map from=
"\" to=
"\docbooktolatexgobble\string\\"/>
541 </template>]]
></programlisting>
544 <xsl:template name=
"scape-url">
545 <xsl:param name=
"string"/>
546 <xsl:call-template name=
"string-replace">
547 <xsl:with-param name=
"from">&</xsl:with-param>
548 <xsl:with-param name=
"to">\string
&</xsl:with-param>
549 <xsl:with-param name=
"string">
550 <xsl:call-template name=
"string-replace">
551 <xsl:with-param name=
"from">%
</xsl:with-param>
552 <xsl:with-param name=
"to">\%
</xsl:with-param>
553 <xsl:with-param name=
"string">
554 <xsl:call-template name=
"string-replace">
555 <xsl:with-param name=
"from">{
</xsl:with-param>
556 <xsl:with-param name=
"to">\{
</xsl:with-param>
557 <xsl:with-param name=
"string">
558 <xsl:call-template name=
"string-replace">
559 <xsl:with-param name=
"from">}
</xsl:with-param>
560 <xsl:with-param name=
"to">\}
</xsl:with-param>
561 <xsl:with-param name=
"string">
562 <xsl:call-template name=
"string-replace">
563 <xsl:with-param name=
"from">\
</xsl:with-param>
564 <xsl:with-param name=
"to">\docbooktolatexgobble\string\\
</xsl:with-param>
565 <xsl:with-param name=
"string" select=
"$string"/>
576 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
577 <refpurpose>Escape the ] character in
<productname condition=
"noindex">LaTeX
</productname> optional arguments (experimental)
</refpurpose>
579 <title>Mapping Source
</title>
580 <programlisting><![CDATA[
<template name=
"scape-optionalarg">
582 <map from=
"]" to=
"{\rbrack}"/>
584 </template>]]
></programlisting>
587 <xsl:template name=
"scape-optionalarg">
588 <xsl:param name=
"string"/>
589 <xsl:call-template name=
"string-replace">
590 <xsl:with-param name=
"from">]
</xsl:with-param>
591 <xsl:with-param name=
"to">{\rbrack}
</xsl:with-param>
592 <xsl:with-param name=
"string" select=
"$string"/>
595 <doc:template xmlns:
doc=
"http://nwalsh.com/xsl/documentation/1.0">
596 <refpurpose>Basic line-breaking for verbatim text
</refpurpose>
599 Allow line breaking after certain characters.
600 Text should be escaped with the
<xref linkend=
"template.scape"/>
601 template before being passed to this template.
605 <title>Mapping Source
</title>
606 <programlisting><![CDATA[
<template name=
"scape-slash">
608 <map from=
"." to=
".\dbz{}"/>
610 <map from=
"/" to=
"/\dbz{}"/>
612 </template>]]
></programlisting>
615 <xsl:template name=
"scape-slash">
616 <xsl:param name=
"string"/>
617 <xsl:call-template name=
"string-replace">
618 <xsl:with-param name=
"from">.
</xsl:with-param>
619 <xsl:with-param name=
"to">.\dbz{}
</xsl:with-param>
620 <xsl:with-param name=
"string">
621 <xsl:call-template name=
"string-replace">
622 <xsl:with-param name=
"from">/
</xsl:with-param>
623 <xsl:with-param name=
"to">/\dbz{}
</xsl:with-param>
624 <xsl:with-param name=
"string" select=
"$string"/>