html2odt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/xsl/README.rst
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
XHTML to ODT XML transformation
|
2
|
+
===============================
|
3
|
+
|
4
|
+
These stylesheets convert namespaced XHTML to ODT_.
|
5
|
+
|
6
|
+
You can download_ them from the project's website_.
|
7
|
+
|
8
|
+
The HTML must be well-formed and valid, so I recommand running it through Tidy_
|
9
|
+
before sending it to the stylesheets.
|
10
|
+
|
11
|
+
Those stylesheets do not build a whole ODT file, they only convert the XHTML to
|
12
|
+
the equivalent OpenDocument XML. The result can then be inserted in a template
|
13
|
+
ODT file. The HTML may be included in an ODT document, the ODT will be left
|
14
|
+
untouched.
|
15
|
+
|
16
|
+
.. _website: http://xhtml2odt.org/
|
17
|
+
.. _download: http://xhtml2odt.org/dl/
|
18
|
+
.. _ODT: http://en.wikipedia.org/wiki/OpenDocument
|
19
|
+
.. _Tidy: http://tidy.sourceforge.net/
|
20
|
+
|
21
|
+
|
22
|
+
Caveats
|
23
|
+
-------
|
24
|
+
|
25
|
+
Styles:
|
26
|
+
Some default styles will be added to the document, but not on the first
|
27
|
+
pass. After converting to ODT, you must run the ``content.xml`` and the
|
28
|
+
``styles.xml`` files (in the ODT file) through the ``xsl/styles.xsl``
|
29
|
+
stylesheet to add the styles. When the default styles are added, the
|
30
|
+
stylesheet checks that the style is not already present, so customizations
|
31
|
+
to the template ODT file will be preserved. It will however add styles that
|
32
|
+
are not used in the text, but that's harmless.
|
33
|
+
|
34
|
+
Images:
|
35
|
+
Images are not added, you must manually go trough the ``draw:image``
|
36
|
+
elements in the converted ODT text and use the ``xlink:href`` attribute to
|
37
|
+
download or copy the image. While you're at it, you should update the image
|
38
|
+
dimensions if the were not provided in the ``img`` tag.
|
39
|
+
|
40
|
+
|
41
|
+
Command-line scripts
|
42
|
+
--------------------
|
43
|
+
|
44
|
+
Three command-line scripts to run the stylesheets are provided, one is
|
45
|
+
Python-based, the other is PHP-based, the last one is shell-based. The first
|
46
|
+
two do import the styles and the images, so they can also be used as a code
|
47
|
+
example for these two steps in other languages and actual export plugins. The
|
48
|
+
shell script is more of a minimalist approach to demonstrate the simplest
|
49
|
+
possible use of the stylesheets.
|
50
|
+
|
51
|
+
Documentation for the PHP and Python scripts can be generated using the ``make
|
52
|
+
doc`` command. This will require Sphinx_ for Python and phpDocumentor_ for PHP.
|
53
|
+
|
54
|
+
.. _sphinx: http://sphinx.pocoo.org/
|
55
|
+
.. _phpDocumentor: http://www.phpdoc.org/
|
56
|
+
|
57
|
+
The python script
|
58
|
+
^^^^^^^^^^^^^^^^^
|
59
|
+
|
60
|
+
The python script is the preferred command-line script, because it currently is
|
61
|
+
a little more complete than the PHP script. It depends on the following Python
|
62
|
+
modules:
|
63
|
+
|
64
|
+
* uTidylib_
|
65
|
+
* lxml_
|
66
|
+
* PIL_
|
67
|
+
|
68
|
+
To get information on the script's options, run it with ``--help``::
|
69
|
+
|
70
|
+
./xhtml2odt.py --help
|
71
|
+
|
72
|
+
The script can be installed on the system with the ``make install`` command.
|
73
|
+
|
74
|
+
.. _uTidylib: http://pypi.python.org/pypi/uTidylib
|
75
|
+
.. _lxml: http://pypi.python.org/pypi/lxml
|
76
|
+
.. _PIL: http://pypi.python.org/pypi/PIL
|
77
|
+
|
78
|
+
The PHP script
|
79
|
+
^^^^^^^^^^^^^^
|
80
|
+
|
81
|
+
The PHP script can be used as an example to create an ODT export plugin for a
|
82
|
+
PHP-based application. It contains comments on what you should do differently
|
83
|
+
in a web-based application. If you want a real PHP-based export plugin, you can
|
84
|
+
look at the code of the `Dotclear ODT export plugin`_.
|
85
|
+
|
86
|
+
The PHP script requires the zip_ module, and will work better with the `tidy
|
87
|
+
extension`_.
|
88
|
+
|
89
|
+
To get information on the script's options, run it with ``--help``::
|
90
|
+
|
91
|
+
./xhtml2odt.php --help
|
92
|
+
|
93
|
+
.. _Dotclear ODT export plugin: http://lab.dotclear.org/wiki/plugin/odt
|
94
|
+
.. _zip: http://php.net/manual/en/zip.installation.php
|
95
|
+
.. _tidy extension: http://php.net/manual/en/book.tidy.php
|
96
|
+
|
97
|
+
|
98
|
+
Tests
|
99
|
+
-----
|
100
|
+
|
101
|
+
The unit tests are python-based, you need to install the nose_ python module
|
102
|
+
availble from PyPI (or your distribution).
|
103
|
+
|
104
|
+
Then, just run ``nosetests tests``.
|
105
|
+
|
106
|
+
.. _nose: http://pypi.python.org/pypi/nose/
|
107
|
+
|
108
|
+
|
109
|
+
References
|
110
|
+
----------
|
111
|
+
|
112
|
+
* `ODT export for Dotclear <http://lab.dotclear.org/wiki/plugin/odt>`_
|
113
|
+
* `ODT export for Trac <http://trac-hacks.org/wiki/OdtExportPlugin>`_
|
114
|
+
* `ODT export for Dokuwiki <http://www.dokuwiki.org/plugin:odt>`_
|
115
|
+
(not using this project, but similar and by the same author)
|
116
|
+
|
117
|
+
|
118
|
+
License
|
119
|
+
-------
|
120
|
+
|
121
|
+
Copyright (C) 2009-2010 `Aurelien Bompard`_.
|
122
|
+
|
123
|
+
Inspired by the work on docbook2odt_, by Roman Fordinal. Many thanks to him.
|
124
|
+
|
125
|
+
.. _Aurelien Bompard: http://aurelien.bompard.org/
|
126
|
+
.. _docbook2odt: http://open.comsultia.com/docbook2odf/
|
127
|
+
|
128
|
+
License is LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl-2.1.html
|
129
|
+
|
130
|
+
This library is free software; you can redistribute it and/or
|
131
|
+
modify it under the terms of the GNU Lesser General Public
|
132
|
+
License as published by the Free Software Foundation; either
|
133
|
+
version 2.1 of the License, or (at your option) any later version.
|
134
|
+
|
135
|
+
This library is distributed in the hope that it will be useful,
|
136
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
137
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
138
|
+
Lesser General Public License for more details.
|
139
|
+
|
140
|
+
You should have received a copy of the GNU Lesser General Public
|
141
|
+
License along with this library; if not, write to the Free Software
|
142
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
143
|
+
|
144
|
+
.. vim:syntax=rst
|
@@ -0,0 +1,169 @@
|
|
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
|
+
|
55
|
+
<xsl:template match="h:blockquote">
|
56
|
+
<!-- special formatting is defined in paragraph -->
|
57
|
+
<xsl:apply-templates/>
|
58
|
+
</xsl:template>
|
59
|
+
|
60
|
+
<xsl:template match="h:hr">
|
61
|
+
<text:p text:style-name="Horizontal_20_Line"/>
|
62
|
+
</xsl:template>
|
63
|
+
<xsl:template match="h:hr" mode="inparagraph"/>
|
64
|
+
|
65
|
+
<!--
|
66
|
+
Preformatted paragraphs management
|
67
|
+
-->
|
68
|
+
<xsl:template match="h:pre">
|
69
|
+
<text:p text:style-name="Preformatted_20_Text">
|
70
|
+
<xsl:apply-templates mode="inparagraph"/>
|
71
|
+
</text:p>
|
72
|
+
<!-- The Preformatted_20_Text style has a margin-bottom of 0, so we add an
|
73
|
+
empty line here -->
|
74
|
+
<text:p text:style-name="Text_20_body"/>
|
75
|
+
</xsl:template>
|
76
|
+
<xsl:template match="h:pre" mode="inparagraph"/>
|
77
|
+
|
78
|
+
<xsl:template match="h:pre//text()" mode="inparagraph">
|
79
|
+
<!-- Don't generate the last line break before the </pre> -->
|
80
|
+
<xsl:variable name="content">
|
81
|
+
<xsl:choose>
|
82
|
+
<xsl:when test="contains(., ' ')
|
83
|
+
and position() = last()
|
84
|
+
and substring(., string-length(.)) = ' '">
|
85
|
+
<xsl:value-of select="substring(., 1, string-length(.)-1)"/>
|
86
|
+
</xsl:when>
|
87
|
+
<xsl:otherwise>
|
88
|
+
<xsl:value-of select="."/>
|
89
|
+
</xsl:otherwise>
|
90
|
+
</xsl:choose>
|
91
|
+
</xsl:variable>
|
92
|
+
<!-- Now call the main template, which will handle the line-breaking -->
|
93
|
+
<xsl:call-template name="pre.line">
|
94
|
+
<xsl:with-param name="content" select="$content"/>
|
95
|
+
</xsl:call-template>
|
96
|
+
</xsl:template>
|
97
|
+
|
98
|
+
<!--
|
99
|
+
this template splits newline-separated pararagraphs into multiple
|
100
|
+
paragraphs
|
101
|
+
-->
|
102
|
+
<xsl:template name="pre.line">
|
103
|
+
<xsl:param name="content"/>
|
104
|
+
<xsl:choose>
|
105
|
+
<!-- This line-breaking manipulation is classical, e.g.:
|
106
|
+
http://skew.org/xml/stylesheets/linefeed2br/
|
107
|
+
-->
|
108
|
+
<xsl:when test="contains($content, ' ')">
|
109
|
+
<!-- split in two -->
|
110
|
+
<xsl:call-template name="pre.line">
|
111
|
+
<xsl:with-param name="content" select="substring-before($content, ' ')"/>
|
112
|
+
</xsl:call-template>
|
113
|
+
<text:line-break/>
|
114
|
+
<xsl:call-template name="pre.line">
|
115
|
+
<xsl:with-param name="content" select="substring-after($content, ' ')"/>
|
116
|
+
</xsl:call-template>
|
117
|
+
</xsl:when>
|
118
|
+
<xsl:otherwise>
|
119
|
+
<!-- here we're on a single line, call pre.line.single to preserve
|
120
|
+
spaces -->
|
121
|
+
<xsl:call-template name="pre.line.single">
|
122
|
+
<xsl:with-param name="content" select="string($content)"/>
|
123
|
+
</xsl:call-template>
|
124
|
+
</xsl:otherwise>
|
125
|
+
</xsl:choose>
|
126
|
+
</xsl:template>
|
127
|
+
|
128
|
+
<!-- This template escapes adjacent spaces -->
|
129
|
+
<xsl:template name="pre.line.single">
|
130
|
+
<xsl:param name="content"/>
|
131
|
+
<xsl:choose>
|
132
|
+
<xsl:when test="contains($content, ' ')">
|
133
|
+
<xsl:call-template name="pre.line.single">
|
134
|
+
<xsl:with-param name="content" select="substring-before($content, ' ')"/>
|
135
|
+
</xsl:call-template>
|
136
|
+
<text:s text:c="2"/>
|
137
|
+
<xsl:call-template name="pre.line.single">
|
138
|
+
<xsl:with-param name="content" select="substring-after($content, ' ')"/>
|
139
|
+
</xsl:call-template>
|
140
|
+
</xsl:when>
|
141
|
+
<xsl:when test="contains($content, '	')">
|
142
|
+
<xsl:call-template name="pre.line.single">
|
143
|
+
<xsl:with-param name="content" select="substring-before($content, '	')"/>
|
144
|
+
</xsl:call-template>
|
145
|
+
<text:tab/>
|
146
|
+
<xsl:call-template name="pre.line.single">
|
147
|
+
<xsl:with-param name="content" select="substring-after($content, '	')"/>
|
148
|
+
</xsl:call-template>
|
149
|
+
</xsl:when>
|
150
|
+
<xsl:otherwise>
|
151
|
+
<xsl:value-of select="string($content)"/>
|
152
|
+
</xsl:otherwise>
|
153
|
+
</xsl:choose>
|
154
|
+
</xsl:template>
|
155
|
+
|
156
|
+
|
157
|
+
<xsl:template match="h:address">
|
158
|
+
<!-- special formatting is defined in paragraph -->
|
159
|
+
<xsl:call-template name="paragraph"/>
|
160
|
+
</xsl:template>
|
161
|
+
<xsl:template match="h:address" mode="inparagraph"/>
|
162
|
+
|
163
|
+
<xsl:template match="h:center">
|
164
|
+
<!-- special formatting is defined in paragraph -->
|
165
|
+
<xsl:call-template name="paragraph"/>
|
166
|
+
</xsl:template>
|
167
|
+
<xsl:template match="h:center" mode="inparagraph"/>
|
168
|
+
|
169
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,122 @@
|
|
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:section">
|
55
|
+
<xsl:apply-templates/>
|
56
|
+
</xsl:template>
|
57
|
+
|
58
|
+
<xsl:template match="h:header">
|
59
|
+
<xsl:apply-templates/>
|
60
|
+
</xsl:template>
|
61
|
+
|
62
|
+
<xsl:template match="h:footer">
|
63
|
+
<xsl:apply-templates/>
|
64
|
+
</xsl:template>
|
65
|
+
|
66
|
+
<xsl:template match="h:summary">
|
67
|
+
<!-- TODO: Add space on the left and right of the text -->
|
68
|
+
<xsl:apply-templates/>
|
69
|
+
</xsl:template>
|
70
|
+
|
71
|
+
<xsl:template match="h:article">
|
72
|
+
<xsl:apply-templates/>
|
73
|
+
</xsl:template>
|
74
|
+
|
75
|
+
<xsl:template match="h:nav"/> <!-- only keep the content -->
|
76
|
+
|
77
|
+
<xsl:template match="h:aside">
|
78
|
+
<text:p text:style-name="Text_20_body">
|
79
|
+
<draw:frame draw:style-name="Marginalia"
|
80
|
+
text:anchor-type="paragraph"
|
81
|
+
svg:width="8.5cm" style:rel-width="50%">
|
82
|
+
<draw:text-box fo:min-height="0.5cm">
|
83
|
+
<xsl:apply-templates/>
|
84
|
+
</draw:text-box>
|
85
|
+
</draw:frame>
|
86
|
+
</text:p>
|
87
|
+
</xsl:template>
|
88
|
+
|
89
|
+
<xsl:template match="h:hgroup">
|
90
|
+
<xsl:apply-templates/>
|
91
|
+
</xsl:template>
|
92
|
+
|
93
|
+
<xsl:template match="h:time" mode="inparagraph">
|
94
|
+
<xsl:apply-templates mode="inparagraph"/>
|
95
|
+
</xsl:template>
|
96
|
+
<xsl:template match="h:time"/>
|
97
|
+
|
98
|
+
<xsl:template match="h:mark" mode="inparagraph">
|
99
|
+
<!-- TODO: make the text background color yellow -->
|
100
|
+
<xsl:apply-templates mode="inparagraph"/>
|
101
|
+
</xsl:template>
|
102
|
+
|
103
|
+
<xsl:template match="h:canvas"/>
|
104
|
+
|
105
|
+
<!-- TODO: include the source ? -->
|
106
|
+
<xsl:template match="h:audio"/>
|
107
|
+
<xsl:template match="h:video"/>
|
108
|
+
<xsl:template match="h:source"/>
|
109
|
+
|
110
|
+
<!-- form elements -->
|
111
|
+
<xsl:template match="h:command|h:datalist|h:details|h:meter|h:output|h:progress|h:keygen"/>
|
112
|
+
|
113
|
+
<!-- TODO: make a frame around it -->
|
114
|
+
<xsl:template match="h:figure"/>
|
115
|
+
<xsl:template match="h:figcaption"/>
|
116
|
+
|
117
|
+
<xsl:template match="h:ruby|h:rt|h:rp" mode="inparagraph">
|
118
|
+
<xsl:apply-templates mode="inparagraph"/>
|
119
|
+
</xsl:template>
|
120
|
+
<xsl:template match="h:ruby|h:rt|h:rp"/>
|
121
|
+
|
122
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,93 @@
|
|
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
|
+
<xsl:template match="h:div">
|
54
|
+
<xsl:apply-templates/>
|
55
|
+
</xsl:template>
|
56
|
+
<xsl:template match="h:div" mode="inparagraph">
|
57
|
+
<xsl:apply-templates mode="inparagraph"/>
|
58
|
+
</xsl:template>
|
59
|
+
|
60
|
+
<xsl:template match="h:html">
|
61
|
+
<xsl:apply-templates/>
|
62
|
+
</xsl:template>
|
63
|
+
|
64
|
+
<xsl:template match="h:head"/>
|
65
|
+
|
66
|
+
<xsl:template match="h:body">
|
67
|
+
<xsl:apply-templates/>
|
68
|
+
</xsl:template>
|
69
|
+
|
70
|
+
<xsl:template match="h:span"/>
|
71
|
+
<xsl:template match="h:span" mode="inparagraph">
|
72
|
+
<xsl:choose>
|
73
|
+
<xsl:when test="translate(@style,' ','') != ''">
|
74
|
+
<!-- leave the style handling to xsl/styles.xsl -->
|
75
|
+
<xsl:copy>
|
76
|
+
<xsl:copy-of select="@*"/>
|
77
|
+
<xsl:apply-templates mode="inparagraph"/>
|
78
|
+
</xsl:copy>
|
79
|
+
</xsl:when>
|
80
|
+
<xsl:otherwise>
|
81
|
+
<xsl:apply-templates mode="inparagraph"/>
|
82
|
+
</xsl:otherwise>
|
83
|
+
</xsl:choose>
|
84
|
+
</xsl:template>
|
85
|
+
|
86
|
+
<xsl:template match="h:script"/>
|
87
|
+
<xsl:template match="h:noscript"/>
|
88
|
+
|
89
|
+
<xsl:template match="h:object"/>
|
90
|
+
|
91
|
+
<xsl:template match="h:form"/>
|
92
|
+
|
93
|
+
</xsl:stylesheet>
|