-
Notifications
You must be signed in to change notification settings - Fork 0
/
knitr.xsl
49 lines (44 loc) · 1.59 KB
/
knitr.xsl
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
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:r="http://www.r-project.org">
<xsl:output method="html" indent="yes"/>
<xsl:include href="common.xsl"/>
<xsl:template name="echo-attr">
<xsl:choose>
<xsl:when test="name() = 'id'">
<xsl:value-of select="current()"/>
</xsl:when>
<xsl:when
test="name() = 'echo' or
name() = 'eval' or
name() = 'fig.width' or
name() = 'fig.height' or
name() = 'dpi' or
name() = 'dev.args' or
name() = 'warning' or
name() = 'include' or
name() = 'message'">
<xsl:value-of select="name()"/>=<xsl:value-of select="current()"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name()"/>="<xsl:value-of select="current()"/><xsl:text>"</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="position() != last()">
<xsl:text>, </xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="//rcode">
<xsl:comment>begin.rcode <xsl:for-each select="@*">
<xsl:call-template name="echo-attr"/>
</xsl:for-each>
<xsl:apply-templates/>end.rcode</xsl:comment>
</xsl:template>
<xsl:template match="//bash">
<xsl:comment>begin.rcode engine="bash"<xsl:if test="@*">, <xsl:for-each select="@*">
<xsl:call-template name="echo-attr"/>
</xsl:for-each></xsl:if>
<xsl:apply-templates/>end.rcode</xsl:comment>
</xsl:template>
</xsl:stylesheet>