ENH: No verbose a2x output when building UserGuide
[freefoam.git] / data / asciidoc / dblatex / asciidoc-dblatex.xsl
blob8e60b1b9c8822b0c9e8e9b74a2368342c803f384
1 <?xml version='1.0'?>
2 <!--
3 Additional user-stylesheet for dblatex. It customizes
4 - the template matching the <alt> element such that no automatic math mode
5 wrappers are added
6 - the appearance of <gui(menu|label|button|icon)> elements
7 -->
8 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
10 <xsl:import href="orig-asciidoc-dblatex.xsl"/>
12 <!-- Direct copy of the content -->
14 <xsl:template match="alt" mode="latex">
15 <xsl:variable name="delim">
16 <xsl:if test="processing-instruction('texmath')">
17 <xsl:call-template name="pi-attribute">
18 <xsl:with-param name="pis"
19 select="processing-instruction('texmath')"/>
20 <xsl:with-param name="attribute" select="'delimiters'"/>
21 </xsl:call-template>
22 </xsl:if>
23 </xsl:variable>
25 <xsl:variable name="tex">
26 <xsl:variable name="text" select="normalize-space(.)"/>
27 <xsl:variable name="len" select="string-length($text)"/>
28 <xsl:choose>
29 <xsl:when test="$delim='user'">
30 <xsl:copy-of select="."/>
31 </xsl:when>
32 <xsl:when test="ancestor::equation[not(child::title)]">
33 <!-- Remove any math mode in an equation environment -->
34 <xsl:choose>
35 <xsl:when test="starts-with($text,'$') and
36 substring($text,$len,$len)='$'">
37 <xsl:copy-of select="substring($text, 2, $len - 2)"/>
38 </xsl:when>
39 <xsl:when test="(starts-with($text,'\[') and
40 substring($text,$len - 1,$len)='\]') or
41 (starts-with($text,'\(') and
42 substring($text,$len - 1,$len)='\)')">
43 <xsl:copy-of select="substring($text, 3, $len - 4)"/>
44 </xsl:when>
45 <xsl:otherwise>
46 <xsl:copy-of select="."/>
47 </xsl:otherwise>
48 </xsl:choose>
49 </xsl:when>
50 <!-- Test to be DB5 compatible, where <alt> can be in other elements -->
51 <xsl:when test="ancestor::equation or
52 ancestor::informalequation or
53 ancestor::inlineequation">
54 <!-- Keep the specified math mode... -->
55 <xsl:choose>
56 <xsl:when test="(starts-with($text,'\[') and
57 substring($text,$len - 1,$len)='\]') or
58 (starts-with($text,'\(') and
59 substring($text,$len - 1,$len)='\)') or
60 (starts-with($text,'$') and
61 substring($text,$len,$len)='$')">
62 <xsl:copy-of select="$text"/>
63 </xsl:when>
64 <!-- ...Or wrap in default math mode -->
65 <xsl:otherwise>
66 <!-- ...Or rather not...
67 <xsl:copy-of select="concat('$', $text, '$')"/>-->
68 <xsl:copy-of select="$text"/>
69 </xsl:otherwise>
70 </xsl:choose>
71 </xsl:when>
72 <xsl:otherwise/>
73 </xsl:choose>
74 </xsl:variable>
75 <!-- Encode it properly -->
76 <xsl:call-template name="scape-encode">
77 <xsl:with-param name="string" select="$tex"/>
78 </xsl:call-template>
79 </xsl:template>
81 <xsl:template match="guibutton|guiicon|guilabel|guimenu">
82 <xsl:call-template name="inline.italicseq"/>
83 </xsl:template>
85 </xsl:stylesheet>