htmltoword 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4caa8437b60de362de112d27ca2d3bd127e018b9
4
- data.tar.gz: bff1647e7f309e5195e74aeee693e76de6587102
3
+ metadata.gz: 3e11d37752ec6cbe7fe7e2efb735a86e9a070767
4
+ data.tar.gz: 3a56eb81b62cc9a2c6e3bf589b53d2362ee30627
5
5
  SHA512:
6
- metadata.gz: 5cffd3d1832113c2227e06098188baa5b22c9514de05c77b7d18c4f2a58ce52937efe4f5144c04eb1fbeaec716fca1300a96874a429646060d78179b2b97b2a0
7
- data.tar.gz: c5ac4f35a6e7a032f57df40bf4e1b4ea7e3fdfa7de8543179a0ca10d6323819e2c3163af8518bf3f5fcde567a4d7e282f5e5a1550a75b2f59f0afbfce2f9b8d1
6
+ metadata.gz: a804913b7fa5611a226149d615f26ad54d85c0bf15813c9dae3f4e8e5d6008617866befa9818d0e26d327d5f3879ff77ed54dca9eff6ce0d0ed23fb9bdfb1803
7
+ data.tar.gz: a29c50d03ae0132a382166f5cb77812dbaaaf1e70e00b70830aa084fbc92b76d9a1b964e182bbb756dc55028cb9f27a103964585919fa312836bb8349d048433
@@ -1,3 +1,3 @@
1
1
  module Htmltoword
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -0,0 +1,340 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
3
+ xmlns:o="urn:schemas-microsoft-com:office:office"
4
+ xmlns:v="urn:schemas-microsoft-com:vml"
5
+ xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
6
+ xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
7
+ xmlns:w10="urn:schemas-microsoft-com:office:word"
8
+ xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
9
+ xmlns:msxsl="urn:schemas-microsoft-com:xslt"
10
+ xmlns:ext="http://www.xmllab.net/wordml2html/ext"
11
+ xmlns:java="http://xml.apache.org/xalan/java"
12
+ xmlns:str="http://exslt.org/strings"
13
+ xmlns:func="http://exslt.org/functions"
14
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
15
+ version="1.0"
16
+ exclude-result-prefixes="java msxsl ext w o v WX aml w10"
17
+ extension-element-prefixes="func">
18
+ <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes" />
19
+
20
+ <xsl:template match="/">
21
+ <xsl:apply-templates />
22
+ </xsl:template>
23
+
24
+ <xsl:template match="head" />
25
+
26
+ <xsl:template match="body">
27
+ <xsl:comment>
28
+ KNOWN BUGS:
29
+ div
30
+ h2
31
+ div
32
+ textnode (WONT BE WRAPPED IN A W:P)
33
+ div
34
+ table
35
+ span
36
+ text
37
+ </xsl:comment>
38
+ <xsl:apply-templates/>
39
+ </xsl:template>
40
+
41
+ <xsl:template match="body/*[not(*)]">
42
+ <w:p>
43
+ <xsl:call-template name="text-alignment" />
44
+ <w:r>
45
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
46
+ </w:r>
47
+ </w:p>
48
+ </xsl:template>
49
+
50
+ <xsl:template match="div[not(ancestor::td) and not(ancestor::th) and not(ancestor::p) and not(descendant::div) and not(descendant::p) and not(descendant::h1) and not(descendant::h2) and not(descendant::h3) and not(descendant::h4) and not(descendant::h5) and not(descendant::h6) and not(descendant::table) and not(descendant::li)]">
51
+ <xsl:comment>Divs should create a p if nothing above them has and nothing below them will</xsl:comment>
52
+ <w:p>
53
+ <xsl:call-template name="text-alignment" />
54
+ <xsl:apply-templates />
55
+ </w:p>
56
+ </xsl:template>
57
+
58
+ <xsl:template match="div">
59
+ <xsl:apply-templates />
60
+ </xsl:template>
61
+
62
+ <!-- TODO: make this prettier. Headings shouldn't enter in template from L51 -->
63
+ <xsl:template match="body/h1|body/h2|body/h3|body/h4|body/h5|body/h6|h1|h2|h3|h4|h5|h6">
64
+ <xsl:variable name="length" select="string-length(name(.))"/>
65
+ <w:p>
66
+ <w:pPr>
67
+ <w:pStyle w:val="Heading{substring(name(.),$length)}"/>
68
+ </w:pPr>
69
+ <w:r>
70
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
71
+ </w:r>
72
+ </w:p>
73
+ </xsl:template>
74
+
75
+ <xsl:template match="p">
76
+ <w:p>
77
+ <xsl:call-template name="text-alignment" />
78
+ <xsl:apply-templates />
79
+ </w:p>
80
+ </xsl:template>
81
+
82
+ <xsl:template match="li">
83
+ <w:p>
84
+ <w:r>
85
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
86
+ </w:r>
87
+ </w:p>
88
+ </xsl:template>
89
+
90
+ <xsl:template match="span[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
91
+ |a[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
92
+ |small[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
93
+ |strong[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
94
+ |em[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
95
+ |i[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
96
+ |b[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]
97
+ |u[not(ancestor::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]">
98
+ <xsl:comment>
99
+ In the following situation:
100
+
101
+ div
102
+ h2
103
+ span
104
+ textnode
105
+ span
106
+ textnode
107
+ p
108
+
109
+ The div template will not create a w:p because the div contains a h2. Therefore we need to wrap the inline elements span|a|small in a p here.
110
+ </xsl:comment>
111
+ <w:p>
112
+ <xsl:apply-templates />
113
+ </w:p>
114
+ </xsl:template>
115
+
116
+ <xsl:template match="text()[not(parent::td) and (preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div)]">
117
+ <xsl:comment>
118
+ In the following situation:
119
+
120
+ div
121
+ h2
122
+ textnode
123
+ p
124
+
125
+ The div template will not create a w:p because the div contains a h2. Therefore we need to wrap the textnode in a p here.
126
+ </xsl:comment>
127
+ <w:p>
128
+ <w:r>
129
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
130
+ </w:r>
131
+ </w:p>
132
+ </xsl:template>
133
+
134
+ <xsl:template match="span[contains(concat(' ', @class, ' '), ' h ')]">
135
+ <xsl:comment>
136
+ This template adds MS Word highlighting ability.
137
+ </xsl:comment>
138
+ <xsl:variable name="color">
139
+ <xsl:choose>
140
+ <xsl:when test="./@data-style='pink'">magenta</xsl:when>
141
+ <xsl:when test="./@data-style='blue'">cyan</xsl:when>
142
+ <xsl:when test="./@data-style='orange'">darkYellow</xsl:when>
143
+ <xsl:otherwise><xsl:value-of select="./@data-style"/></xsl:otherwise>
144
+ </xsl:choose>
145
+ </xsl:variable>
146
+ <xsl:choose>
147
+ <xsl:when test="preceding-sibling::h1 or preceding-sibling::h2 or preceding-sibling::h3 or preceding-sibling::h4 or preceding-sibling::h5 or preceding-sibling::h6 or preceding-sibling::table or preceding-sibling::p or preceding-sibling::ol or preceding-sibling::ul or preceding-sibling::div or following-sibling::h1 or following-sibling::h2 or following-sibling::h3 or following-sibling::h4 or following-sibling::h5 or following-sibling::h6 or following-sibling::table or following-sibling::p or following-sibling::ol or following-sibling::ul or following-sibling::div">
148
+ <w:p>
149
+ <w:r>
150
+ <w:rPr>
151
+ <w:highlight w:val="{$color}"/>
152
+ </w:rPr>
153
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
154
+ </w:r>
155
+ </w:p>
156
+ </xsl:when>
157
+ <xsl:otherwise>
158
+ <w:r>
159
+ <w:rPr>
160
+ <w:highlight w:val="{$color}"/>
161
+ </w:rPr>
162
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
163
+ </w:r>
164
+ </xsl:otherwise>
165
+ </xsl:choose>
166
+ </xsl:template>
167
+
168
+ <xsl:template match="div[contains(concat(' ', @class, ' '), ' -page-break ')]">
169
+ <w:p>
170
+ <w:r>
171
+ <w:br w:type="page" />
172
+ </w:r>
173
+ </w:p>
174
+ <xsl:apply-templates />
175
+ </xsl:template>
176
+
177
+ <xsl:template match="details" />
178
+
179
+ <xsl:template name="tableborders">
180
+ <xsl:variable name="border">
181
+ <xsl:choose>
182
+ <xsl:when test="contains(concat(' ', @class, ' '), ' table-bordered ')">6</xsl:when>
183
+ <xsl:when test="not(@border)">0</xsl:when>
184
+ <xsl:otherwise><xsl:value-of select="./@border * 6"/></xsl:otherwise>
185
+ </xsl:choose>
186
+ </xsl:variable>
187
+ <xsl:variable name="bordertype">
188
+ <xsl:choose>
189
+ <xsl:when test="$border=0">none</xsl:when>
190
+ <xsl:otherwise>single</xsl:otherwise>
191
+ </xsl:choose>
192
+ </xsl:variable>
193
+ <w:tblBorders>
194
+ <w:top w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
195
+ <w:left w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
196
+ <w:bottom w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
197
+ <w:right w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
198
+ <w:insideH w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
199
+ <w:insideV w:val="{$bordertype}" w:sz="{$border}" w:space="0" w:color="auto"/>
200
+ </w:tblBorders>
201
+ </xsl:template>
202
+
203
+ <xsl:template match="table">
204
+ <w:tbl>
205
+ <w:tblPr>
206
+ <w:tblStyle w:val="TableGrid"/>
207
+ <xsl:call-template name="tableborders"/>
208
+ <w:tblLook w:val="0600" w:firstRow="0" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:noHBand="1" w:noVBand="1"/>
209
+ </w:tblPr>
210
+ <xsl:apply-templates />
211
+ </w:tbl>
212
+ </xsl:template>
213
+
214
+ <xsl:template match="tbody">
215
+ <xsl:apply-templates />
216
+ </xsl:template>
217
+
218
+ <xsl:template match="thead">
219
+ <xsl:choose>
220
+ <xsl:when test="count(./tr) = 0">
221
+ <w:tr><xsl:apply-templates /></w:tr>
222
+ </xsl:when>
223
+ <xsl:otherwise>
224
+ <xsl:apply-templates />
225
+ </xsl:otherwise>
226
+ </xsl:choose>
227
+ </xsl:template>
228
+
229
+ <xsl:template match="tr">
230
+ <xsl:if test="string-length(.) > 0">
231
+ <w:tr>
232
+ <xsl:apply-templates />
233
+ </w:tr>
234
+ </xsl:if>
235
+ </xsl:template>
236
+
237
+ <xsl:template match="th">
238
+ <w:tc>
239
+ <w:p>
240
+ <w:r>
241
+ <w:rPr>
242
+ <w:b />
243
+ </w:rPr>
244
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
245
+ </w:r>
246
+ </w:p>
247
+ </w:tc>
248
+ </xsl:template>
249
+
250
+ <xsl:template match="td">
251
+ <w:tc>
252
+ <xsl:call-template name="block">
253
+ <xsl:with-param name="current" select="." />
254
+ <xsl:with-param name="class" select="@class" />
255
+ <xsl:with-param name="style" select="@style" />
256
+ </xsl:call-template>
257
+ </w:tc>
258
+ </xsl:template>
259
+
260
+ <xsl:template name="block">
261
+ <xsl:param name="current" />
262
+ <xsl:param name="class" />
263
+ <xsl:param name="style" />
264
+ <xsl:if test="count($current/*|$current/text()) = 0">
265
+ <w:p/>
266
+ </xsl:if>
267
+ <xsl:for-each select="$current/*|$current/text()">
268
+ <xsl:choose>
269
+ <xsl:when test="name(.) = 'table'">
270
+ <xsl:apply-templates select="." />
271
+ <w:p/>
272
+ </xsl:when>
273
+ <xsl:when test="contains('|p|h1|h2|h3|h4|h5|h6|ul|ol|', concat('|', name(.), '|'))">
274
+ <xsl:apply-templates select="." />
275
+ </xsl:when>
276
+ <xsl:when test="descendant::table|descendant::p|descendant::h1|descendant::h2|descendant::h3|descendant::h4|descendant::h5|descendant::h6|descendant::li">
277
+ <xsl:call-template name="block">
278
+ <xsl:with-param name="current" select="."/>
279
+ </xsl:call-template>
280
+ </xsl:when>
281
+ <xsl:otherwise>
282
+ <w:p>
283
+ <xsl:call-template name="text-alignment">
284
+ <xsl:with-param name="class" select="$class" />
285
+ <xsl:with-param name="style" select="$style" />
286
+ </xsl:call-template>
287
+ <xsl:apply-templates select="." />
288
+ </w:p>
289
+ </xsl:otherwise>
290
+ </xsl:choose>
291
+ </xsl:for-each>
292
+ </xsl:template>
293
+
294
+ <xsl:template match="text()">
295
+ <xsl:if test="string-length(.) > 0">
296
+ <w:r>
297
+ <xsl:if test="ancestor::i or ancestor::em">
298
+ <w:rPr>
299
+ <w:i />
300
+ </w:rPr>
301
+ </xsl:if>
302
+ <xsl:if test="ancestor::b or ancestor::strong">
303
+ <w:rPr>
304
+ <w:b />
305
+ </w:rPr>
306
+ </xsl:if>
307
+ <xsl:if test="ancestor::u">
308
+ <w:rPr>
309
+ <w:u w:val="single"/>
310
+ </w:rPr>
311
+ </xsl:if>
312
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
313
+ </w:r>
314
+ </xsl:if>
315
+ </xsl:template>
316
+
317
+ <xsl:template match="*">
318
+ <xsl:apply-templates/>
319
+ </xsl:template>
320
+
321
+ <xsl:template name="text-alignment">
322
+ <xsl:param name="class" select="@class" />
323
+ <xsl:param name="style" select="@style" />
324
+ <xsl:variable name="alignment">
325
+ <xsl:choose>
326
+ <xsl:when test="contains(concat(' ', $class, ' '), ' center ') or contains(translate(normalize-space($style),' ',''), 'text-align:center')">center</xsl:when>
327
+ <xsl:when test="contains(concat(' ', $class, ' '), ' right ') or contains(translate(normalize-space($style),' ',''), 'text-align:right')">right</xsl:when>
328
+ <xsl:when test="contains(concat(' ', $class, ' '), ' left ') or contains(translate(normalize-space($style),' ',''), 'text-align:left')">left</xsl:when>
329
+ <xsl:when test="contains(concat(' ', $class, ' '), ' justify ') or contains(translate(normalize-space($style),' ',''), 'text-align:justify')">both</xsl:when>
330
+ <xsl:otherwise></xsl:otherwise>
331
+ </xsl:choose>
332
+ </xsl:variable>
333
+ <xsl:if test="string-length(normalize-space($alignment)) > 0">
334
+ <w:pPr>
335
+ <w:jc w:val="{$alignment}"/>
336
+ </w:pPr>
337
+ </xsl:if>
338
+ </xsl:template>
339
+
340
+ </xsl:stylesheet>
@@ -0,0 +1,149 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
3
+ xmlns:o="urn:schemas-microsoft-com:office:office"
4
+ xmlns:v="urn:schemas-microsoft-com:vml"
5
+ xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
6
+ xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
7
+ xmlns:w10="urn:schemas-microsoft-com:office:word"
8
+ xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
9
+ xmlns:msxsl="urn:schemas-microsoft-com:xslt"
10
+ xmlns:ext="http://www.xmllab.net/wordml2html/ext"
11
+ xmlns:java="http://xml.apache.org/xalan/java"
12
+ xmlns:str="http://exslt.org/strings"
13
+ xmlns:func="http://exslt.org/functions"
14
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
15
+ version="1.0"
16
+ exclude-result-prefixes="java msxsl ext w o v WX aml w10"
17
+ extension-element-prefixes="func">
18
+
19
+ <!-- support function to return substring-before or everything -->
20
+ <func:function name="func:substring-before-if-contains">
21
+ <xsl:param name="arg"/>
22
+ <xsl:param name="delim"/>
23
+ <func:result>
24
+ <xsl:choose>
25
+ <xsl:when test="contains($arg, $delim)">
26
+ <xsl:value-of select="substring-before($arg, $delim)"/>
27
+ </xsl:when>
28
+ <xsl:otherwise>
29
+ <xsl:value-of select="$arg"/>
30
+ </xsl:otherwise>
31
+ </xsl:choose>
32
+ </func:result>
33
+ </func:function>
34
+
35
+ <!-- Full width tables per default -->
36
+ <xsl:template match="table">
37
+ <w:tbl>
38
+ <w:tblPr>
39
+ <w:tblStyle w:val="TableGrid"/>
40
+ <w:tblW w:w="5000" w:type="pct"/>
41
+ <xsl:call-template name="tableborders"/>
42
+ <w:tblLook w:val="0600" w:firstRow="0" w:lastRow="0" w:firstColumn="0" w:lastColumn="0" w:noHBand="1" w:noVBand="1"/>
43
+ </w:tblPr>
44
+ <xsl:apply-templates />
45
+ </w:tbl>
46
+ </xsl:template>
47
+
48
+ <!-- Advanced cell transformation -->
49
+ <xsl:template match="td|th">
50
+ <w:tc>
51
+ <w:tcPr>
52
+ <xsl:if test="contains(@class, 'ms-border-')">
53
+ <w:tcBorders>
54
+ <xsl:for-each select="str:tokenize(@class, ' ')">
55
+ <xsl:call-template name="define-border">
56
+ <xsl:with-param name="class" select="." />
57
+ </xsl:call-template>
58
+ </xsl:for-each>
59
+ </w:tcBorders>
60
+ </xsl:if>
61
+ <xsl:if test="contains(@class, 'ms-fill-')">
62
+ <xsl:variable name="cell-bg" select="str:tokenize(substring-after(@class, 'ms-fill-'), ' ')[1]"/>
63
+ <w:shd w:val="clear" w:color="auto" w:fill="{$cell-bg}" />
64
+ </xsl:if>
65
+ </w:tcPr>
66
+ <xsl:call-template name="block">
67
+ <xsl:with-param name="current" select="." />
68
+ <xsl:with-param name="class" select="@class" />
69
+ <xsl:with-param name="style" select="@style" />
70
+ </xsl:call-template>
71
+ </w:tc>
72
+ </xsl:template>
73
+
74
+ <!-- use block quotes for spacing (can be nested) -->
75
+ <xsl:template match="blockquote">
76
+ <w:p>
77
+ <w:pPr>
78
+ <w:spacing w:afterLines="200" />
79
+ </w:pPr>
80
+ </w:p>
81
+ <xsl:apply-templates/>
82
+ </xsl:template>
83
+
84
+ <xsl:template match="ol/li">
85
+ <w:p>
86
+ <w:pPr>
87
+ <w:pStyle w:val="ListParagraph"/>
88
+ <w:numPr>
89
+ <w:ilvl w:val="0"/>
90
+ <w:numId w:val="1"/>
91
+ </w:numPr>
92
+ </w:pPr>
93
+ <w:r>
94
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
95
+ </w:r>
96
+ </w:p>
97
+ </xsl:template>
98
+
99
+ <xsl:template match="ul/li">
100
+ <w:p>
101
+ <w:pPr>
102
+ <w:pStyle w:val="ListParagraph"/>
103
+ <w:numPr>
104
+ <w:ilvl w:val="0"/>
105
+ <w:numId w:val="10"/>
106
+ </w:numPr>
107
+ </w:pPr>
108
+ <w:r>
109
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
110
+ </w:r>
111
+ </w:p>
112
+ </xsl:template>
113
+
114
+ <xsl:template match="ol">
115
+ <xsl:apply-templates />
116
+ </xsl:template>
117
+
118
+ <xsl:template match="ul">
119
+ <xsl:apply-templates />
120
+ </xsl:template>
121
+
122
+ <xsl:template name="define-border">
123
+ <xsl:param name="class" />
124
+ <xsl:if test="contains($class, 'ms-border-')">
125
+ <xsl:variable name="border" select="substring-after($class, 'ms-border-')"/>
126
+ <xsl:variable name="border-properties" select="str:tokenize($border, '-')"/>
127
+ <xsl:variable name="border-location" select="$border-properties[1]" />
128
+ <xsl:variable name="border-value" select="$border-properties[2]" />
129
+ <xsl:variable name="border-color">
130
+ <xsl:choose>
131
+ <xsl:when test="string-length($border-properties[3]) > 0"><xsl:value-of select="$border-properties[3]"/></xsl:when>
132
+ <xsl:otherwise>000000</xsl:otherwise>
133
+ </xsl:choose>
134
+ </xsl:variable>
135
+ <xsl:variable name="border-size">
136
+ <xsl:choose>
137
+ <xsl:when test="string-length($border-properties[4]) > 0"><xsl:value-of select="$border-properties[4] * 6"/></xsl:when>
138
+ <xsl:otherwise>6</xsl:otherwise>
139
+ </xsl:choose>
140
+ </xsl:variable>
141
+ <xsl:element name="w:{$border-location}">
142
+ <xsl:attribute name="w:val"><xsl:value-of select="$border-value" /></xsl:attribute>
143
+ <xsl:attribute name="w:sz"><xsl:value-of select="$border-size" /></xsl:attribute>
144
+ <xsl:attribute name="w:space">0</xsl:attribute>
145
+ <xsl:attribute name="w:color"><xsl:value-of select="$border-color" /></xsl:attribute>
146
+ </xsl:element>
147
+ </xsl:if>
148
+ </xsl:template>
149
+ </xsl:stylesheet>
@@ -0,0 +1,20 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
3
+ xmlns:o="urn:schemas-microsoft-com:office:office"
4
+ xmlns:v="urn:schemas-microsoft-com:vml"
5
+ xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
6
+ xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
7
+ xmlns:w10="urn:schemas-microsoft-com:office:word"
8
+ xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
9
+ xmlns:msxsl="urn:schemas-microsoft-com:xslt"
10
+ xmlns:ext="http://www.xmllab.net/wordml2html/ext"
11
+ xmlns:java="http://xml.apache.org/xalan/java"
12
+ xmlns:str="http://exslt.org/strings"
13
+ xmlns:func="http://exslt.org/functions"
14
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
15
+ version="1.0"
16
+ exclude-result-prefixes="java msxsl ext w o v WX aml w10"
17
+ extension-element-prefixes="func">
18
+ <xsl:import href="./base.xslt"/>
19
+ <xsl:import href="./extras.xslt"/>
20
+ </xsl:stylesheet>
@@ -0,0 +1,49 @@
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2
+ xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
3
+ xmlns:o="urn:schemas-microsoft-com:office:office"
4
+ xmlns:v="urn:schemas-microsoft-com:vml"
5
+ xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
6
+ xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
7
+ xmlns:w10="urn:schemas-microsoft-com:office:word"
8
+ xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"
9
+ xmlns:msxsl="urn:schemas-microsoft-com:xslt"
10
+ xmlns:ext="http://www.xmllab.net/wordml2html/ext"
11
+ xmlns:java="http://xml.apache.org/xalan/java"
12
+ xmlns:str="http://exslt.org/common"
13
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
14
+ version="1.0"
15
+ exclude-result-prefixes="java msxsl ext w o v WX aml w10">
16
+
17
+
18
+ <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes" />
19
+
20
+ <xsl:template match="/ | html">
21
+ <w:document xmlns:wpc="http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas" xmlns:mo="http://schemas.microsoft.com/office/mac/office/2008/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="urn:schemas-microsoft-com:mac:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:wpi="http://schemas.microsoft.com/office/word/2010/wordprocessingInk" xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" mc:Ignorable="w14 wp14">
22
+ <xsl:apply-templates select="//body"/>
23
+ </w:document>
24
+ </xsl:template>
25
+
26
+ <xsl:template match="body">
27
+ <w:body>
28
+ <w:p>
29
+ <xsl:apply-templates/>
30
+ </w:p>
31
+ <w:sectPr>
32
+ <w:pgSz w:w="11906" w:h="16838"/>
33
+ <w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440" w:header="708" w:footer="708" w:gutter="0"/>
34
+ <w:cols w:space="708"/>
35
+ <w:docGrid w:linePitch="360"/>
36
+ </w:sectPr>
37
+ </w:body>
38
+ </xsl:template>
39
+
40
+ <xsl:template match="h1|h2|h3|li|span">
41
+ <w:br/>
42
+ <w:r>
43
+ <xsl:comment>Im block</xsl:comment>
44
+ <w:t xml:space="preserve"><xsl:value-of select="."/></w:t>
45
+ </w:r>
46
+ <w:br/>
47
+ </xsl:template>
48
+
49
+ </xsl:stylesheet>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmltoword
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Frandsen, Cristina Matonte
@@ -136,7 +136,13 @@ files:
136
136
  - lib/htmltoword/configuration.rb
137
137
  - lib/htmltoword/document.rb
138
138
  - lib/htmltoword/htmltoword_helper.rb
139
+ - lib/htmltoword/templates/default.docx
140
+ - lib/htmltoword/templates/default_old.docx
139
141
  - lib/htmltoword/version.rb
142
+ - lib/htmltoword/xslt/base.xslt
143
+ - lib/htmltoword/xslt/extras.xslt
144
+ - lib/htmltoword/xslt/htmltoword.xslt
145
+ - lib/htmltoword/xslt/style2.xslt
140
146
  homepage: http://github.com/karnov/htmltoword
141
147
  licenses:
142
148
  - MIT