html2odt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/xsl/styles.xsl ADDED
@@ -0,0 +1,143 @@
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
+ exclude-result-prefixes="office xsl dc text style table draw fo xlink meta number svg chart dr3d math form script dom xforms xsd xsi presentation h"
52
+ version="1.0">
53
+
54
+ <!-- SETTINGS -->
55
+ <xsl:decimal-format name="staff" digit="D" />
56
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="utf-8"/>
57
+ <!--<xsl:strip-space elements="*"/>-->
58
+ <!--<xsl:preserve-space elements=""/>-->
59
+
60
+
61
+ <xsl:include href="param.xsl"/>
62
+ <xsl:include href="styles/automatic-styles.xsl"/>
63
+ <xsl:include href="styles/main-styles.xsl"/>
64
+ <xsl:include href="styles/fonts.xsl"/>
65
+ <xsl:include href="styles/highlight.xsl"/>
66
+ <xsl:include href="styles/inline.xsl"/>
67
+
68
+
69
+ <xsl:template match="/">
70
+ <xsl:apply-templates/>
71
+ </xsl:template>
72
+
73
+
74
+ <!-- process automatic styles -->
75
+ <xsl:template match="office:automatic-styles">
76
+ <office:automatic-styles>
77
+ <!-- copy the existing styles -->
78
+ <xsl:for-each select="child::*">
79
+ <xsl:copy>
80
+ <xsl:copy-of select="@*"/>
81
+ <xsl:apply-templates/>
82
+ </xsl:copy>
83
+ </xsl:for-each>
84
+ <!-- add missing styles -->
85
+ <xsl:call-template name="autostyles"/>
86
+ <!-- add missing syntax highlighting styles -->
87
+ <xsl:call-template name="highlight"/>
88
+ <!-- add missing inline styles -->
89
+ <xsl:call-template name="inline"/>
90
+ </office:automatic-styles>
91
+ </xsl:template>
92
+
93
+ <!-- process main styles -->
94
+ <xsl:template match="office:styles">
95
+ <office:styles>
96
+ <!-- copy the existing styles -->
97
+ <xsl:for-each select="child::*">
98
+ <xsl:copy>
99
+ <xsl:copy-of select="@*"/>
100
+ <xsl:apply-templates/>
101
+ </xsl:copy>
102
+ </xsl:for-each>
103
+ <!-- add missing styles -->
104
+ <xsl:call-template name="mainstyles"/>
105
+ </office:styles>
106
+ </xsl:template>
107
+
108
+ <!-- process font declarations -->
109
+ <xsl:template match="office:font-face-decls">
110
+ <office:font-face-decls>
111
+ <!-- copy the existing fonts -->
112
+ <xsl:for-each select="child::*">
113
+ <xsl:copy>
114
+ <xsl:copy-of select="@*"/>
115
+ <xsl:apply-templates/>
116
+ </xsl:copy>
117
+ </xsl:for-each>
118
+ <!-- add missing fonts -->
119
+ <xsl:call-template name="fonts"/>
120
+ </office:font-face-decls>
121
+ </xsl:template>
122
+
123
+ <!-- Convert the <span> tags which have inline CSS properties in the style
124
+ attribute. See the styles/inline.xsl stylesheet for details -->
125
+ <xsl:template match="h:span[@style]">
126
+ <text:span>
127
+ <xsl:attribute name="text:style-name">
128
+ <xsl:text>inline-style.</xsl:text>
129
+ <xsl:value-of select="generate-id(.)"/>
130
+ </xsl:attribute>
131
+ <xsl:apply-templates/>
132
+ </text:span>
133
+ </xsl:template>
134
+
135
+ <!-- Leave alone unknown tags -->
136
+ <xsl:template match="*">
137
+ <xsl:copy>
138
+ <xsl:copy-of select="@*"/>
139
+ <xsl:apply-templates/>
140
+ </xsl:copy>
141
+ </xsl:template>
142
+
143
+ </xsl:stylesheet>
data/xsl/xhtml2odt.xsl ADDED
@@ -0,0 +1,116 @@
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
+ exclude-result-prefixes="office xsl dc text style table draw fo xlink meta number svg chart dr3d math form script dom xforms xsd xsi presentation h"
52
+ version="1.0">
53
+
54
+ <!-- SETTINGS -->
55
+ <xsl:decimal-format name="staff" digit="D" />
56
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="utf-8"/>
57
+ <!--<xsl:strip-space elements="*"/>-->
58
+ <!--<xsl:preserve-space elements=""/>-->
59
+
60
+
61
+ <xsl:include href="param.xsl"/>
62
+ <xsl:include href="document-content.xsl"/>
63
+ <xsl:include href="specific.xsl"/>
64
+
65
+
66
+ <xsl:template match="/">
67
+ <xsl:apply-templates/>
68
+ </xsl:template>
69
+
70
+ <!-- ignore ODT paragraph inside ODT paragraphs -->
71
+ <xsl:template match="text:p">
72
+ <xsl:choose>
73
+ <xsl:when test="
74
+ descendant::h:p|
75
+ child::h:h1|
76
+ child::h:h2|
77
+ child::h:h3|
78
+ child::h:h4|
79
+ child::h:h5|
80
+ child::h:h6
81
+ ">
82
+ <!-- continue without text:p creation to child element -->
83
+
84
+ <!-- when in this block is some text, display it in paragraph -->
85
+ <!-- this is not functional
86
+ <text:p>
87
+ <xsl:value-of select="string(.)"/>
88
+ </text:p>
89
+ -->
90
+ <!-- call template for each found element -->
91
+ <xsl:for-each select="*">
92
+ <xsl:apply-templates select="."/>
93
+ </xsl:for-each>
94
+ </xsl:when>
95
+ <xsl:otherwise>
96
+ <xsl:copy>
97
+ <xsl:copy-of select="@*"/>
98
+ <xsl:apply-templates/>
99
+ </xsl:copy>
100
+ </xsl:otherwise>
101
+ </xsl:choose>
102
+ </xsl:template>
103
+
104
+ <!-- Leave alone unknown tags -->
105
+ <xsl:template match="*">
106
+ <xsl:if test="$debug">
107
+ <xsl:comment>Unknown tag : <xsl:value-of select="name(.)"/><xsl:value-of select="."/></xsl:comment>
108
+ </xsl:if>
109
+ <xsl:copy>
110
+ <xsl:copy-of select="@*"/>
111
+ <xsl:apply-templates/>
112
+ </xsl:copy>
113
+ </xsl:template>
114
+
115
+
116
+ </xsl:stylesheet>
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html2odt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gregor Schmidt (Planio)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dimensions
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: nokogiri
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.7.2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.7.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubyzip
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.2.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '5.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '5.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: html2odt generates ODT documents based on HTML fragments using xhtml2odt
112
+ email:
113
+ - gregor@plan.io
114
+ - support@plan.io
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - CHANGELOG.md
121
+ - CODE_OF_CONDUCT.md
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - html2odt.gemspec
129
+ - lib/html2odt.rb
130
+ - lib/html2odt/document.rb
131
+ - lib/html2odt/image.rb
132
+ - lib/html2odt/version.rb
133
+ - odt/template.odt
134
+ - xsl/LICENSE.txt
135
+ - xsl/README.rst
136
+ - xsl/document-content.xsl
137
+ - xsl/document-content/block.xsl
138
+ - xsl/document-content/html5.xsl
139
+ - xsl/document-content/ignore.xsl
140
+ - xsl/document-content/inline.xsl
141
+ - xsl/document-content/link.xsl
142
+ - xsl/document-content/lists.xsl
143
+ - xsl/document-content/media.xsl
144
+ - xsl/document-content/paragraph.xsl
145
+ - xsl/document-content/section.xsl
146
+ - xsl/document-content/tables.xsl
147
+ - xsl/param.xsl
148
+ - xsl/specific.xsl
149
+ - xsl/specific/elyxer.xsl
150
+ - xsl/specific/geshi.xsl
151
+ - xsl/specific/lyx.xsl
152
+ - xsl/specific/pygments.xsl
153
+ - xsl/specific/trac.xsl
154
+ - xsl/styles.xsl
155
+ - xsl/styles/automatic-styles.xsl
156
+ - xsl/styles/fonts.xsl
157
+ - xsl/styles/highlight.xsl
158
+ - xsl/styles/inline.xsl
159
+ - xsl/styles/main-styles.xsl
160
+ - xsl/xhtml2odt.xsl
161
+ homepage: https://github.com/planio-gmbh/html2odt
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.4.8
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: html2odt generates ODT documents based on HTML fragments
185
+ test_files: []