/
html2wiki.xslt
executable file
·82 lines (64 loc) · 1.96 KB
/
html2wiki.xslt
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
<?xml version="1.0" encoding="Windows-1251"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="text" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a">
<xsl:value-of select="@href" />
</xsl:template>
<xsl:template match="h1">
= <xsl:apply-templates /> =
</xsl:template>
<xsl:template match="h2">
== <xsl:apply-templates /> ==
</xsl:template>
<xsl:template match="h3">
== <xsl:apply-templates /> ==
</xsl:template>
<xsl:template match="h4">
=== <xsl:apply-templates /> ===
</xsl:template>
<xsl:template match="p">
<xsl:text xml:space="preserve">
</xsl:text>
<xsl:apply-templates/>
<xsl:text xml:space="preserve">
</xsl:text>
</xsl:template>
<xsl:template match="u"> __<xsl:apply-templates/>__</xsl:template>
<xsl:template match="em"> *<xsl:apply-templates/>*</xsl:template>
<xsl:template match="pre[parent::blockquote]">
{{{
<xsl:apply-templates/>
}}}
</xsl:template>
<xsl:template match="pre">
{{{
<xsl:apply-templates/>
}}}
</xsl:template>
<xsl:template match="li[parent::ul]">
<xsl:text disable-output-escaping="yes">
* </xsl:text> <xsl:apply-templates/>
</xsl:template>
<xsl:template match="li[parent::ol]">
<xsl:text xml:space="preserve">
</xsl:text>
<xsl:value-of select="position()"/>.<xsl:text xml:space="preserve"> </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="dt[parent::dl]">
<xsl:text disable-output-escaping="yes">
* </xsl:text> <xsl:apply-templates/>
</xsl:template>
<xsl:template match="dd[parent::dl]">
<xsl:text xml:space="preserve">
</xsl:text>
<xsl:value-of select="position()"/>.<xsl:text xml:space="preserve"> </xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*">
<xsl:text xml:space="preserve"> </xsl:text><xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>