html2odt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +21 -0
- data/README.md +163 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/html2odt.gemspec +29 -0
- data/lib/html2odt/document.rb +309 -0
- data/lib/html2odt/image.rb +82 -0
- data/lib/html2odt/version.rb +3 -0
- data/lib/html2odt.rb +18 -0
- data/odt/template.odt +0 -0
- data/xsl/LICENSE.txt +502 -0
- data/xsl/README.rst +144 -0
- data/xsl/document-content/block.xsl +169 -0
- data/xsl/document-content/html5.xsl +122 -0
- data/xsl/document-content/ignore.xsl +93 -0
- data/xsl/document-content/inline.xsl +167 -0
- data/xsl/document-content/link.xsl +127 -0
- data/xsl/document-content/lists.xsl +130 -0
- data/xsl/document-content/media.xsl +130 -0
- data/xsl/document-content/paragraph.xsl +151 -0
- data/xsl/document-content/section.xsl +80 -0
- data/xsl/document-content/tables.xsl +334 -0
- data/xsl/document-content.xsl +63 -0
- data/xsl/param.xsl +70 -0
- data/xsl/specific/elyxer.xsl +93 -0
- data/xsl/specific/geshi.xsl +94 -0
- data/xsl/specific/lyx.xsl +101 -0
- data/xsl/specific/pygments.xsl +170 -0
- data/xsl/specific/trac.xsl +61 -0
- data/xsl/specific.xsl +58 -0
- data/xsl/styles/automatic-styles.xsl +388 -0
- data/xsl/styles/fonts.xsl +62 -0
- data/xsl/styles/highlight.xsl +152 -0
- data/xsl/styles/inline.xsl +114 -0
- data/xsl/styles/main-styles.xsl +455 -0
- data/xsl/styles.xsl +143 -0
- data/xsl/xhtml2odt.xsl +116 -0
- metadata +185 -0
@@ -0,0 +1,167 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
38
|
+
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
39
|
+
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
40
|
+
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template match="h:em|h:i"/>
|
55
|
+
<xsl:template match="h:em|h:i" mode="inparagraph">
|
56
|
+
<text:span text:style-name="emphasis">
|
57
|
+
<xsl:apply-templates mode="inparagraph"/>
|
58
|
+
</text:span>
|
59
|
+
</xsl:template>
|
60
|
+
|
61
|
+
<xsl:template match="h:strong|h:b"/>
|
62
|
+
<xsl:template match="h:strong|h:b" mode="inparagraph">
|
63
|
+
<text:span text:style-name="strong">
|
64
|
+
<xsl:apply-templates mode="inparagraph"/>
|
65
|
+
</text:span>
|
66
|
+
</xsl:template>
|
67
|
+
|
68
|
+
<xsl:template match="h:sup"/>
|
69
|
+
<xsl:template match="h:sup" mode="inparagraph">
|
70
|
+
<text:span text:style-name="sup">
|
71
|
+
<xsl:apply-templates mode="inparagraph"/>
|
72
|
+
</text:span>
|
73
|
+
</xsl:template>
|
74
|
+
|
75
|
+
<xsl:template match="h:sub"/>
|
76
|
+
<xsl:template match="h:sub" mode="inparagraph">
|
77
|
+
<text:span text:style-name="sub">
|
78
|
+
<xsl:apply-templates mode="inparagraph"/>
|
79
|
+
</text:span>
|
80
|
+
</xsl:template>
|
81
|
+
|
82
|
+
<xsl:template match="h:code|h:tt|h:samp|h:kbd"/>
|
83
|
+
<xsl:template match="h:code|h:tt|h:samp|h:kbd" mode="inparagraph">
|
84
|
+
<text:span text:style-name="Teletype">
|
85
|
+
<xsl:apply-templates mode="inparagraph"/>
|
86
|
+
</text:span>
|
87
|
+
</xsl:template>
|
88
|
+
|
89
|
+
<xsl:template match="h:br">
|
90
|
+
<text:line-break/>
|
91
|
+
</xsl:template>
|
92
|
+
<xsl:template match="h:br" mode="inparagraph">
|
93
|
+
<text:line-break/>
|
94
|
+
</xsl:template>
|
95
|
+
|
96
|
+
<xsl:template match="h:del"/>
|
97
|
+
<xsl:template match="h:del" mode="inparagraph">
|
98
|
+
<text:span text:style-name="strike">
|
99
|
+
<xsl:apply-templates mode="inparagraph"/>
|
100
|
+
</text:span>
|
101
|
+
</xsl:template>
|
102
|
+
|
103
|
+
<xsl:template match="h:abbr|h:acronym"/>
|
104
|
+
<xsl:template match="h:abbr|h:acronym" mode="inparagraph">
|
105
|
+
<xsl:apply-templates mode="inparagraph"/>
|
106
|
+
<xsl:variable name="footnotenum"
|
107
|
+
select="count(preceding::h:abbr) + count(preceding::h:acronym) + 1"/>
|
108
|
+
<text:note text:note-class="footnote">
|
109
|
+
<xsl:attribute name="text:id">
|
110
|
+
<xsl:text>ftn</xsl:text>
|
111
|
+
<xsl:value-of select="$footnotenum"/>
|
112
|
+
</xsl:attribute>
|
113
|
+
<text:note-citation>
|
114
|
+
<xsl:value-of select="$footnotenum"/>
|
115
|
+
</text:note-citation>
|
116
|
+
<text:note-body>
|
117
|
+
<text:p text:style-name="Footnote">
|
118
|
+
<xsl:value-of select="@title"/>
|
119
|
+
</text:p>
|
120
|
+
</text:note-body>
|
121
|
+
</text:note>
|
122
|
+
</xsl:template>
|
123
|
+
|
124
|
+
<xsl:template match="h:big"/>
|
125
|
+
<xsl:template match="h:big" mode="inparagraph">
|
126
|
+
<text:span text:style-name="big">
|
127
|
+
<xsl:apply-templates mode="inparagraph"/>
|
128
|
+
</text:span>
|
129
|
+
</xsl:template>
|
130
|
+
|
131
|
+
<xsl:template match="h:small"/>
|
132
|
+
<xsl:template match="h:small" mode="inparagraph">
|
133
|
+
<text:span text:style-name="small">
|
134
|
+
<xsl:apply-templates mode="inparagraph"/>
|
135
|
+
</text:span>
|
136
|
+
</xsl:template>
|
137
|
+
|
138
|
+
<xsl:template match="h:cite|h:dfn|h:var"/>
|
139
|
+
<xsl:template match="h:cite|h:dfn|h:var" mode="inparagraph">
|
140
|
+
<text:span text:style-name="Citation">
|
141
|
+
<xsl:apply-templates mode="inparagraph"/>
|
142
|
+
</text:span>
|
143
|
+
</xsl:template>
|
144
|
+
|
145
|
+
<xsl:template match="h:q"/>
|
146
|
+
<xsl:template match="h:q" mode="inparagraph">
|
147
|
+
<xsl:text>"</xsl:text>
|
148
|
+
<xsl:apply-templates mode="inparagraph"/>
|
149
|
+
<xsl:text>"</xsl:text>
|
150
|
+
</xsl:template>
|
151
|
+
|
152
|
+
<xsl:template match="h:ins"/>
|
153
|
+
<xsl:template match="h:ins" mode="inparagraph">
|
154
|
+
<text:span text:style-name="underline">
|
155
|
+
<xsl:apply-templates mode="inparagraph"/>
|
156
|
+
</text:span>
|
157
|
+
</xsl:template>
|
158
|
+
|
159
|
+
<xsl:template match="h:u"/>
|
160
|
+
<xsl:template match="h:u" mode="inparagraph">
|
161
|
+
<text:span text:style-name="underline">
|
162
|
+
<xsl:apply-templates mode="inparagraph"/>
|
163
|
+
</text:span>
|
164
|
+
</xsl:template>
|
165
|
+
|
166
|
+
|
167
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,127 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
38
|
+
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
39
|
+
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
40
|
+
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template match="h:a">
|
55
|
+
<xsl:call-template name="link">
|
56
|
+
<xsl:with-param name="mode" select="''"/>
|
57
|
+
</xsl:call-template>
|
58
|
+
</xsl:template>
|
59
|
+
<xsl:template match="h:a" mode="inparagraph">
|
60
|
+
<xsl:call-template name="link">
|
61
|
+
<xsl:with-param name="mode" select="'inparagraph'"/>
|
62
|
+
</xsl:call-template>
|
63
|
+
</xsl:template>
|
64
|
+
|
65
|
+
<xsl:template name="link">
|
66
|
+
<xsl:param name="mode"/>
|
67
|
+
<xsl:choose>
|
68
|
+
<xsl:when test="h:img">
|
69
|
+
<draw:a>
|
70
|
+
<xsl:call-template name="link-content">
|
71
|
+
<xsl:with-param name="mode" select="$mode"/>
|
72
|
+
</xsl:call-template>
|
73
|
+
</draw:a>
|
74
|
+
</xsl:when>
|
75
|
+
<xsl:otherwise>
|
76
|
+
<text:a>
|
77
|
+
<xsl:call-template name="link-content">
|
78
|
+
<xsl:with-param name="mode" select="$mode"/>
|
79
|
+
</xsl:call-template>
|
80
|
+
</text:a>
|
81
|
+
</xsl:otherwise>
|
82
|
+
</xsl:choose>
|
83
|
+
</xsl:template>
|
84
|
+
|
85
|
+
<xsl:template name="link-content">
|
86
|
+
<xsl:param name="mode"/>
|
87
|
+
<xsl:attribute name="xlink:type"><xsl:text>simple</xsl:text></xsl:attribute>
|
88
|
+
<xsl:attribute name="xlink:href">
|
89
|
+
<xsl:choose>
|
90
|
+
<xsl:when test="contains(@href, '#') and substring-before(@href,'#') = $url">
|
91
|
+
<xsl:text>#</xsl:text><xsl:value-of select="substring-after(@href,'#')"/>
|
92
|
+
</xsl:when>
|
93
|
+
<xsl:otherwise>
|
94
|
+
<xsl:value-of select="@href"/>
|
95
|
+
</xsl:otherwise>
|
96
|
+
</xsl:choose>
|
97
|
+
</xsl:attribute>
|
98
|
+
<xsl:choose>
|
99
|
+
<xsl:when test="@id">
|
100
|
+
<text:bookmark-start>
|
101
|
+
<xsl:attribute name="text:name">
|
102
|
+
<xsl:value-of select="@id"/>
|
103
|
+
</xsl:attribute>
|
104
|
+
</text:bookmark-start>
|
105
|
+
</xsl:when>
|
106
|
+
</xsl:choose>
|
107
|
+
<xsl:choose>
|
108
|
+
<xsl:when test="$mode = 'inparagraph'">
|
109
|
+
<xsl:apply-templates mode="inparagraph"/>
|
110
|
+
</xsl:when>
|
111
|
+
<xsl:otherwise>
|
112
|
+
<xsl:apply-templates/>
|
113
|
+
</xsl:otherwise>
|
114
|
+
</xsl:choose>
|
115
|
+
<xsl:choose>
|
116
|
+
<xsl:when test="@id">
|
117
|
+
<text:bookmark-end>
|
118
|
+
<xsl:attribute name="text:name">
|
119
|
+
<xsl:value-of select="@id"/>
|
120
|
+
</xsl:attribute>
|
121
|
+
</text:bookmark-end>
|
122
|
+
</xsl:when>
|
123
|
+
</xsl:choose>
|
124
|
+
</xsl:template>
|
125
|
+
|
126
|
+
|
127
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,130 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
38
|
+
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
39
|
+
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
40
|
+
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template match="h:ul" mode="inparagraph"/>
|
55
|
+
<xsl:template match="h:ul">
|
56
|
+
<xsl:param name="nolists" select="false()"/>
|
57
|
+
<!-- No lists inside lists (handled separately, see below) -->
|
58
|
+
<xsl:if test="not($nolists)">
|
59
|
+
<text:list text:style-name="List_20_1">
|
60
|
+
<xsl:apply-templates select="h:li"/>
|
61
|
+
</text:list>
|
62
|
+
</xsl:if>
|
63
|
+
</xsl:template>
|
64
|
+
|
65
|
+
|
66
|
+
<xsl:template match="h:ol" mode="inparagraph"/>
|
67
|
+
<xsl:template match="h:ol">
|
68
|
+
<xsl:param name="nolists" select="false()"/>
|
69
|
+
<!-- No lists inside lists (handled separately, see below) -->
|
70
|
+
<xsl:if test="not($nolists)">
|
71
|
+
<text:list text:style-name="Numbering_20_1">
|
72
|
+
<xsl:apply-templates select="h:li" />
|
73
|
+
</text:list>
|
74
|
+
</xsl:if>
|
75
|
+
</xsl:template>
|
76
|
+
|
77
|
+
<!-- li -->
|
78
|
+
|
79
|
+
<xsl:template match="h:li" mode="inparagraph"/>
|
80
|
+
<xsl:template match="h:li">
|
81
|
+
<text:list-item>
|
82
|
+
<text:p>
|
83
|
+
<xsl:attribute name="text:style-name">
|
84
|
+
<xsl:text>list-item</xsl:text>
|
85
|
+
<xsl:choose>
|
86
|
+
<xsl:when test="parent::h:ul"><xsl:text>-bullet</xsl:text></xsl:when>
|
87
|
+
<xsl:when test="parent::h:ol"><xsl:text>-number</xsl:text></xsl:when>
|
88
|
+
<xsl:otherwise></xsl:otherwise>
|
89
|
+
</xsl:choose>
|
90
|
+
</xsl:attribute>
|
91
|
+
<xsl:apply-templates select="child::node()" mode="inparagraph">
|
92
|
+
<!-- sublists must be after the </text:p> -->
|
93
|
+
<xsl:with-param name="nolists" select="true()"/>
|
94
|
+
</xsl:apply-templates>
|
95
|
+
</text:p>
|
96
|
+
<xsl:apply-templates select="h:ul|h:ol|h:pre|h:blockquote"/>
|
97
|
+
</text:list-item>
|
98
|
+
</xsl:template>
|
99
|
+
|
100
|
+
|
101
|
+
<!-- Definition lists -->
|
102
|
+
<xsl:template match="h:dl" mode="inparagraph"/>
|
103
|
+
<xsl:template match="h:dl">
|
104
|
+
<!--<xsl:apply-templates select="h:dt"/>-->
|
105
|
+
<xsl:apply-templates/>
|
106
|
+
</xsl:template>
|
107
|
+
|
108
|
+
<xsl:template match="h:dt" mode="inparagraph"/>
|
109
|
+
<xsl:template match="h:dt">
|
110
|
+
<xsl:call-template name="paragraph"/>
|
111
|
+
<!--
|
112
|
+
<text:p text:style-name="Definition_20_Term">
|
113
|
+
<xsl:apply-templates mode="inparagraph"/>
|
114
|
+
</text:p>
|
115
|
+
<xsl:apply-templates select="following-sibling::h:dd[position()=1]"/>
|
116
|
+
-->
|
117
|
+
</xsl:template>
|
118
|
+
|
119
|
+
<xsl:template match="h:dd" mode="inparagraph"/>
|
120
|
+
<xsl:template match="h:dd">
|
121
|
+
<xsl:call-template name="paragraph"/>
|
122
|
+
<!--
|
123
|
+
<text:p text:style-name="Definition_20_Description">
|
124
|
+
<xsl:apply-templates mode="inparagraph"/>
|
125
|
+
</text:p>
|
126
|
+
-->
|
127
|
+
</xsl:template>
|
128
|
+
|
129
|
+
|
130
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,130 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
xhtml2odt - XHTML to ODT XML transformation.
|
5
|
+
Copyright (C) 2009 Aurelien Bompard
|
6
|
+
Inspired by the work on docbook2odt, by Roman Fordinal
|
7
|
+
http://open.comsultia.com/docbook2odf/
|
8
|
+
|
9
|
+
License: LGPL v2.1 or later <http://www.gnu.org/licenses/lgpl-2.1.html>
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
24
|
+
MA 02110-1301 USA
|
25
|
+
|
26
|
+
-->
|
27
|
+
<xsl:stylesheet
|
28
|
+
xmlns:h="http://www.w3.org/1999/xhtml"
|
29
|
+
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
|
30
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
31
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
32
|
+
xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
|
33
|
+
xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
|
34
|
+
xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
|
35
|
+
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
|
36
|
+
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
|
37
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
38
|
+
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
|
39
|
+
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
|
40
|
+
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
|
41
|
+
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
|
42
|
+
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
|
43
|
+
xmlns:math="http://www.w3.org/1998/Math/MathML"
|
44
|
+
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
|
45
|
+
xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
|
46
|
+
xmlns:dom="http://www.w3.org/2001/xml-events"
|
47
|
+
xmlns:xforms="http://www.w3.org/2002/xforms"
|
48
|
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
49
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
50
|
+
xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0"
|
51
|
+
version="1.0">
|
52
|
+
|
53
|
+
|
54
|
+
<xsl:template match="h:img">
|
55
|
+
<text:p text:style-name="Text_20_body">
|
56
|
+
<xsl:call-template name="image"/>
|
57
|
+
</text:p>
|
58
|
+
</xsl:template>
|
59
|
+
<xsl:template match="h:img" mode="inparagraph">
|
60
|
+
<xsl:call-template name="image"/>
|
61
|
+
</xsl:template>
|
62
|
+
|
63
|
+
<xsl:template name="image">
|
64
|
+
|
65
|
+
<!-- @align -->
|
66
|
+
<!-- @contentwidth -->
|
67
|
+
<!-- @contentheight -->
|
68
|
+
<!-- @fileref -->
|
69
|
+
<!-- @format -->
|
70
|
+
<!-- @scale -->
|
71
|
+
<!-- @scalefit -->
|
72
|
+
<!-- @valign -->
|
73
|
+
<!-- @width -->
|
74
|
+
<!-- @depth -->
|
75
|
+
|
76
|
+
<xsl:element name="draw:frame">
|
77
|
+
|
78
|
+
<xsl:choose>
|
79
|
+
<xsl:when test="substring-before(@width,'cm') < $img_inline_threshold
|
80
|
+
and substring-before(@height,'cm') < $img_inline_threshold">
|
81
|
+
<xsl:attribute name="text:anchor-type">as-char</xsl:attribute>
|
82
|
+
<xsl:attribute name="draw:style-name">image-inline</xsl:attribute>
|
83
|
+
</xsl:when>
|
84
|
+
<xsl:when test="contains(@style,'float:') and contains(@style,'left')">
|
85
|
+
<xsl:attribute name="text:anchor-type">paragraph</xsl:attribute>
|
86
|
+
<xsl:attribute name="draw:style-name">image-left</xsl:attribute>
|
87
|
+
</xsl:when>
|
88
|
+
<xsl:when test="contains(@style,'float:') and contains(@style,'right')">
|
89
|
+
<xsl:attribute name="text:anchor-type">paragraph</xsl:attribute>
|
90
|
+
<xsl:attribute name="draw:style-name">image-right</xsl:attribute>
|
91
|
+
</xsl:when>
|
92
|
+
<xsl:otherwise>
|
93
|
+
<xsl:attribute name="text:anchor-type">paragraph</xsl:attribute>
|
94
|
+
<xsl:attribute name="draw:style-name">image-center</xsl:attribute>
|
95
|
+
</xsl:otherwise>
|
96
|
+
</xsl:choose>
|
97
|
+
|
98
|
+
<xsl:attribute name="draw:name">imageobject-<xsl:value-of select="generate-id()"/></xsl:attribute>
|
99
|
+
|
100
|
+
<xsl:choose>
|
101
|
+
<xsl:when test="@width and @height">
|
102
|
+
<xsl:attribute name="svg:width"><xsl:value-of select="@width"/></xsl:attribute>
|
103
|
+
<xsl:attribute name="svg:height"><xsl:value-of select="@height"/></xsl:attribute>
|
104
|
+
</xsl:when>
|
105
|
+
<xsl:otherwise>
|
106
|
+
<!-- In OpenDocument svg:width and height must be defined. Use defaults here -->
|
107
|
+
<xsl:attribute name="svg:width"><xsl:value-of select="$img_default_width"/></xsl:attribute>
|
108
|
+
<xsl:attribute name="svg:height"><xsl:value-of select="$img_default_height"/></xsl:attribute>
|
109
|
+
</xsl:otherwise>
|
110
|
+
</xsl:choose>
|
111
|
+
|
112
|
+
<xsl:attribute name="svg:y">0.20cm</xsl:attribute>
|
113
|
+
|
114
|
+
<xsl:attribute name="draw:z-index">1</xsl:attribute>
|
115
|
+
<xsl:element name="draw:image">
|
116
|
+
<xsl:attribute name="xlink:href"><xsl:value-of select="@src"/></xsl:attribute>
|
117
|
+
<xsl:attribute name="xlink:type">simple</xsl:attribute>
|
118
|
+
<xsl:attribute name="xlink:show">embed</xsl:attribute>
|
119
|
+
<xsl:attribute name="xlink:actuate">onLoad</xsl:attribute>
|
120
|
+
</xsl:element>
|
121
|
+
|
122
|
+
<xsl:element name="svg:title"><xsl:value-of select="@alt"/></xsl:element>
|
123
|
+
|
124
|
+
</xsl:element>
|
125
|
+
|
126
|
+
</xsl:template>
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
</xsl:stylesheet>
|