summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/xsl/LaTeXML/LaTeXML-inline-xhtml.xsl
blob: bbb7b5724d15ab8ac8bb0c1a41ca09d62a8ce57b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?xml version="1.0" encoding="utf-8"?>
<!--
/=====================================================================\ 
|  LaTeXML-inline-xhtml.xsl                                           |
|  Converting various inline-level elements to xhtml                  |
|=====================================================================|
| Part of LaTeXML:                                                    |
|  Public domain software, produced as part of work done by the       |
|  United States Government & not subject to copyright in the US.     |
|=====================================================================|
| Bruce Miller <bruce.miller@nist.gov>                        #_#     |
| http://dlmf.nist.gov/LaTeXML/                              (o o)    |
\=========================================================ooo==U==ooo=/
-->
<xsl:stylesheet
    version     = "1.0"
    xmlns:xsl   = "http://www.w3.org/1999/XSL/Transform"
    xmlns       = "http://www.w3.org/1999/xhtml"
    xmlns:ltx   = "http://dlmf.nist.gov/LaTeXML"
    xmlns:func  = "http://exslt.org/functions"
    xmlns:f     = "http://dlmf.nist.gov/LaTeXML/functions"
    exclude-result-prefixes = "ltx func f">

<!-- ======================================================================
     Visible inline elements
     ====================================================================== -->

<xsl:template match="ltx:text">
 <span style="{f:positioning(.)}" class="{concat(f:classes(.),
					 f:if(@font,concat(' ',@font),''),
					 f:if(@size,concat(' ',@size),''))}">
   <xsl:call-template name="add_id"/>
   <xsl:apply-templates/>
 </span>
</xsl:template>

<xsl:template match="ltx:emph">
  <em class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></em>
</xsl:template>

<xsl:template match="ltx:acronym">
  <acronym class='{f:classes(.)}' title="{@name}"><xsl:call-template name="add_id"/><xsl:apply-templates/></acronym>
</xsl:template>


<!-- This should either get some sort of style w/width,height & background,
     or, at most, only be an hr if it's wide & short -->
<xsl:template match="ltx:rule">
  <span style="{concat(f:positioning(.),'background:black; ')}" class="{f:classes(.)}">&#xA0;</span>
</xsl:template>

<xsl:template match="ltx:ref">
  <xsl:choose>
    <xsl:when test="not(@href) or @href=''">
      <span class="{concat(f:classes(.),' here')}"><xsl:call-template name="add_id"/><xsl:apply-templates/></span>
    </xsl:when>
    <xsl:otherwise>
      <a href="{@href}" title="{@title}" class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></a>
    </xsl:otherwise>
  </xsl:choose>    
</xsl:template>

<!-- can't nest-->
<xsl:template match="ltx:ref//ltx:ref">
  <span class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></span>
</xsl:template>

<xsl:template match="ltx:anchor">
  <a name="{@xml:id}" class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></a>
</xsl:template>

<xsl:template match="ltx:cite">
  <cite class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></cite>
</xsl:template>

<!-- ltx:bibref not handled, since it is translated to ref in crossref module -->

<!-- ======================================================================
     Typically invisible meta elements
     ====================================================================== -->

<!-- normally hidden -->
<xsl:template match="ltx:note">
  <span class="{concat(f:classes(.),' ',@role)}">
    <xsl:call-template name="add_id"/>
    <xsl:call-template name="note-mark"/>
    <span class="{concat(local-name(.),'_content_outer')}">
      <span class="{concat(local-name(.),'_content')}">
	<xsl:call-template name="note-mark"/>
	<xsl:if test="not(@role = 'footnote')">
	  <span class="note-type"><xsl:value-of select="@role"/>: </span>
	</xsl:if>
	<xsl:apply-templates/>
      </span>
    </span>
  </span>
</xsl:template>

<xsl:template name="note-mark">
  <sup class="mark">
    <xsl:choose>
      <xsl:when test="@mark"><xsl:value-of select="@mark"/></xsl:when>
      <xsl:otherwise>&#x2020;</xsl:otherwise>
    </xsl:choose>
  </sup>
</xsl:template>

<xsl:template match="ltx:ERROR">
  <span class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></span>
</xsl:template>

<!-- invisible -->
<xsl:template match="ltx:indexmark"/>

<xsl:template match="ltx:indexphrase">
  <span class="{f:classes(.)}"><xsl:call-template name="add_id"/><xsl:apply-templates/></span>
</xsl:template>

</xsl:stylesheet>