1 <?xml version=
"1.0" encoding=
"utf-8"?>
2 <!DOCTYPE xsl:stylesheet [
4 <!-- "xml:space='preserve'" is needed for use with libxslt -->
5 <!-- "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" is needed for
7 <!-- Used to create a blank line -->
8 <!ENTITY tCR
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xml:space='preserve'>&CR;</xsl:text>">
9 <!-- Used when the line before must be ended -->
10 <!ENTITY tEOL
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xml:space='preserve'>&CR;</xsl:text>">
11 <!ENTITY tSP
"<xsl:text xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xml:space='preserve'> </xsl:text>">
15 Copyright (C) 2005, 2006, 2009 Stefan Merten, David Priest
17 xml2rst.xsl is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License as published
19 by the Free Software Foundation; either version 2 of the License,
20 or (at your option) any later version.
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 General Public License for more details.
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
33 <!-- ********************************************************************** -->
34 <!-- ********************************************************************** -->
36 <!-- These elements in the DTD need support:
38 - ``colspec`` has attribute "stub %yesorno; #IMPLIED"
40 - ``document`` has attribute "title CDATA #IMPLIED"
42 Probably rendered by the `.. title::` directive
47 Set namespace extensions. These are used as [shortname]:[tag] throughout the
49 xsl: eXtensible Stylesheet Language
50 u: user extensions (indicates utility 'call-template' routines defined in
52 data: Data elements used by the stylesheet
56 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
59 exclude-result-prefixes=
"data">
63 omit-xml-declaration=
"yes"
66 <!-- ******************************************************************** -->
67 <!-- ******************************************************************** -->
69 <!-- Parameter to configure title markup; see manual page for description -->
72 select=
"'o=o-u=u-u~u`u,u.'"/>
74 <!-- Parameter for folding long lines; see manual page for description -->
79 <!-- ******************************************************************** -->
80 <!-- ******************************************************************** -->
87 name=
"structural_elements"
88 select=
"'*document*section*topic*sidebar*'"/>
91 name=
"structural_subelements"
92 select=
"'*title*subtitle*docinfo*decoration*transition*'"/>
95 name=
"bibliographic_elements"
96 select=
"'*address*author*authors*contact*copyright*date*field*organization*revision*status*version*'"/>
99 name=
"decorative_elements"
100 select=
"'*footer*header*'"/>
103 name=
"simple_body_elements_no_substitution"
104 select=
"'*comment*doctest_block*image*literal_block*paragraph*pending*raw*rubric*target*'"/>
107 name=
"folding_elements"
108 select=
"concat('*comment*paragraph*rubric*attribution*caption*line*', substring-after($bibliographic_elements, '*'))"/>
111 name=
"simple_body_elements"
112 select=
"concat($simple_body_elements_no_substitution, 'substitution_definition*')"/>
115 name=
"compound_body_elements"
116 select=
"'*admonition*attention*block_quote*bullet_list*caution*citation*compound*danger*definition_list*enumerated_list*error*field_list*figure*footnote*hint*important*line_block*note*option_list*system_message*table*tip*warning*container*'"/>
120 select=
"concat($simple_body_elements, substring-after($compound_body_elements, '*'))"/>
124 select=
"'*admonition*attention*caution*danger*error*hint*important*note*tip*warning*'"/>
127 name=
"simple_body_subelements"
128 select=
"'*attribution*caption*classifier*colspec*field_name*label*line*option_argument*option_string*term*'"/>
131 name=
"compound_body_subelements"
132 select=
"'*definition*definition_list_item*description*entry*field*field_body*legend*list_item*option*option_group*option_list_item*row*tbody*tgroup*thead*'"/>
135 name=
"inline_elements"
136 select=
"'*abbreviation*acronym*citation_reference*emphasis*footnote_reference*generated*image*inline*literal*problematic*reference*strong*subscript*substitution_reference*superscript*target*title_reference*raw*'"/>
139 name=
"inline_containers"
140 select=
"concat($simple_body_elements_no_substitution, substring-after($inline_elements, '*'))"/>
144 select=
"'*admonition*attention*caution*comment*danger*error*footnote*hint*important*note*tip*warning*image*figure*topic*sidebar*rubric*meta*raw*citation*compound*substitution_definition*container*'"/>
147 name=
"titled_elements"
148 select=
"'*sidebar*topic*admonition*'"/>
152 select=
"concat($structural_elements, substring-after($structural_subelements, '*'), substring-after($body_elements, '*'))"/>
155 name=
"adornment_characters"
156 select=
"concat($apos, '!"#$%&()*+,-./:;<=>?@[\]^_`{|}~')"/>
158 <!-- ******************************************************************** -->
159 <!-- ******************************************************************** -->
162 Content Model: ((title, subtitle?)?, docinfo?, decoration?,
165 Attributes: The document element contains only the common attributes: ids,
166 names, dupnames, source, and classes.
168 Depending on the source of the data and the stage of processing, the
169 "document" may not initially contain a "title". A document title is not
170 directly representable in reStructuredText. Instead, a lone top-level section
171 may have its title promoted to become the document title, and similarly for a
172 lone second-level (sub)section's title to become the document subtitle. The
173 "docinfo" may be transformed from an initial field_list, and "decoration" is
174 usually constructed programmatically.
176 <!-- == structural_element -->
180 test=
"//generated[@classes = 'sectnum']">
181 <xsl:text>.. section-numbering::
</xsl:text>
186 name=
"u:outputClass">
191 <xsl:apply-templates/>
194 <!-- ******************************************************************** -->
197 Content Model: (title, %structure.model;)
198 Attributes: The section element contains only the common attributes: ids,
199 names, dupnames, source, and classes.
201 <!-- == structural_element -->
205 name=
"u:outputClass"/>
208 <xsl:apply-templates/>
211 <!-- == structural_element -->
213 match=
"section[@classes = 'system-messages']"/>
214 <!-- Ignore system messages completely -->
215 <!-- This should be really in `generated' -->
217 <!-- ******************************************************************** -->
220 Content Model: (title, subtitle?, (%body.elements;)+)
221 Attributes: The sidebar element contains only the common attributes: ids,
222 names, dupnames, source, and classes.
224 <!-- == structural_element == directive -->
229 <xsl:text>.. sidebar::
</xsl:text>
239 select=
"'subtitle'"/>
245 select=
"ancestor-or-self::*"/>
250 <!-- Always blank line after parameter block -->
253 select=
"*[not(self::title) and not(self::subtitle)]"/>
256 <!-- ******************************************************************** -->
259 Content Model: (title?, (%body.elements;)+)
260 Attributes: The topic element contains only the common attributes: ids,
261 names, dupnames, source, and classes.
263 <!-- == structural_element == directive -->
268 <xsl:text>.. topic::
</xsl:text>
275 select=
"*[not(self::title)]"/>
278 <!-- == structural_element == directive -->
280 match=
"topic[starts-with(@classes, 'contents')]">
283 <xsl:text>.. contents::
</xsl:text>
291 select=
"@*[name() != 'ids' and name() != 'names' and name() != 'classes']"/>
295 select=
"substring-before(@classes, ' local')"/>
297 name=
"realClassesLocal"
298 select=
"normalize-space(substring-after(@classes, 'contents'))"/>
300 name=
"realClassesNode">
305 select=
"normalize-space(substring-before($realClassesLocal, 'local'))"/>
309 select=
"$realClassesLocal"/>
315 select=
"string($realClassesNode)"/>
328 select=
"ancestor-or-self::*"/>
340 select=
"$realClasses"/>
343 select=
"ancestor-or-self::*"/>
346 <!-- Autogenerated content is discarded -->
350 <!-- == structural_element == directive -->
352 match=
"topic[@classes='dedication' or @classes='abstract']">
355 <xsl:text>:
</xsl:text>
358 <xsl:text>:
</xsl:text>
361 select=
"*[not(self::title)]"/>
364 <!-- ******************************************************************** -->
367 Content Model: (title, (%body.elements;)+)
368 Attributes: The admonition element contains only the common attributes:
369 ids, names, dupnames, source, and classes.
371 <!-- == compound_body_element == directive -->
376 <xsl:text>.. admonition::
</xsl:text>
384 select=
"@*[name() != 'classes' or not(starts-with(., 'admonition-'))]"/>
389 select=
"*[not(self::title)]"/>
392 <!-- ******************************************************************** -->
395 Content Model: (%body.elements;)+
396 Attributes: The note element contains only the common attributes: ids,
397 names, dupnames, source, and classes.
399 <!-- == compound_body_element == directive -->
401 match=
"attention | caution | danger | error | hint | important | note | tip | warning">
403 name=
"u:outputClass"/>
406 <xsl:text>..
</xsl:text>
409 <xsl:text>::
</xsl:text>
414 select=
"@*[name() != 'classes']"/>
416 <xsl:apply-templates/>
419 <!-- ******************************************************************** -->
422 Content Model: (header?, footer?)
423 Attributes: The decoration element contains only the common attributes:
424 ids, names, dupnames, source, and classes.
426 Although the content model doesn't specifically require contents, no empty
427 decoration elements are ever created.
429 <!-- == structural_subelement -->
431 match=
"//document/decoration">
432 <xsl:apply-templates/>
435 <!-- TODO To be rendered as `.. header::` directive -->
436 <!-- == decorative_element -->
438 match=
"//document/decoration/header">
439 <xsl:apply-templates/>
442 <!-- TODO To be rendered as `.. footer::` directive -->
443 <!-- == decorative_element -->
445 match=
"//document/decoration/footer">
446 <xsl:apply-templates/>
449 <!-- ******************************************************************** -->
452 Content Model: (%bibliographic.elements;)+
453 Attributes: The docinfo element contains only the common attributes: ids,
454 names, dupnames, source, and classes.
456 <!-- == structural_subelement -->
460 name=
"u:outputClass"/>
463 <xsl:apply-templates/>
468 <!-- ******************************************************************** -->
471 Content Model: ((author, organization?, address?, contact?)+)
472 Attributes: The authors element contains only the common attributes: ids,
473 names, dupnames, source, and classes.
475 In reStructuredText, multiple author's names are separated with semicolons
476 (";") or commas (","); semicolons take precedence. There is currently no way
477 to represent the author's organization, address, or contact in a
478 reStructuredText "Authors" field.
480 <!-- == bibliographic_element == folding_element -->
482 match=
"docinfo/authors">
484 name=
"u:outputFolding">
487 <xsl:text>:
</xsl:text>
490 <xsl:text>:
</xsl:text>
496 Content Model: %text.model;
497 Attributes: All docinfo elements contains the common attributes (ids,
498 names, dupnames, source, and classes)
499 Some docinfo elements also have xml:space.
502 match=
"docinfo/authors/*">
503 <xsl:apply-templates/>
504 <!-- no semicolon after final author -->
506 test=
"generate-id(current()) != generate-id(../*[last()])">
507 <xsl:text>;
</xsl:text>
512 Content Model: (field_name, field_body)
513 Attributes: The field element contains only the common attributes: ids,
514 names, dupnames, source, and classes.
516 <!-- == bibliographic_element -->
518 match=
"docinfo/field">
519 <!-- contents handled by ordinary field lists -->
520 <xsl:apply-templates/>
521 <!-- Supply an EOL because following elements do not recognize this -->
526 Content Model: %text.model;
527 Attributes: All docinfo elements contains the common attributes (ids,
528 names, dupnames, source, and classes)
529 Some docinfo elements also have xml:space.
531 <!-- == bibliographic_element == folding_element -->
533 match=
"docinfo/*[name()!='authors' and name()!='field']">
535 name=
"u:outputFolding">
538 <xsl:text>:
</xsl:text>
541 <xsl:text>:
</xsl:text>
546 <!-- ******************************************************************** -->
550 Attributes: The transition element contains only the common attributes:
551 ids, names, dupnames, source, and classes.
553 <!-- == structural_subelement -->
557 name=
"u:outputClass"/>
558 &tCR; <!-- req: blank line before -->
559 <xsl:text>-----
</xsl:text>
561 <!-- Add a required blank line after unless class follows immediately -->
563 test=
"not(following-sibling::*[1]/@classes)">
568 <!-- ******************************************************************** -->
569 <!-- ******************************************************************** -->
572 IFF there is a /document/title element, it is the publication's title. All
573 other titles will appear within sections.
575 Content Model: %text.model;
576 Attributes: The title element contains the common attributes (ids, names,
577 dupnames, source, and classes), plus refid and auto.
578 refid is used as a backlink to a table of contents entry.
579 auto is used to indicate (with value "1") that the title has been
580 numbered automatically.
582 <!-- == structural_subelement -->
584 match=
"//document/title">
586 name=
"u:outputClass"/>
589 <!-- Catch the title text as it is rendered so its length can be
591 <xsl:apply-templates/>
595 select=
"normalize-space($textWS)"/>
598 select=
"string-length($text)"/>
622 <!-- ******************************************************************** -->
625 Title Underlines are defined by their position within the tree.
627 Content Model: %text.model;
628 Attributes: The title element contains the common attributes (ids, names,
629 dupnames, source, and classes), plus refid and auto.
630 refid is used as a backlink to a table of contents entry.
631 auto is used to indicate (with value "1") that the title has been
632 numbered automatically.
634 <!-- == structural_subelement -->
636 match=
"section/title">
638 name=
"u:outputClass"/>
641 <!-- catch the title text as it is rendered -->
642 <xsl:apply-templates/>
646 select=
"normalize-space($textWS)"/>
649 select=
"string-length($text)"/>
652 select=
"count(ancestor::section)"/>
660 select=
"$depth + 2"/>
672 select=
"$depth + 2"/>
674 <!-- Add a blank line after unless structure follows immediately -->
676 test=
"not(contains(concat($structural_elements, $compound_body_elements), concat('*', name(following-sibling::*[1]), '*')) or following-sibling::*[1]/@classes)">
681 <!-- ******************************************************************** -->
684 Content Model: %text.model;
685 Attributes: The title element contains the common attributes (ids, names,
686 dupnames, source, and classes), plus refid and auto.
687 refid is used as a backlink to a table of contents entry.
688 auto is used to indicate (with value "1") that the title has been
689 numbered automatically.
691 <!-- == structural_subelement -->
695 name=
"u:outputClass">
697 name=
"alreadyBlanked"
700 <!-- blank line provided by parent -->
701 <xsl:apply-templates/>
702 <!-- no EOL: provided by parent -->
705 <!-- ******************************************************************** -->
708 IFF there is a /document/title element, it is the publication's title. All
709 other titles will appear within sections.
711 Content Model: %text.model;
712 Attributes: The subtitle element contains only the common attributes:
713 ids, names, dupnames, source, and classes.
715 <!-- == structural_subelement -->
717 match=
"//document/subtitle">
719 name=
"u:outputClass"/>
722 <!-- Catch the title text as it is rendered -->
723 <xsl:apply-templates/>
727 select=
"normalize-space($textWS)"/>
730 select=
"string-length($text)"/>
732 <!-- always a blank line above -->
757 <!-- ******************************************************************** -->
760 Content Model: %text.model;
761 Attributes: The subtitle element contains only the common attributes: ids,
762 names, dupnames, source, and classes.
764 <!-- == structural_subelement -->
766 match=
"sidebar/subtitle">
768 name=
"u:outputClass"/>
771 <xsl:apply-templates/>
776 <!-- ******************************************************************** -->
777 <!-- ******************************************************************** -->
780 Content Model: %text.model;
781 Attributes: The comment element contains only the common attributes: ids,
782 names, dupnames, source, and classes.
784 <!-- == simple_body_element == folding_element == directive -->
790 name=
"u:outputFolding">
793 <xsl:text>..
</xsl:text>
798 <!-- ******************************************************************** -->
801 Content Model: %text.model;
802 Attributes: The doctest_block element contains the common attributes (ids,
803 names, dupnames, source, and classes), plus xml:space.
805 <!-- == simple_body_element -->
807 match=
"doctest_block">
809 name=
"u:outputClass"/>
812 <xsl:apply-templates/>
816 <!-- ******************************************************************** -->
818 <!-- An image element can have various roles; they are all covered here -->
819 <!-- == simple_body_element == inline_element == directive -->
824 test=
"contains($inline_containers, concat('*', name(..), '*')) and @alt">
825 <!-- An inline image with an `@alt' - must be a substitution
827 <xsl:text>|
</xsl:text>
828 <!-- Original text is lost - use what we have -->
831 <xsl:text>|
</xsl:text>
836 test=
"not(parent::figure)">
838 test=
"not(parent::substitution_definition)">
841 <xsl:text>..
</xsl:text>
843 <xsl:text>image::
</xsl:text>
850 test=
"parent::figure">
851 <!-- `@classes' is special because it is in the parent -->
858 select=
"'figclass'"/>
861 select=
"../@classes"/>
864 select=
"ancestor::*"/>
867 <!-- `@align' is special because it is in the parent -->
880 select=
"ancestor::*"/>
885 <!-- `figure' would add one level of indentation -->
888 select=
"ancestor::*"/>
892 test=
"parent::substitution_definition">
895 <!-- `@alt' only for the real images -->
898 select=
"@*[name() != 'alt']"/>
906 select=
"@*[name() != 'ids' and name() != 'names']"/>
911 test=
"parent::reference">
912 <!-- A clickable image -->
923 <!-- An internal link -->
925 name=
"u:inlineReference">
932 <!-- An external link -->
934 select=
"../@refuri"/>
940 select=
"ancestor-or-self::*"/>
943 <!-- Always blank line after parameter block -->
949 <!-- ******************************************************************** -->
952 Content Model: (line_block | line)+
953 Attributes: The line_block element contains the common attributes (ids,
954 names, dupnames, source, and classes), plus xml:space.
956 <!-- == compound_body_element -->
960 name=
"u:outputClass"/>
963 select=
"name(..) = 'line_block'"/>
965 test=
"not($isEmbedded)">
969 <xsl:apply-templates/>
972 <!-- ******************************************************************** -->
975 Content Model: %text.model;
976 Attributes: The line element contains the common attributes (ids,
977 names, dupnames, source, and classes).
979 <!-- == simple_body_subelement == folding_element -->
983 name=
"u:outputClass"/>
994 <!-- Only for non-empty lines -->
996 name=
"lineBlockIndent">
997 <!-- Very special indendation for nested `line_block's -->
999 select=
"ancestor::line_block[position() > 1]">
1005 </xsl:call-template>
1009 name=
"u:outputFolding">
1012 <xsl:text>|
</xsl:text>
1014 select=
"$lineBlockIndent"/>
1018 select=
"concat($indent, ' ', $lineBlockIndent)"/>
1019 </xsl:call-template>
1022 <xsl:text>|
</xsl:text>
1028 <!-- ******************************************************************** -->
1031 Content Model: %text.model;
1032 Attributes: The literal_block element contains the common attributes (ids,
1033 names, dupnames, source, and classes), plus xml:space.
1035 <!-- == simple_body_element == directive -->
1037 match=
"literal_block">
1040 test=
".//*[contains($inline_elements, concat('*', name(), '*'))]">
1041 <!-- If it contains inline elements this is a parsed-literal -->
1044 <xsl:text>.. parsed-literal::
</xsl:text>
1052 name=
"u:outputClass"/>
1053 <!-- TODO Support for the (fully) minimized style would be nice but
1054 is difficult to accomplish because there is a linefeed
1055 already when we arrive here :-( -->
1058 <xsl:text>::
</xsl:text>
1064 name=
"isQuotedLiteral">
1066 name=
"u:isQuotedLiteral"/>
1068 <!-- Indent correctly depending on quoted literal or not -->
1071 test=
"string-length($isQuotedLiteral)">
1076 select=
"ancestor::*"/>
1077 </xsl:call-template>
1078 <xsl:apply-templates
1079 mode=
"quotedLiteral"/>
1086 select=
"ancestor-or-self::*"/>
1087 </xsl:call-template>
1088 <xsl:apply-templates/>
1094 <!-- Indent a text of a quoted literal containing line feeds correctly -->
1097 mode=
"quotedLiteral">
1106 select=
"ancestor::*[position() > 1]"/>
1107 </xsl:call-template>
1109 </xsl:call-template>
1112 <!-- Determine whether `$text' is a quoted literal and return the quote
1115 name=
"u:isQuotedLiteral">
1121 select=
"substring($text, 1, 1)"/>
1123 test=
"contains($adornment_characters, $quote) and substring($text, 1, 1) = $quote">
1124 <!-- Given quote is an adornment character and first character is this
1128 test=
"contains($text, '
')">
1129 <!-- Test the remaining lines -->
1131 name=
"u:isQuotedLiteral">
1134 select=
"substring-after($text, '
')"/>
1138 </xsl:call-template>
1141 <!-- No more lines to test so this is a quoted literal -->
1149 <!-- ******************************************************************** -->
1152 Content Model: %text.model;
1153 Attributes: The paragraph element contains only the common attributes:
1154 ids, names, dupnames, source, and classes.
1156 <!-- == simple_body_element == folding_element -->
1161 select=
"preceding-sibling::*[1]"/>
1162 <!-- Do indent except first element in some compound elements -->
1165 select=
"($previous or not(parent::list_item or parent::field_body or contains($admonitions, concat('*', name(..), '*')))) and name($previous) != 'label'"/>
1166 <!-- Blank line in front if following a body element, except first
1167 elements in some compound elements -->
1170 select=
"($previous or not(parent::list_item or ../parent::option_list_item or parent::field_body or parent::document or contains($admonitions, concat('*', name(..), '*')))) and (not($previous) or contains($body_elements, concat('*', name($previous), '*')) or name($previous) = 'title' and contains($titled_elements, concat('*', name(..), '*')) or name($previous) = 'docinfo')"/>
1176 test=
"$needsIndent">
1182 <!-- This paragraph has a classes attribute - always needs newline and
1185 name=
"u:outputClass">
1187 name=
"alreadyBlanked"
1188 select=
"$needsBlank"/>
1190 name=
"alreadyIndented"
1191 select=
"$needsIndent"/>
1192 </xsl:call-template>
1197 name=
"u:outputFolding"/>
1200 <!-- ******************************************************************** -->
1202 <!-- == simple_body_element -->
1206 name=
"u:notSupported"/>
1209 <!-- ******************************************************************** -->
1211 <!-- == simple_body_element == inline_element == directive -->
1216 test=
"contains($inline_containers, concat('*', name(..), '*'))">
1217 <!-- Used as a custom role -->
1218 <!-- TODO `role' directives must be generated for user-defined raw
1220 <!-- The name of the custom role is not contained in the input -->
1221 <xsl:text>:RAW-ROLE:`
</xsl:text>
1222 <xsl:apply-templates/>
1223 <xsl:text>`
</xsl:text>
1226 <!-- A directive -->
1228 name=
"u:outputClass"/>
1231 <xsl:text>.. raw::
</xsl:text>
1239 select=
"@*[name() != 'format' and name() != 'classes']"/>
1240 </xsl:call-template>
1246 select=
"ancestor-or-self::*"/>
1247 </xsl:call-template>
1248 <xsl:apply-templates/>
1254 <!-- ******************************************************************** -->
1256 <!-- == simple_body_element == folding_element == directive -->
1262 name=
"u:outputFolding">
1265 <xsl:text>.. rubric::
</xsl:text>
1267 </xsl:call-template>
1272 <!-- ******************************************************************** -->
1274 <!-- == compound_body_element == directive -->
1279 <xsl:text>.. compound::
</xsl:text>
1283 <xsl:apply-templates/>
1286 <!-- ******************************************************************** -->
1288 <!-- == compound_body_element == directive -->
1293 <xsl:text>.. container::
</xsl:text>
1301 <xsl:apply-templates/>
1304 <!-- ******************************************************************** -->
1306 <!-- == simple_body_element == directive -->
1308 match=
"substitution_definition">
1309 <!-- More than one child or not a directive is a replacement text -->
1312 select=
"not(* and count(node()) = 1 and contains($directives, concat('*', name(*[1]), '*')))"/>
1317 <xsl:text>.. |
</xsl:text>
1319 name=
"u:outputNames"/>
1320 <xsl:text>|
</xsl:text>
1325 <!-- TODO Substitution references for replace can not be found because
1326 they are not marked as such; embedding them in `generated'
1329 name=
"u:outputFolding">
1334 <xsl:text>replace::
</xsl:text>
1336 </xsl:call-template>
1341 <xsl:apply-templates/>
1346 <!-- ******************************************************************** -->
1349 Content Model: ((%body.elements;)+, attribution?)
1350 Attributes: The block_quote element contains only the common attributes:
1351 ids, names, dupnames, source, and classes.
1353 <!-- == compound_body_element -->
1355 match=
"block_quote">
1357 test=
"@classes = 'epigraph' or @classes = 'highlights' or @classes = 'pull-quote'">
1360 <xsl:text>..
</xsl:text>
1363 <xsl:text>::
</xsl:text>
1368 <xsl:apply-templates/>
1371 <!-- ******************************************************************** -->
1373 <!-- == simple_body_subelement == folding_element -->
1375 match=
"attribution">
1377 name=
"u:outputClass"/>
1378 <!-- blank line between quote and attribution -->
1383 name=
"u:outputFolding">
1386 <xsl:text>--
</xsl:text>
1388 </xsl:call-template>
1391 <!-- ******************************************************************** -->
1393 <!-- == compound_body_element == directive -->
1397 name=
"u:outputClass"/>
1400 <xsl:text>.. [
</xsl:text>
1403 <xsl:text>]
</xsl:text>
1404 <xsl:apply-templates
1405 select=
"*[not(self::label)]"/>
1408 <!-- == simple_body_subelement -->
1410 match=
"citation/label">
1411 <xsl:apply-templates/>
1414 <!-- ******************************************************************** -->
1416 <!-- == compound_body_element == directive -->
1421 <xsl:text>.. figure::
</xsl:text>
1422 <xsl:apply-templates/>
1425 <!-- ******************************************************************** -->
1427 <!-- == simple_body_subelement == folding_element -->
1433 name=
"u:outputFolding"/>
1436 <!-- ******************************************************************** -->
1438 <!-- == compound_body_subelement -->
1441 <xsl:apply-templates/>
1444 <!-- ******************************************************************** -->
1446 <!-- TODO Footnotes should continue on line of definition -->
1448 <!-- user-numbered footnotes lack @auto -->
1449 <!-- == compound_body_element == directive -->
1451 match=
"footnote[not(@auto)]">
1453 name=
"u:outputClass"/>
1456 <xsl:text>.. [
</xsl:text>
1457 <xsl:apply-templates
1459 <xsl:text>]
</xsl:text>
1460 <xsl:apply-templates
1461 select=
"*[not(self::label)]"/>
1464 <!-- autonumbered footnotes have @auto -->
1465 <!-- if the target footnote_reference@names matches its label, it was not a
1466 numbered-name footnote -->
1467 <!-- == compound_body_element == directive -->
1469 match=
"footnote[@auto='1']">
1471 name=
"u:outputClass"/>
1474 <xsl:text>.. [#
</xsl:text>
1476 test=
"@names = @ids">
1478 name=
"u:outputNames"/>
1480 <xsl:text>]
</xsl:text>
1481 <xsl:apply-templates
1482 select=
"*[not(self::label)]"/>
1485 <!-- autosymboled footnotes have @auto -->
1486 <!-- == compound_body_element == directive -->
1488 match=
"footnote[@auto='*']">
1490 name=
"u:outputClass"/>
1493 <xsl:text>.. [*]
</xsl:text>
1494 <xsl:apply-templates
1495 select=
"*[not(self::label)]"/>
1498 <!-- == compound_body_element == directive -->
1500 match=
"footnote[starts-with(@names, 'TARGET_NOTE:\ ')]">
1501 <!-- This is not a footnote but a hint for a directive -->
1503 test=
"generate-id(//footnote[starts-with(@names, 'TARGET_NOTE:\ ')][1]) = generate-id(.)">
1504 <!-- Only for the first one -->
1507 <!-- TODO May have a `classes` attribute -->
1508 <xsl:text>.. target-notes::
</xsl:text>
1513 <!-- == simple_body_subelement -->
1515 match=
"footnote/label">
1516 <xsl:apply-templates/>
1519 <!-- ******************************************************************** -->
1522 Content Model: (list_item +)
1523 Attributes: The bullet_list element contains the common attributes (ids,
1524 names, dupnames, source, and classes), plus bullet.
1525 bullet is used to record the style of bullet from the input data.
1526 In documents processed from reStructuredText, it contains one of "-",
1527 "+", or "*". It may be ignored in processing.
1529 <!-- == compound_body_element -->
1531 match=
"bullet_list">
1533 name=
"u:outputClass"/>
1534 <xsl:apply-templates
1535 mode=
"bullet_list"/>
1538 <!-- ******************************************************************** -->
1541 Content Model: (definition_list_item +)
1542 Attributes: The definition_list element contains only the common
1543 attributes: ids, names, dupnames, source, and classes.
1545 <!-- == compound_body_element -->
1547 match=
"definition_list">
1549 name=
"u:outputClass"/>
1550 <xsl:apply-templates/>
1553 <!-- ******************************************************************** -->
1556 Content Model: (term, classifier?, definition)
1557 Attributes: The definition_list_item element contains only the common
1558 attributes: ids, names, dupnames, source, and classes.
1560 <!-- == compound_body_subelement -->
1562 match=
"definition_list_item">
1564 name=
"u:outputClass"/>
1567 <xsl:apply-templates/>
1570 <!-- ******************************************************************** -->
1573 Content Model: %text.model;
1574 Attributes: The term element contains only the common attributes: ids,
1575 names, dupnames, source, and classes.
1577 <!-- == simple_body_subelement -->
1580 <xsl:apply-templates/>
1583 <!-- ******************************************************************** -->
1586 Content Model: %text.model;
1587 Attributes: The classifier element contains only the common attributes:
1588 ids, names, dupnames, source, and classes.
1590 <!-- == simple_body_subelement -->
1593 <xsl:text> :
</xsl:text>
1594 <xsl:apply-templates/>
1597 <!-- ******************************************************************** -->
1600 Content Model: (%body.elements;)+
1601 Attributes: The definition element contains only the common attributes:
1602 ids, names, dupnames, source, and classes.
1604 <!-- == compound_body_subelement -->
1608 name=
"u:outputClass"/>
1609 <xsl:apply-templates/>
1612 <!-- ******************************************************************** -->
1615 Content Model: (list_item +)
1616 Attributes: The enumerated_list element contains the common attributes
1617 (ids, names, dupnames, source, and classes), plus enumtype, prefix, suffix, and
1619 enumtype is used to record the intended enumeration sequence, one
1620 of "arabic" (1, 2, 3, ...), "loweralpha" (a, b, c, ..., z), "upperalpha" (A,
1621 B, C, ..., Z), "lowerroman" (i, ii, iii, iv, ..., mmmmcmxcix [4999]), or
1622 "upperroman" (I, II, III, IV, ..., MMMMCMXCIX [4999]).
1623 prefix stores the formatting characters used before the enumerator. In
1624 documents originating from reStructuredText data, it will contain either ""
1625 (empty string) or "(" (left parenthesis). It may or may not affect
1627 suffix stores the formatting characters used after the enumerator. In
1628 documents originating from reStructuredText data, it will contain either "."
1629 (period) or ")" (right parenthesis). Depending on the capabilities of the
1630 output format, this attribute may or may not affect processing.
1631 start contains the ordinal value of the first item in the list, in
1632 decimal. For lists beginning at value 1 ("1", "a", "A", "i", or "I"), this
1633 attribute may be omitted.
1635 <!-- == compound_body_element -->
1637 match=
"enumerated_list">
1639 name=
"u:outputClass"/>
1640 <xsl:apply-templates
1641 mode=
"enumerated_list"/>
1644 <!-- ******************************************************************** -->
1647 Content Model: (field +)
1648 Attributes: The field_list element contains only the common attributes:
1649 ids, names, dupnames, source, and classes.
1651 <!-- == compound_body_element -->
1655 name=
"u:outputClass"/>
1656 <xsl:apply-templates/>
1659 <!-- ******************************************************************** -->
1662 Content Model: (field_name, field_body)
1663 Attributes: The field element contains only the common attributes: ids,
1664 names, dupnames, source, and classes.
1666 <!-- == compound_body_subelement -->
1670 name=
"u:outputClass"/>
1673 <xsl:apply-templates/>
1676 <!-- ********************************************************************** -->
1679 Content Model: %text.model;
1680 Attributes: The field_name element contains only the common attributes:
1681 ids, names, dupnames, source, and classes.
1683 <!-- == simple_body_subelement -->
1686 <xsl:text>:
</xsl:text>
1687 <xsl:apply-templates/>
1688 <xsl:text>:
</xsl:text>
1689 <!-- no EOL: field_body starts on same line -->
1692 <!-- ******************************************************************** -->
1695 Content Model: (%body.elements;)*
1696 Attributes: The field_body element contains only the common attributes:
1697 ids, names, dupnames, source, and classes.
1699 <!-- == compound_body_subelement -->
1703 name=
"u:outputClass"/>
1704 <xsl:apply-templates/>
1707 <!-- ******************************************************************** -->
1710 Content Model: (option_list_item +)
1711 Attributes: The option_list element contains only the common attributes:
1712 ids, names, dupnames, source, and classes.
1714 <!-- == compound_body_element -->
1716 match=
"option_list">
1718 name=
"u:outputClass"/>
1721 <xsl:apply-templates/>
1724 <!-- ******************************************************************** -->
1727 Content Model: (option_group, description)
1728 Attributes: The option_list_item element contains only the common
1729 attributes: ids, names, dupnames, source, and classes.
1731 <!-- == compound_body_subelement -->
1733 match=
"option_list_item">
1735 name=
"u:outputClass"/>
1738 <xsl:apply-templates/>
1741 <!-- ******************************************************************** -->
1744 Content Model: (option_group, description)
1745 Attributes: The option_group element contains only the common attributes:
1746 ids, names, dupnames, source, and classes.
1748 <!-- == compound_body_subelement -->
1750 match=
"option_group">
1751 <xsl:apply-templates/>
1755 <!-- ******************************************************************** -->
1758 Content Model: (option_string, option_argument *)
1759 Attributes: The option element contains only the common attributes: ids,
1760 names, dupnames, source, and classes.
1762 <!-- == compound_body_subelement -->
1766 name=
"u:outputClass"/>
1767 <xsl:apply-templates/>
1769 test=
"generate-id(current()) != generate-id(../*[last()])">
1770 <!-- No comma after final option -->
1771 <xsl:text>,
</xsl:text>
1773 <!-- no EOL: description on same line -->
1776 <!-- ******************************************************************** -->
1779 Content Model: (#PCDATA)
1780 Attributes: The option_string element contains only the common attributes:
1781 ids, names, dupnames, source, and classes.
1783 <!-- == simple_body_subelement -->
1785 match=
"option_string">
1786 <xsl:apply-templates/>
1789 <!-- ******************************************************************** -->
1792 Content Model: (#PCDATA)
1793 Attributes: The option_argument element contains the common attributes
1794 (ids, names, dupnames, source, and classes), plus delimiter.
1795 delimiter contains the text preceding the option_argument:
1796 either the text separating it from the option_string (typically
1798 or the text between option arguments (typically either "," or " ").
1800 <!-- == simple_body_subelement -->
1802 match=
"option_argument">
1804 select=
"@delimiter"/>
1805 <xsl:apply-templates/>
1808 <!-- ******************************************************************** -->
1811 Content Model: (%body.elements;)+
1812 Attributes: The description element contains only the common attributes:
1813 ids, names, dupnames, source, and classes.
1815 <!-- == compound_body_subelement -->
1817 match=
"description">
1819 name=
"u:outputClass"/>
1820 <xsl:apply-templates/>
1824 <!-- ******************************************************************** -->
1827 Content Model: (%body.elements;)+
1828 Attributes: The list_item element contains only the common attributes:
1829 ids, names, dupnames, source, and classes
1832 bullet is used to record the style of bullet from the input data.
1833 In documents processed from reStructuredText, it contains one of "-",
1834 "+", or "*". It may be ignored in processing.
1836 <!-- == compound_body_subelement -->
1841 name=
"u:outputClass"/>
1843 test=
"name(*[1]) != 'bullet_list'">
1844 <!-- Start the list item only if the first child is not another list -->
1848 select=
"../@bullet"/>
1849 &tSP; <!-- space after bullet -->
1851 <xsl:apply-templates/>
1854 <!-- ******************************************************************** -->
1858 enumtype is used to record the intended enumeration sequence, one of
1859 "arabic" (1, 2, 3, ...), "loweralpha" (a, b, c, ..., z), "upperalpha" (A, B,
1860 C, ..., Z), "lowerroman" (i, ii, iii, iv, ..., mmmmcmxcix [4999]), or
1861 "upperroman" (I, II, III, IV, ..., MMMMCMXCIX [4999]).
1862 prefix stores the formatting characters used before the enumerator. In
1863 documents originating from reStructuredText data, it will contain either ""
1864 (empty string) or "(" (left parenthesis). It may or may not affect
1866 suffix stores the formatting characters used after the enumerator. In
1867 documents originating from reStructuredText data, it will contain either "."
1868 (period) or ")" (right parenthesis). Depending on the capabilities of the
1869 output format, this attribute may or may not affect processing.
1870 start contains the ordinal value of the first item in the list, in
1871 decimal. For lists beginning at value 1 ("1", "a", "A", "i", or "I"), this
1872 attribute may be omitted.
1875 <!-- == compound_body_subelement -->
1878 mode=
"enumerated_list">
1880 name=
"u:outputClass"/>
1884 name=
"u:outputEnumerator"/>
1885 <xsl:apply-templates/>
1888 <!-- Outputs a complete enumerator when called in an
1889 enumerated_list/list_item -->
1891 name=
"u:outputEnumerator">
1892 <!-- Use parent's numeration attribute -->
1895 select=
"../@enumtype"/>
1896 <!-- Determine starting point -->
1903 select=
"../@start"/>
1911 <!-- Determine position of this item in its real context -->
1916 select=
"generate-id()"/>
1917 <!-- Generate the right current node list -->
1919 select=
"../list_item">
1921 test=
"generate-id() = $wanted">
1923 select=
"position()"/>
1927 <!-- Determine encoding of the number for the given numeration -->
1931 name=
"u:position2Enumerator">
1934 select=
"$enumType"/>
1937 select=
"$position"/>
1941 </xsl:call-template>
1943 <!-- Determine encoding of the maximum number -->
1947 name=
"u:position2Enumerator">
1950 select=
"$enumType"/>
1953 select=
"count(../list_item)"/>
1957 </xsl:call-template>
1959 <!-- Output complete enumerator -->
1961 select=
"../@prefix"/>
1965 select=
"../@suffix"/>
1966 <!-- Output at least one trailing space -->
1968 <!-- Output more whitespace to align with the maximum enumerator -->
1970 test=
"$enumType != 'lowerroman' and $enumType != 'upperroman'">
1973 <!-- Assumes that the maximum number has maximum string length -->
1976 select=
"string-length($max) - string-length($cur)"/>
1977 </xsl:call-template>
1981 <!-- Determine the right ordinal enumerator based on the parameters -->
1983 name=
"u:position2Enumerator">
1990 <!-- Determine logical number -->
1993 select=
"$start - 1 + $position"/>
1996 test=
"$enumType = 'arabic'">
2001 test=
"$enumType = 'loweralpha'">
2003 select=
"substring('abcdefghijklmnopqrstzuvwxyz', $ordinal, 1)"/>
2006 test=
"$enumType = 'upperalpha'">
2008 select=
"substring('ABCDEFGHIJKLMNOPQRSTZUVWXYZ', $ordinal, 1)"/>
2010 <!-- TODO Support for counting roman numbers -->
2012 test=
"$enumType = 'lowerroman'">
2013 <xsl:text>i
</xsl:text>
2016 test=
"$enumType = 'upperroman'">
2017 <xsl:text>I
</xsl:text>
2022 <!-- ******************************************************************** -->
2023 <!-- ******************************************************************** -->
2026 Content Model: (title?, tgroup+)
2027 Attributes: The table element contains the common attributes and:
2028 frame, colsep, rowsep, pgwide
2030 <!-- == compound_body_element -->
2034 name=
"u:outputClass"/>
2037 <xsl:apply-templates
2041 <!-- TODO A table title must be rendered by using the `.. table::'
2045 <xsl:apply-templates
2051 <!-- ******************************************************************** -->
2054 Content Model: (colspec*, thead?, tbody)
2055 Attributes: The tgroup element contains the common attributes and:
2056 cols, colsep, rowsep, align
2058 <!-- == compound_body_subelement -->
2061 <xsl:apply-templates/>
2064 <!-- ******************************************************************** -->
2067 Content Model: EMPTY
2068 Attributes: The colspec element contains the common attributes and:
2069 colnum, colname, colwidth, colsep, rowsep, align, char, charoff
2071 The colwidth attribute gives the width of the respective column in characters
2072 including padding whitespace but no separator markup.
2074 <!-- == simple_body_subelement -->
2075 <!-- @colwidth needed by children but element has no own output -->
2079 <!-- ******************************************************************** -->
2082 Content Model: (row+)
2083 Attributes: The thead element contains the common attributes and:
2086 <!-- == compound_body_subelement -->
2089 <xsl:apply-templates/>
2093 Content Model: (row+)
2094 Attributes: The tbody element contains the common attributes and:
2097 <!-- == compound_body_subelement -->
2100 <xsl:apply-templates/>
2103 <!-- ******************************************************************** -->
2106 Content Model: (entry+)
2107 Attributes: The row element contains the common attributes and:
2110 <!-- == compound_body_subelement -->
2113 <!-- Separator line above unless first row of a tbody with no previous
2114 thead (in this case the separator line is output already as the
2115 closing separator line of thead) -->
2117 test=
"position() > 1 or parent::thead or parent::tbody and not(../../thead)">
2119 name=
"u:rowSeparatorLine"/>
2121 <!-- Determine heights in physical lines of all entries -->
2128 <!-- Catch the text of all entries -->
2129 <xsl:apply-templates/>
2131 <!-- Compute height of this entry; leading and trailing EOL must be
2134 select=
"string-length($text) - string-length(translate($text, '
', '')) - 1"/>
2135 &tSP; <!-- A space as a list separator -->
2138 <!-- Determine maximum height so every entry must be this high -->
2146 </xsl:call-template>
2148 <!-- Output all the physical lines of this row -->
2156 select=
"$maxHeight"/>
2157 </xsl:call-template>
2158 <!-- Output final separator line if this is the last row -->
2160 test=
"position() = last()">
2162 name=
"u:rowSeparatorLine">
2165 <!-- Determine correct character for the separator line -->
2168 test=
"parent::thead">
2178 </xsl:call-template>
2182 <!-- Output physical line $currentLine of a row and continue until
2183 line $maxLine is output -->
2187 name=
"currentLine"/>
2191 test=
"$currentLine <= $maxLine">
2192 <!-- If there are still physical lines to output do it -->
2195 <!-- Leading bar -->
2196 <xsl:text>|
</xsl:text>
2197 <xsl:apply-templates>
2200 select=
"$currentLine"/>
2201 </xsl:apply-templates>
2202 <!-- End of this physical line -->
2204 <!-- Continue with the next physical line -->
2209 select=
"$currentLine + 1"/>
2213 </xsl:call-template>
2217 <!-- Output a separator line with all the right characters -->
2219 name=
"u:rowSeparatorLine">
2225 <xsl:text>+
</xsl:text>
2227 select=
"../../colspec">
2232 select=
"@colwidth"/>
2236 </xsl:call-template>
2237 <xsl:text>+
</xsl:text>
2242 <!-- ******************************************************************** -->
2245 Content Model: (%body.elements;)*
2246 Attributes: The entry element contains the common attributes and:
2247 colname, namest, morerows, colsep, rowsep, align, char, charoff, valign and
2250 <!-- == compound_body_subelement -->
2253 <!-- TODO `classes` attribute needs support -->
2254 <!-- This is called in two ways; if $currentLine = 0 all physical lines
2255 of this entry must be output; if $currentLine > 0 the physical line
2256 with exactly this number shall be output -->
2262 select=
"position() + sum(preceding-sibling::entry/@morecols)"/>
2263 <!-- Determine width in characters needed for this entry -->
2267 name=
"u:computeEntryWidth">
2270 select=
"../../../colspec"/>
2276 select=
"@morecols"/>
2277 </xsl:call-template>
2279 <!-- Output the entry completely or a certain physical line -->
2281 name=
"u:outputEntry">
2284 <!-- Capture physical lines of the entry in a variable -->
2285 <xsl:apply-templates/>
2291 name=
"expectedIndent">
2292 <!-- Capture indent for the entry generated by the normal template
2293 rules to remove it later -->
2299 select=
"$currentLine"/>
2300 </xsl:call-template>
2301 <!-- Final bar after the entry -->
2302 <xsl:text>|
</xsl:text>
2305 <!-- Compute width of the entry -->
2307 name=
"u:computeEntryWidth">
2308 <!-- The colspec elements of all columns -->
2311 <!-- Column of this entry -->
2314 <!-- Number of columns this entry spans -->
2324 <!-- If entry spans multiple columns compute their width -->
2326 name=
"u:computeEntryWidth">
2329 select=
"$colspecs"/>
2332 select=
"$column + 1"/>
2335 select=
"$span - 1"/>
2336 <!-- Add the separator character and the following column width -->
2339 select=
"$sum + 1 + $colspecs[$column]/@colwidth"/>
2340 </xsl:call-template>
2343 <!-- Does not span more columns so return sum and width of this
2346 select=
"$sum + $colspecs[$column]/@colwidth"/>
2351 <!-- Outputs one or all lines of a table entry as a string trimmed left and
2354 name=
"u:outputEntry">
2355 <!-- Width of the entry; there is no provision for actual physical lines
2356 longer than this width -->
2359 <!-- The string containing the remaining physical lines; may be an empty
2364 <!-- The indendation which is expected to be prefixed before every
2367 name=
"expectedIndent"
2369 <!-- Is this the first call to this template -->
2373 <!-- Number of physical line to output or 0 to output all lines -->
2377 <!-- Output is wanted if all or the first physical line are to be
2381 select=
"$outputLine = 0 or $outputLine = 1"/>
2383 name=
"stringLFHalfTrimmed">
2386 test=
"$isFirst and substring($string, 1, 1) = '
'">
2387 <!-- Remove leading linefeed if this is the first time -->
2389 select=
"substring($string, 2)"/>
2398 name=
"stringLFTrimmed">
2401 test=
"$isFirst and substring($stringLFHalfTrimmed, string-length($stringLFHalfTrimmed), 1) = '
'">
2402 <!-- Remove trailing linefeed if this is the first time -->
2404 select=
"substring($stringLFHalfTrimmed, 1, string-length($stringLFHalfTrimmed) - 1)"/>
2408 select=
"$stringLFHalfTrimmed"/>
2412 <!-- Determine remaining lines after the first one -->
2414 name=
"remainingLines">
2416 test=
"contains($stringLFTrimmed, '
')">
2418 select=
"substring-after($stringLFTrimmed, '
')"/>
2423 <!-- If this physical line must be output determine the first physical
2429 test=
"string-length($remainingLines)">
2431 select=
"substring-before($stringLFTrimmed, '
')"/>
2435 select=
"$stringLFTrimmed"/>
2439 <!-- Remove the leading indentation from the physical line which is
2440 brought there by the normal templates -->
2444 test=
"string-length($firstLine)">
2445 <!-- Trim only non-empty lines -->
2447 select=
"substring-after($firstLine, $expectedIndent)"/>
2450 <!-- Pad the line with a leading and a trailing space -->
2453 select=
"concat(' ', $trimmed, ' ')"/>
2454 <!-- Output the padded value -->
2457 <!-- Fill up the width of the entry with spaces -->
2459 test=
"$width - string-length($padded) < 0">
2461 <xsl:text>WARNING: Table column too narrow (minimum:
</xsl:text>
2463 select=
"string-length($padded)"/>
2464 <xsl:text>)
</xsl:text>
2472 select=
"$width - string-length($padded)"/>
2473 </xsl:call-template>
2476 test=
"$outputLine > 1 or $outputLine = 0 and string-length($remainingLines)">
2477 <!-- If a following physical line must be output or if all physical
2478 lines shall be output and there are remaining physical lines -->
2480 test=
"$outputLine = 0">
2481 <!-- Output linefeed only if we output all the lines -->
2484 <!-- Output the remaining lines -->
2486 name=
"u:outputEntry">
2492 select=
"$remainingLines"/>
2494 name=
"expectedIndent"
2495 select=
"$expectedIndent"/>
2503 test=
"$outputLine = 0">
2509 select=
"$outputLine - 1"/>
2513 </xsl:call-template>
2517 <!-- ******************************************************************** -->
2518 <!-- ******************************************************************** -->
2520 <!-- == inline_element -->
2522 match=
"citation_reference">
2524 name=
"u:bkslshEscPre"/>
2525 <xsl:text>[
</xsl:text>
2526 <xsl:apply-templates/>
2527 <xsl:text>]_
</xsl:text>
2529 name=
"u:bkslshEscSuf"/>
2532 <!-- ******************************************************************** -->
2534 <!-- == inline_element -->
2536 match=
"substitution_reference">
2538 name=
"u:bkslshEscPre"/>
2539 <xsl:text>|
</xsl:text>
2540 <xsl:apply-templates/>
2541 <xsl:text>|
</xsl:text>
2543 name=
"u:bkslshEscSuf"/>
2546 <!-- ******************************************************************** -->
2548 <!-- == inline_element -->
2552 name=
"u:bkslshEscPre"/>
2553 <xsl:text>*
</xsl:text>
2554 <xsl:apply-templates/>
2555 <xsl:text>*
</xsl:text>
2557 name=
"u:bkslshEscSuf"/>
2560 <!-- ******************************************************************** -->
2562 <!-- user-numbered footnotes lack @auto -->
2563 <!-- == inline_element -->
2565 match=
"footnote_reference[not(@auto)]">
2567 name=
"u:bkslshEscPre"/>
2568 <xsl:text>[
</xsl:text>
2571 <xsl:text>]_
</xsl:text>
2573 name=
"u:bkslshEscSuf"/>
2574 <!-- child paragraph provides blank line -->
2577 <!-- automatically numbered footnotes have @auto -->
2578 <!-- if @names is different from label content, it is a named footnote -->
2579 <!-- == inline_element -->
2581 match=
"footnote_reference[@auto='1']">
2586 test=
"not(starts-with(//footnote[@ids=$ref]/@names, 'TARGET_NOTE:\ '))">
2587 <!-- Not a generated footnote reference for a `.. target-notes::';
2588 such footnote reference and the preceding space should be
2589 embedded in `generated'! -->
2591 name=
"u:bkslshEscPre"/>
2592 <xsl:text>[#
</xsl:text>
2594 test=
"//footnote[@ids=$ref]/@names != //footnote[@ids=$ref]/label">
2596 name=
"u:outputNames">
2599 select=
"//footnote[@ids=$ref]/@names"/>
2600 </xsl:call-template>
2602 <xsl:text>]_
</xsl:text>
2604 name=
"u:bkslshEscSuf"/>
2608 <!-- automatically symboled footnotes have @auto=* -->
2609 <!-- == inline_element -->
2611 match=
"footnote_reference[@auto='*']">
2613 name=
"u:bkslshEscPre"/>
2614 <xsl:text>[*]_
</xsl:text>
2616 name=
"u:bkslshEscSuf"/>
2619 <!-- ******************************************************************** -->
2622 Content Model: %text.model;
2624 <!-- == inline_element -->
2628 name=
"u:bkslshEscPre"/>
2629 <xsl:text>``
</xsl:text>
2630 <xsl:apply-templates/>
2631 <xsl:text>``
</xsl:text>
2633 name=
"u:bkslshEscSuf"/>
2636 <!-- ******************************************************************** -->
2638 <!-- Attribute combinations found in `standard' text and other examples:
2639 @refuri = standalone hyperlink
2640 @ids @refid = TOC, probably all in <generated>
2641 @name @refuri with matching <target> in document = named external hyperlink _
2642 @name @refuri immediately followed by matching <target> = named embedded URI _
2643 @name @refuri with no matching <target> in document = anonymous embedded URI __
2644 @anonymous @name @refuri with no matching <target> in document = anonymous explicit URI __
2645 @name @refid = internal cross-reference _
2646 @anonymous @name @refid = anonymous implicit internal reference __
2647 @name @refid image = clickable image to internal reference _
2648 @refuri image = clickable image to standalone hyperlink
2650 A target matches if target/@names contains the lower cased, whitespace
2651 quoted reference/@name
2654 <!-- Standalone hyperlink -->
2655 <!-- == inline_element -->
2657 match=
"reference[not(@name or @anonymous)]">
2659 name=
"u:bkslshEscPre"/>
2662 test=
"starts-with(., 'PEP ')">
2663 <xsl:text>:PEP:`
</xsl:text>
2665 select=
"substring-after(., 'PEP ')"/>
2666 <xsl:text>`
</xsl:text>
2669 test=
"starts-with(., 'RFC ')">
2670 <xsl:text>:RFC:`
</xsl:text>
2672 select=
"substring-after(., 'RFC ')"/>
2673 <xsl:text>`
</xsl:text>
2676 <xsl:apply-templates/>
2680 name=
"u:bkslshEscSuf"/>
2683 <!-- External references -->
2684 <!-- == inline_element -->
2686 match=
"reference[@name and @refuri]">
2687 <!-- Determine normalized name by downcasing it -->
2690 select=
"translate(normalize-space(@name), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
2694 name=
"u:quoteWhite">
2697 select=
"$normalized"/>
2698 </xsl:call-template>
2702 select=
"//target[contains(@names, $quoted)]"/>
2704 name=
"u:inlineReference">
2707 select=
"not($matching) or @anonymous"/>
2710 select=
"not(@anonymous) and (not($matching) or generate-id(following-sibling::node()[1]) = generate-id($matching))"/>
2711 </xsl:call-template>
2714 <!-- Internal references -->
2715 <!-- == inline_element -->
2717 match=
"reference[@name and @refid]">
2719 name=
"u:inlineReference">
2722 select=
"@anonymous"/>
2723 </xsl:call-template>
2726 <!-- Image references -->
2727 <!-- == inline_element -->
2729 match=
"reference[image]">
2730 <!-- All done by the `image' tag -->
2731 <xsl:apply-templates/>
2734 <!-- ******************************************************************** -->
2737 Content Model: %text.model;
2739 <!-- == inline_element -->
2743 name=
"u:bkslshEscPre"/>
2744 <xsl:text>**
</xsl:text>
2745 <xsl:apply-templates/>
2746 <xsl:text>**
</xsl:text>
2748 name=
"u:bkslshEscSuf"/>
2751 <!-- ******************************************************************** -->
2753 <!-- == inline_element -->
2757 name=
"u:bkslshEscPre"/>
2758 <xsl:text>:sub:`
</xsl:text>
2759 <xsl:apply-templates/>
2760 <xsl:text>`
</xsl:text>
2762 name=
"u:bkslshEscSuf"/>
2765 <!-- ******************************************************************** -->
2767 <!-- == inline_element -->
2769 match=
"superscript">
2771 name=
"u:bkslshEscPre"/>
2772 <xsl:text>:sup:`
</xsl:text>
2773 <xsl:apply-templates/>
2774 <xsl:text>`
</xsl:text>
2776 name=
"u:bkslshEscSuf"/>
2779 <!-- ******************************************************************** -->
2781 <!-- The target element has various roles depending on context; they are
2782 all handled here -->
2783 <!-- == simple_body_element == inline_element == directive -->
2788 test=
"name(preceding-sibling::*[1]) = 'reference'">
2789 <!-- An embedded inline target - handled by the reference itself -->
2792 test=
"contains($inline_containers, concat('*', name(..), '*'))">
2793 <!-- An inline target of some sort -->
2795 name=
"u:inlineReference">
2799 </xsl:call-template>
2803 <!-- An anonymous target directive -->
2805 name=
"u:outputClass"/>
2808 <xsl:text>__
</xsl:text>
2813 name=
"u:outputNamesRefid"/>
2814 <xsl:text>_
</xsl:text>
2825 test=
"@names | @refid">
2826 <!-- A target directive -->
2828 name=
"u:outputClass"/>
2831 <xsl:text>.. _
</xsl:text>
2836 name=
"u:outputNamesRefid"/>
2841 select=
"contains(@names, ':')"/>
2843 test=
"$quoteNeeded">
2844 <xsl:text>`
</xsl:text>
2847 name=
"u:outputNames"/>
2849 test=
"$quoteNeeded">
2850 <xsl:text>`
</xsl:text>
2854 <xsl:text>:
</xsl:text>
2857 <xsl:text> </xsl:text>
2864 <!-- Should not happen -->
2866 name=
"u:notSupported"/>
2871 <!-- ******************************************************************** -->
2874 Content Model: %text.model;
2876 <!-- == inline_element -->
2878 match=
"title_reference">
2880 name=
"u:bkslshEscPre"/>
2881 <xsl:text>`
</xsl:text>
2882 <xsl:apply-templates/>
2883 <xsl:text>`
</xsl:text>
2885 name=
"u:bkslshEscSuf"/>
2888 <!-- ******************************************************************** -->
2891 Content Model: %text.model;
2893 <!-- == inline_element -->
2896 <!-- TODO `role' directives must be generated for plain and derived
2897 user-defined roles. -->
2899 name=
"u:bkslshEscPre"/>
2900 <xsl:text>:
</xsl:text>
2903 <xsl:text>:`
</xsl:text>
2904 <xsl:apply-templates/>
2905 <xsl:text>`
</xsl:text>
2907 name=
"u:bkslshEscSuf"/>
2910 <!-- ******************************************************************** -->
2912 <!-- TODO `meta` directive must be implemented. -->
2914 <!-- ******************************************************************** -->
2917 Docutils wraps generated elements around text that is inserted (generated) by
2918 Docutils; i.e., text that was not in the document, like section numbers
2919 inserted by the "sectnum" directive.
2921 <!-- == inline_element -->
2925 <!-- == inline_element -->
2927 match=
"problematic">
2928 <!-- Simply output the contained text because this is probably the
2934 <!-- == compound_body_element -->
2936 match=
"system_message"/>
2938 <!-- ******************************************************************** -->
2939 <!-- ******************************************************************** -->
2942 When a block of text contains linefeeds, it was indented relative to a marker
2951 <!-- ******************************************************************** -->
2952 <!-- ******************************************************************** -->
2954 <!-- Add a blank line if necessary and indent -->
2963 <!-- ******************************************************************** -->
2965 <!-- Add a blank line in certain contexts -->
2968 <xsl:apply-templates
2969 mode=
"blankSkipInline"
2970 select=
"preceding::*[1]"/>
2973 <!-- Find the preceding element we are really interested in and act
2974 according to this element -->
2976 mode=
"blankSkipInline"
2979 <!-- Skip all inline elements and body subelements and check their
2982 test=
"contains(concat($inline_elements, $simple_body_subelements, $compound_body_subelements), concat('*', name(.), '*'))">
2983 <xsl:apply-templates
2984 mode=
"blankSkipInline"
2988 <!-- Reached the type of element we decide on -->
2990 test=
"contains($blank_after, concat('*', name(.), '*'))">
2997 <!-- ******************************************************************** -->
3000 Indent a block if it's a child of...
3033 <!-- This is only for `bullet_list/list_item';
3034 `enumerated_list/list_item' is handled special -->
3039 name=
"definition_list_item"
3045 name=
"option_list_item"
3047 <!-- This is also the indentation if block_quote comes as one of the
3048 special directives -->
3053 name=
"literal_block"
3063 <!-- Do indent according to ancestor -->
3066 <!-- In some cases the ancestors to indent for need to be determined
3067 by the calling template -->
3070 select=
"ancestor::*"/>
3072 select=
"$ancestors">
3078 test=
"contains($directives, concat('*', $this, '*'))">
3081 <!-- TODO Indentation of lines after some directives must be
3082 indented to align with the directive instead of a
3083 fixed indentation; however, this is rather complicated
3084 since identation for parameters should be fixed -->
3088 </xsl:call-template>
3091 test=
"$this = 'list_item' and parent::enumerated_list">
3092 <!-- Enumerated list items base their indentation on the
3097 name=
"u:outputEnumerator"/>
3103 select=
"string-length($enumerator)"/>
3104 </xsl:call-template>
3111 select=
"document('')//data:lookup/node[@name=$this]/@indent"/>
3112 </xsl:call-template>
3118 <!-- ******************************************************************** -->
3121 Create a repeated character string
3122 Shamelessly borrowed from Jeni Tennison's work on EXSLT
3134 test=
"not($length) or $length <= 0 or not($chars)"/>
3138 select=
"concat($chars, $chars, $chars, $chars, $chars, $chars, $chars, $chars, $chars, $chars)"/>
3141 test=
"string-length($string) >= $length">
3143 select=
"substring($string, 1, $length)"/>
3154 </xsl:call-template>
3161 <!-- ******************************************************************** -->
3163 <!-- Indent a text containing line feeds correctly -->
3169 <!-- A fixed indentation may be given by caller -->
3172 <!-- If not given compute it -->
3178 test=
"contains($string,'
')">
3179 <!-- Output first physical line -->
3181 select=
"substring-before($string, '
')"/>
3183 <!-- Indent before the next line -->
3186 <!-- Output remaining physical lines -->
3191 select=
"substring-after($string, '
')"/>
3195 </xsl:call-template>
3197 <!-- String does not contain newline, so just output it -->
3205 <!-- ******************************************************************** -->
3207 <!-- Do output for those elements which do fold their inline content -->
3209 name=
"u:outputFolding">
3210 <!-- The prefix text to be output before the body -->
3214 <!-- The indentation for this body -->
3221 select=
"ancestor-or-self::*"/>
3222 </xsl:call-template>
3226 <!-- TODO Whitespace count of inline literals must be preserved -->
3227 <xsl:apply-templates/>
3229 <!-- Always output prefix with all trailing and leading spaces -->
3234 test=
"$fold > 0">
3237 select=
"normalize-space($string)"/>
3240 test=
"$string = ''">
3241 <!-- Empty strings need no output -->
3244 test=
"$normalized = ''">
3245 <!-- Only white-space in string; output a single space here -->
3249 <!-- Output leading white-space here -->
3251 test=
"normalize-space(substring($string, 1, 1)) = ''">
3255 name=
"u:indentFold">
3258 select=
"$normalized"/>
3264 select=
"string-length($indent) + string-length($prefix)"/>
3265 </xsl:call-template>
3266 <!-- Output trailing white-space here -->
3268 test=
"normalize-space(substring($string, string-length($string), 1)) = ''">
3282 <!-- ******************************************************************** -->
3284 <!-- Indent a string with folding -->
3286 name=
"u:indentFold">
3287 <!-- Normalized string to output -->
3290 <!-- Indentation to use for a new line -->
3293 <!-- Current output column -->
3294 <!-- TODO This is not a correct assumption for field definitions where
3295 the field name effectively determines the column of the first
3299 select=
"string-length($indent)"/>
3300 <!-- Do we start on a new (indented) line? -->
3307 <!-- TODO Quoted spaces must not end a word -->
3309 test=
"contains($string, ' ')">
3311 select=
"substring-before($string, ' ')"/>
3321 select=
"substring-after($string, ' ')"/>
3324 test=
"$string = ''"/>
3327 <!-- Output at least first word -->
3329 select=
"$firstWord"/>
3331 name=
"u:indentFold">
3340 select=
"$cursorColumn + string-length($firstWord)"/>
3344 </xsl:call-template>
3347 test=
"$cursorColumn + 1 + string-length($firstWord) > $fold">
3348 <!-- Line would get too long; start new line, indent and continue -->
3353 name=
"u:indentFold">
3362 select=
"string-length($indent)"/>
3366 </xsl:call-template>
3369 <!-- In a line and first word fits; separate and add word -->
3372 select=
"$firstWord"/>
3374 name=
"u:indentFold">
3383 select=
"$cursorColumn + 1 + string-length($firstWord)"/>
3387 </xsl:call-template>
3392 <!-- ******************************************************************** -->
3394 <!-- Output attributes of the current element as a field list -->
3400 <!-- Ancestors are needed for determining indentation; caller may give
3404 select=
"ancestor-or-self::*"/>
3407 <!-- Skip URIs based on parent -->
3409 test=
"name() != 'uri' and name() != 'xml:space'">
3414 select=
"$ancestors"/>
3415 </xsl:call-template>
3420 <!-- Output one attribute of the current element as a field list -->
3429 <!-- Ancestors are needed for determining indentation; caller may give
3433 select=
"ancestor::*"/>
3438 select=
"$ancestors"/>
3439 </xsl:call-template>
3440 <xsl:text>:
</xsl:text>
3443 test=
"$name = 'classes'">
3444 <xsl:text>class
</xsl:text>
3451 <xsl:text>:
</xsl:text>
3454 <xsl:text> </xsl:text>
3461 <!-- ******************************************************************** -->
3463 <!-- Output `\' or `\ ' before some inline element if necessary -->
3465 name=
"u:bkslshEscPre">
3466 <!-- Get the sibling node directly before the current element -->
3469 select=
"preceding-sibling::node()[1]"/>
3471 <!-- No sibling before this node -->
3473 test=
"not($before)"/>
3474 <!-- Element directly before this - must be another inline element -->
3476 test=
"name($before)">
3477 <!-- So separate it by a quoted space -->
3478 <xsl:text>\
</xsl:text>
3480 <!-- Node directly before this is text - check it -->
3482 test=
"not(contains(concat($apos, ' 
	
"([{<-/:'), substring($before, string-length($before), 1)))">
3483 <!-- Does not end in one of the allowed characters so separate it -->
3484 <xsl:text>\
</xsl:text>
3489 <!-- Output `\' or `\ ' after some inline element if necessary -->
3491 name=
"u:bkslshEscSuf">
3492 <!-- Get the sibling node directly after the current element -->
3495 select=
"following-sibling::node()[1]"/>
3497 <!-- No sibling after this node -->
3499 test=
"not($after)"/>
3500 <!-- Element directly after this - must be another inline element
3503 test=
"name($after)"/>
3504 <!-- Node directly after this is text - check it -->
3506 test=
"not(contains(concat($apos, ' 
	
")]}>-/:.,;!?\'), substring($after, 1, 1)))">
3507 <!-- Does not start with one of the allowed characters so separate
3509 <xsl:text>\
</xsl:text>
3514 <!-- ******************************************************************** -->
3517 name=
"u:notSupported">
3520 <xsl:text>######## NOT SUPPORTED: `
</xsl:text>
3523 <xsl:text>' ########
</xsl:text>
3527 <!-- ******************************************************************** -->
3531 <!-- Length of the rendered(!) text -->
3534 <!-- Depth 1 and 2 are document title and subtitle while depths
3535 greater than 2 are normal section titles -->
3538 <!-- Test whether a overline is wanted at all -->
3540 test=
"substring($adornment, 2 * ($depth - 1) + 1, 1) = 'o'">
3548 select=
"substring($adornment, 2 * ($depth - 1) + 2, 1)"/>
3549 </xsl:call-template>
3556 <!-- Length of the rendered(!) text -->
3559 <!-- Depth 1 and 2 are document title and subtitle while depths
3560 greater than 2 are normal section titles -->
3570 select=
"substring($adornment, 2 * ($depth - 1) + 2, 1)"/>
3571 </xsl:call-template>
3575 <!-- ******************************************************************** -->
3577 <!-- Output a non-standalone reference or target -->
3579 name=
"u:inlineReference">
3586 <!-- Is this a target instead of a reference? -->
3594 name=
"u:bkslshEscPre"/>
3595 <!-- Delimiter only if link contains other than alphanumerics -->
3599 test=
"* or translate($text, '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', '') or $embedded">
3600 <xsl:text>`
</xsl:text>
3605 <xsl:text>_
</xsl:text>
3608 select=
"$delimiter"/>
3609 <xsl:apply-templates
3613 <xsl:text> <</xsl:text>
3616 <xsl:text>></xsl:text>
3619 select=
"$delimiter"/>
3621 test=
"not($isTarget)">
3622 <xsl:text>_
</xsl:text>
3625 <xsl:text>_
</xsl:text>
3629 name=
"u:bkslshEscSuf"/>
3632 <!-- ******************************************************************** -->
3634 <!-- Determine the maximum number from a whitespace separated number list -->
3639 <!-- If this is not given by the caller a list of negative numbers will
3646 select=
"normalize-space($numbers)"/>
3649 test=
"contains($cleanNumbers, ' ')">
3652 select=
"substring-before($cleanNumbers, ' ')"/>
3655 test=
"$head > $currentMax">
3660 select=
"substring-after($cleanNumbers, ' ')"/>
3664 </xsl:call-template>
3671 select=
"substring-after($cleanNumbers, ' ')"/>
3674 select=
"$currentMax"/>
3675 </xsl:call-template>
3682 test=
"$cleanNumbers > $currentMax">
3684 select=
"$cleanNumbers"/>
3688 select=
"$currentMax"/>
3695 <!-- ******************************************************************** -->
3697 <!-- Output a class directive for the directly following element. -->
3698 <!-- TODO A class directive can also be used as a container putting the
3699 respective attribute to its content; however, this is not
3700 reflected in XML - you'd need to check a sequence of elements
3701 whether they all have the same attribute; furthermore class
3702 settings for block quotes needs to be treated special -->
3704 name=
"u:outputClass">
3705 <!-- Blank line already output? -->
3707 name=
"alreadyBlanked"
3709 <!-- Indentation already output? -->
3711 name=
"alreadyIndented"
3713 <!-- Add a blank line after class directive? -->
3720 test=
"not($alreadyBlanked)">
3725 test=
"not($alreadyIndented)">
3729 <xsl:text>.. class::
</xsl:text>
3740 <!-- ******************************************************************** -->
3742 <!-- Output a string with backslashed stripped -->
3744 name=
"u:outputUnbackslashed">
3749 test=
"not(contains($string, '\'))">
3755 select=
"substring-before($string, '\')"/>
3757 name=
"u:outputUnbackslashed">
3760 select=
"substring-after($string, '\')"/>
3761 </xsl:call-template>
3766 <!-- Returns a name at an index -->
3768 name=
"u:name4Index">
3778 test=
"not(contains($names, ' '))">
3783 select=
"concat($name0, $names)"/>
3786 <!-- No string with this index -->
3795 select=
"substring-before($names, ' ')"/>
3798 test=
"substring($before, string-length($before)) = '\'">
3799 <!-- Quoted space found -->
3801 name=
"u:name4Index">
3804 select=
"substring-after($names, ' ')"/>
3810 select=
"concat($name0, $before, ' ')"/>
3811 </xsl:call-template>
3814 <!-- Separating space found -->
3819 select=
"concat($name0, $before)"/>
3823 name=
"u:name4Index">
3826 select=
"substring-after($names, ' ')"/>
3829 select=
"$index - 1"/>
3830 </xsl:call-template>
3839 <!-- Output a names attribute at index considering quoted spaces. -->
3841 name=
"u:outputNames">
3842 <!-- Blank line already output? -->
3852 name=
"u:name4Index">
3859 </xsl:call-template>
3862 name=
"u:outputUnbackslashed">
3866 </xsl:call-template>
3869 <!-- ******************************************************************** -->
3871 <!-- Finds an id in a list and returns its index or empty string if not
3872 contained exactly. -->
3889 test=
"$list = $id or starts-with($list, concat($id, ' '))">
3898 select=
"substring-after($list, ' ')"/>
3904 select=
"$index + 1"/>
3905 </xsl:call-template>
3910 <!-- In a number of elements find the one containing exactly id and return
3911 the index of the element as well as the index of the id -->
3913 name=
"u:findRefElem">
3915 name=
"possibleElems"/>
3918 <!-- XSLT is 1-based -->
3924 select=
"$possibleElems[1]"/>
3926 <!-- No more elements - return empty string -->
3928 test=
"not($possibleElems)">
3933 <!-- Check whether the first element contains the id -->
3940 select=
"$elem/@ids"/>
3944 </xsl:call-template>
3950 select=
"concat($elemIndex, ' ', $fnd)"/>
3954 name=
"u:findRefElem">
3956 name=
"possibleElems"
3957 select=
"$possibleElems[position() != 1]"/>
3963 select=
"$elemIndex + 1"/>
3964 </xsl:call-template>
3971 <!-- Output a names attribute for a refid. -->
3973 name=
"u:outputNamesRefid">
3977 <!-- Determine all possible elements which might be referred -->
3979 name=
"possibleElems"
3980 select=
"//*[contains(@ids, $refid)]"/>
3982 name=
"refElem_index">
3984 name=
"u:findRefElem">
3986 name=
"possibleElems"
3987 select=
"$possibleElems"/>
3991 </xsl:call-template>
3994 name=
"u:outputNames">
3997 select=
"$possibleElems[position() = substring-before($refElem_index, ' ')]/@names"/>
4000 select=
"number(substring-after($refElem_index, ' '))"/>
4001 </xsl:call-template>
4004 <!-- ******************************************************************** -->
4006 <!-- Output a string with each space character quoted -->
4008 name=
"u:quoteWhite">
4013 select=
"substring-before($string, ' ')"/>
4022 select=
"concat($head, '\ ')"/>
4024 name=
"u:quoteWhite">
4027 select=
"substring-after($string, ' ')"/>
4028 </xsl:call-template>
4033 <!-- ******************************************************************** -->
4034 <!-- ******************************************************************** -->
4036 <!-- Report unknown tags -->
4040 <xsl:text>`
</xsl:text>
4043 <xsl:text>' encountered
</xsl:text>
4046 <xsl:text> in `
</xsl:text>
4048 select=
"name(parent::*)"/>
4049 <xsl:text>'
</xsl:text>
4051 <xsl:text>, but no template matches.
</xsl:text>
4057 <!-- ********************************************************************** -->
4058 <!-- ********************************************************************** -->
4059 <!-- ********************************************************************** -->
4060 <!-- POD manual page
4064 xml2rst-noexslt.xsl - An XSLT script to convert Docutils XML to reStructuredText
4068 Xalan docutils.xml xml2rst.xsl
4072 Today B<xml2rst-noexslt.xsl> is not the recommended way to use
4073 B<xml2rst>. The preferred way is to install B<lxml> and use
4074 B<xml2rst.py> instead.
4078 B<xml2rst-noexslt.xsl> is an XSLT script to convert Docutils XML to
4079 reStructuredText. You can use your favorite XSLT processor (e.g. Xalan
4080 from the Apache project) to generate reStructuredText from the
4081 Docutils intermediate XML representation. Its main use is to generate
4082 reStructuredText from some other format where a converter to Docutils
4087 The following options are supported. They are XSLT parameters for the
4088 whole script and must be given to the XSLT processor by the respective
4089 option (Xalan: B<-p>).
4095 Configures title markup to use so different styles can be requested
4098 The value of the parameter must be a string made up of a sequence of
4099 character pairs. The first character of a pair is C<o> (overline) or
4100 C<u> (underline) and the second character is the character to use for
4103 The first and the second character pair is used for document title and
4104 subtitle, the following pairs are used for section titles where the
4105 third pair is used for the top level section title.
4107 Defaults to C<o=o-u=u-u~u:u.u`>.
4111 Configures whether long text lines in paragraphs should be folded and
4112 to which length. This option is for input not coming from reST which
4113 may have no internal line feeds in plain text strings.
4115 If folding is enabled text strings not in a line feed preserving
4116 context are first white-space normalized and then broken according to
4117 the folding rules. Folding rules put out the first word and continue
4118 to do so with the following words unless the next word would cross
4119 the folding boundary. Words are delimited by white-space.
4121 Defaults to C<0>, i.e. no folding.
4125 =head2 Unsupported features
4127 It is generally not possible to create an exact reproduction of an
4128 original reStructuredText source from an intermediate XML file. The
4129 reason is that Docutils transports pretty much but not all information
4130 of the original source into the XML. Also the sequence is changed
4133 However, the coverage of Docutils features of B<xml2rst-noexslt.xsl> is
4134 pretty good. A few minor features are not supported:
4138 =item * Fully minimized style for literal blocks
4140 =item * Substitution references for C<replace::> substitutions
4142 =item * Counting roman numbers in enumerated lists
4144 =item * Special table types like C<list-table::> and C<csv-table::>
4146 =item * Custom role definitions
4152 Installation is not necessary. Just use the file as downloaded with
4153 your favorite XSLT processor.
4157 Stefan Merten <smerten@oekonux.de> based on works by David Priest.
4161 This program is licensed under the terms of the GPL. See
4163 http://www.gnu.org/licenses/gpl.txt
4169 http://www.merten-home.de/FreeSoftware/xml2rst/