html2doc 0.8.14 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/html2doc.gemspec +1 -1
- data/lib/html2doc/base.rb +4 -0
- data/lib/html2doc/math.rb +10 -1
- data/lib/html2doc/version.rb +1 -1
- data/spec/html2doc_spec.rb +16 -78
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 736a1b4a315563665d82191a2a21a63f1db634b9e847a145607cd8f0aa93d794
|
4
|
+
data.tar.gz: 317869cf8d2ae0a7c4d7fee710bc29a472f2c09027d4845b3a1f70c2bee42df4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e299333ccf126d00439413fd2e9fc45dc87eeb5756798ace28ec863b3463052dfcade119a3730140067cd48f6e37d468934d80f8432d882a974753e900adec2f
|
7
|
+
data.tar.gz: 9a2337da976ae160b46284bc47f6f5131451bafff06cb1cc65d1cc9732d5e9122964b765bfabb25014c3179427f3170ba5f981b93f73d4ca4b50449b0e335383
|
data/html2doc.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "nokogiri", ">= 1.10.4"
|
32
32
|
spec.add_dependency "thread_safe"
|
33
33
|
spec.add_dependency "uuidtools"
|
34
|
-
spec.add_dependency "asciimath", "~> 1.0.
|
34
|
+
spec.add_dependency "asciimath", "~> 1.0.9"
|
35
35
|
|
36
36
|
spec.add_development_dependency "bundler", "~> 2.0.1"
|
37
37
|
spec.add_development_dependency "byebug", "~> 9.1"
|
data/lib/html2doc/base.rb
CHANGED
@@ -99,6 +99,10 @@ module Html2Doc
|
|
99
99
|
r.gsub!(%r{></v:imagedata>}, "/>")
|
100
100
|
r.gsub!(%r{></w:wrap>}, "/>")
|
101
101
|
r.gsub!(%r{&tab;|&tab;}, '<span style="mso-tab-count:1">  </span>')
|
102
|
+
r = r.split(%r{(<m:oMath>|</m:oMath>)}).each_slice(4).map do |a|
|
103
|
+
a.size > 2 and a[2] = a[2].gsub(/>\s+</, "><")
|
104
|
+
a
|
105
|
+
end.join
|
102
106
|
r
|
103
107
|
end
|
104
108
|
|
data/lib/html2doc/math.rb
CHANGED
@@ -46,11 +46,20 @@ module Html2Doc
|
|
46
46
|
gsub(/<\?[^>]+>\s*/, "").
|
47
47
|
gsub(/ xmlns(:[^=]+)?="[^"]+"/, "").
|
48
48
|
gsub(%r{<(/)?([a-z])}, "<\\1m:\\2")
|
49
|
-
ooxml = uncenter(x, ooxml)
|
49
|
+
ooxml = uncenter(esc_space(x), ooxml)
|
50
50
|
x.swap(ooxml)
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
# escape space as 2; we are removing any spaces generated by XML indentation
|
55
|
+
def self.esc_space(xml)
|
56
|
+
xml.traverse do |n|
|
57
|
+
next unless n.text?
|
58
|
+
n = n.text.gsub(/ /, "2")
|
59
|
+
end
|
60
|
+
xml
|
61
|
+
end
|
62
|
+
|
54
63
|
# if oomml has no siblings, by default it is centered; override this with
|
55
64
|
# left/right if parent is so tagged
|
56
65
|
def self.uncenter(m, ooxml)
|
data/lib/html2doc/version.rb
CHANGED
data/spec/html2doc_spec.rb
CHANGED
@@ -248,77 +248,7 @@ lang=EN-GB style='font-size:10.0pt;mso-bidi-font-size:11.0pt'><o:p></o:p></span>
|
|
248
248
|
</html>
|
249
249
|
FTR
|
250
250
|
|
251
|
-
ASCII_MATH
|
252
|
-
<m:nary>
|
253
|
-
<m:naryPr>
|
254
|
-
<m:chr m:val="∑"></m:chr>
|
255
|
-
<m:limLoc m:val="undOvr"></m:limLoc>
|
256
|
-
<m:grow m:val="on"></m:grow>
|
257
|
-
<m:subHide m:val="off"></m:subHide>
|
258
|
-
<m:supHide m:val="off"></m:supHide>
|
259
|
-
</m:naryPr>
|
260
|
-
<m:sub>
|
261
|
-
<m:r>
|
262
|
-
<m:t>i=1</m:t>
|
263
|
-
</m:r>
|
264
|
-
</m:sub>
|
265
|
-
<m:sup>
|
266
|
-
<m:r>
|
267
|
-
<m:t>n</m:t>
|
268
|
-
</m:r>
|
269
|
-
</m:sup>
|
270
|
-
<m:e>
|
271
|
-
<m:sSup>
|
272
|
-
<m:e>
|
273
|
-
<m:r>
|
274
|
-
<m:t>i</m:t>
|
275
|
-
</m:r>
|
276
|
-
</m:e>
|
277
|
-
<m:sup>
|
278
|
-
<m:r>
|
279
|
-
<m:t>3</m:t>
|
280
|
-
</m:r>
|
281
|
-
</m:sup>
|
282
|
-
</m:sSup>
|
283
|
-
</m:e>
|
284
|
-
</m:nary>
|
285
|
-
<m:r>
|
286
|
-
<m:t>=</m:t>
|
287
|
-
</m:r>
|
288
|
-
<m:sSup>
|
289
|
-
<m:e>
|
290
|
-
<m:r>
|
291
|
-
<m:t>(</m:t>
|
292
|
-
</m:r>
|
293
|
-
<m:f>
|
294
|
-
<m:fPr>
|
295
|
-
<m:type m:val="bar"></m:type>
|
296
|
-
</m:fPr>
|
297
|
-
<m:num>
|
298
|
-
<m:r>
|
299
|
-
<m:t>n</m:t>
|
300
|
-
</m:r>
|
301
|
-
<m:r>
|
302
|
-
<m:t>(n+1)</m:t>
|
303
|
-
</m:r>
|
304
|
-
</m:num>
|
305
|
-
<m:den>
|
306
|
-
<m:r>
|
307
|
-
<m:t>2</m:t>
|
308
|
-
</m:r>
|
309
|
-
</m:den>
|
310
|
-
</m:f>
|
311
|
-
<m:r>
|
312
|
-
<m:t>)</m:t>
|
313
|
-
</m:r>
|
314
|
-
</m:e>
|
315
|
-
<m:sup>
|
316
|
-
<m:r>
|
317
|
-
<m:t>2</m:t>
|
318
|
-
</m:r>
|
319
|
-
</m:sup>
|
320
|
-
</m:sSup>
|
321
|
-
FTR
|
251
|
+
ASCII_MATH='<m:nary><m:naryPr><m:chr m:val="∑"></m:chr><m:limLoc m:val="undOvr"></m:limLoc><m:grow m:val="on"></m:grow><m:subHide m:val="off"></m:subHide><m:supHide m:val="off"></m:supHide></m:naryPr><m:sub><m:r><m:t>i=1</m:t></m:r></m:sub><m:sup><m:r><m:t>n</m:t></m:r></m:sup><m:e><m:sSup><m:e><m:r><m:t>i</m:t></m:r></m:e><m:sup><m:r><m:t>3</m:t></m:r></m:sup></m:sSup></m:e></m:nary><m:r><m:t>=</m:t></m:r><m:sSup><m:e><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:f><m:fPr><m:type m:val="bar"></m:type></m:fPr><m:num><m:r><m:t>n</m:t></m:r><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:r><m:t>n+1</m:t></m:r></m:e></m:d></m:num><m:den><m:r><m:t>2</m:t></m:r></m:den></m:f></m:e></m:d></m:e><m:sup><m:r><m:t>2</m:t></m:r></m:sup></m:sSup>'
|
322
252
|
|
323
253
|
DEFAULT_STYLESHEET = File.read("lib/html2doc/wordstyle.css", encoding: "utf-8").freeze
|
324
254
|
|
@@ -431,13 +361,21 @@ RSpec.describe Html2Doc do
|
|
431
361
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
432
362
|
#{word_body("
|
433
363
|
<div><m:oMath>
|
434
|
-
#{ASCII_MATH}
|
435
|
-
|
436
|
-
<
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
364
|
+
#{ASCII_MATH}<m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>\"integer\"</m:t></m:r>
|
365
|
+
</m:oMath>
|
366
|
+
</div>", '<div style="mso-element:footnote-list"/>')}
|
367
|
+
#{WORD_FTR1}
|
368
|
+
OUTPUT
|
369
|
+
end
|
370
|
+
|
371
|
+
it "processes spaces in AsciiMath" do
|
372
|
+
Html2Doc.process(html_input(%[<div>{{text " integer ")}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"])
|
373
|
+
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
374
|
+
to match_fuzzy(<<~OUTPUT)
|
375
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
376
|
+
#{word_body("
|
377
|
+
<div><m:oMath>
|
378
|
+
<m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>integer</m:t></m:r>
|
441
379
|
</m:oMath>
|
442
380
|
</div>", '<div style="mso-element:footnote-list"/>')}
|
443
381
|
#{WORD_FTR1}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html2doc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 1.0.
|
103
|
+
version: 1.0.9
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 1.0.
|
110
|
+
version: 1.0.9
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: bundler
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|