html2doc 1.0.4 → 1.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 +4 -4
- data/.github/workflows/rake.yml +42 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +6 -2
- data/README.adoc +1 -3
- data/html2doc.gemspec +4 -3
- data/lib/html2doc/base.rb +15 -6
- data/lib/html2doc/math.rb +86 -6
- data/lib/html2doc/mime.rb +19 -10
- data/lib/html2doc/mml2omml.xsl +35 -7
- data/lib/html2doc/version.rb +1 -1
- data/spec/html2doc_spec.rb +63 -21
- metadata +26 -16
- data/.github/workflows/macos.yml +0 -38
- data/.github/workflows/ubuntu.yml +0 -56
- data/.github/workflows/windows.yml +0 -40
- data/.rubocop.ribose.yml +0 -65
- data/.rubocop.tb.yml +0 -650
data/lib/html2doc/version.rb
CHANGED
data/spec/html2doc_spec.rb
CHANGED
@@ -36,7 +36,8 @@ MIME-Version: 1.0
|
|
36
36
|
Content-Type: multipart/related; boundary="----=_NextPart_"
|
37
37
|
|
38
38
|
------=_NextPart_
|
39
|
-
Content-
|
39
|
+
Content-ID: <test.htm>
|
40
|
+
Content-Disposition: inline; filename="test.htm"
|
40
41
|
Content-Type: text/html; charset="utf-8"
|
41
42
|
|
42
43
|
<?xml version="1.0"?>
|
@@ -51,7 +52,7 @@ Content-Type: text/html; charset="utf-8"
|
|
51
52
|
<![endif]-->
|
52
53
|
<meta http-equiv=Content-Type content="text/html; charset=utf-8"/>
|
53
54
|
|
54
|
-
<link rel=File-List href="
|
55
|
+
<link rel=File-List href="cid:filelist.xml"/>
|
55
56
|
<title>blank</title><style><![CDATA[
|
56
57
|
<!--
|
57
58
|
HDR
|
@@ -73,7 +74,8 @@ end
|
|
73
74
|
|
74
75
|
WORD_FTR1 = <<~FTR
|
75
76
|
------=_NextPart_
|
76
|
-
Content-
|
77
|
+
Content-ID: <filelist.xml>
|
78
|
+
Content-Disposition: inline; filename="filelist.xml"
|
77
79
|
Content-Transfer-Encoding: base64
|
78
80
|
Content-Type: #{Html2Doc::mime_type('filelist.xml')}
|
79
81
|
|
@@ -86,7 +88,8 @@ FTR
|
|
86
88
|
|
87
89
|
WORD_FTR2 = <<~FTR
|
88
90
|
------=_NextPart_
|
89
|
-
Content-
|
91
|
+
Content-ID: <filelist.xml>
|
92
|
+
Content-Disposition: inline; filename="filelist.xml"
|
90
93
|
Content-Transfer-Encoding: base64
|
91
94
|
Content-Type: #{Html2Doc::mime_type('filelist.xml')}
|
92
95
|
PHhtbCB4bWxuczpvPSJ1cm46c2NoZW1hcy1taWNyb3NvZnQtY29tOm9mZmljZTpvZmZpY2UiPgog
|
@@ -97,7 +100,8 @@ FTR
|
|
97
100
|
|
98
101
|
WORD_FTR3 = <<~FTR
|
99
102
|
------=_NextPart_
|
100
|
-
Content-
|
103
|
+
Content-ID: <filelist.xml>
|
104
|
+
Content-Disposition: inline; filename="filelist.xml"
|
101
105
|
Content-Transfer-Encoding: base64
|
102
106
|
Content-Type: #{Html2Doc::mime_type('filelist.xml')}
|
103
107
|
|
@@ -106,7 +110,8 @@ ICAgICAgIDxvOk1haW5GaWxlIEhSZWY9Ii4uL3Rlc3QuaHRtIi8+ICA8bzpGaWxlIEhSZWY9IjFh
|
|
106
110
|
YzIwNjVmLTAzZjAtNGM3YS1iOWE2LTkyZTgyMDU5MWJmMC5wbmciLz4KICA8bzpGaWxlIEhSZWY9
|
107
111
|
ImZpbGVsaXN0LnhtbCIvPgo8L3htbD4K
|
108
112
|
------=_NextPart_
|
109
|
-
Content-
|
113
|
+
Content-ID: <cb7b0d19-891e-4634-815a-570d019d454c.png>
|
114
|
+
Content-Disposition: inline; filename="cb7b0d19-891e-4634-815a-570d019d454c.png"
|
110
115
|
Content-Transfer-Encoding: base64
|
111
116
|
Content-Type: image/png
|
112
117
|
------=_NextPart_--
|
@@ -329,9 +334,9 @@ RSpec.describe Html2Doc do
|
|
329
334
|
expect(HTMLEntities.new.encode(hdr, :hexadecimal).
|
330
335
|
gsub(/\</, "<").gsub(/\>/, ">").gsub(/\'/, "'").gsub(/\"/, '"').
|
331
336
|
gsub(/\
/, "
").gsub(/\
/, "\n")).to match_fuzzy(HEADERHTML)
|
332
|
-
expect(html.sub(%r{Content-
|
337
|
+
expect(html.sub(%r{Content-ID: <header.html>.*$}m, "")).
|
333
338
|
to match_fuzzy(<<~OUTPUT)
|
334
|
-
#{WORD_HDR} #{DEFAULT_STYLESHEET.gsub(/
|
339
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET.gsub(/url\("[^"]+"\)/, "url(cid:header.html)")}
|
335
340
|
#{WORD_HDR_END} #{word_body("", '<div style="mso-element:footnote-list"/>')} #{WORD_FTR2}
|
336
341
|
OUTPUT
|
337
342
|
end
|
@@ -340,7 +345,7 @@ RSpec.describe Html2Doc do
|
|
340
345
|
Html2Doc.process(html_input(""), filename: "test", header_file: "spec/header_img.html")
|
341
346
|
doc = guid_clean(File.read("test.doc", encoding: "utf-8"))
|
342
347
|
expect(doc).to match(%r{Content-Type: image/png})
|
343
|
-
expect(doc).to match(%r{
|
348
|
+
expect(doc).to match(%r{iVBORw0KGgoAAAANSUhEUgAAA5cAAAN7CAYAAADRE24cAAAgAElEQVR4XuydB5gUxdaGC65gTogB})
|
344
349
|
end
|
345
350
|
|
346
351
|
it "processes a header with an image with absolute path" do
|
@@ -351,7 +356,7 @@ RSpec.describe Html2Doc do
|
|
351
356
|
Html2Doc.process(html_input(""), filename: "test", header_file: "spec/header_img1.html")
|
352
357
|
doc = guid_clean(File.read("test.doc", encoding: "utf-8"))
|
353
358
|
expect(doc).to match(%r{Content-Type: image/png})
|
354
|
-
expect(doc).to match(%r{
|
359
|
+
expect(doc).to match(%r{iVBORw0KGgoAAAANSUhEUgAAA5cAAAN7CAYAAADRE24cAAAgAElEQVR4XuydB5gUxdaGC65gTogB})
|
355
360
|
end
|
356
361
|
|
357
362
|
|
@@ -374,7 +379,21 @@ RSpec.describe Html2Doc do
|
|
374
379
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
375
380
|
#{word_body(%{
|
376
381
|
<div><m:oMath>
|
377
|
-
<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><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>"integer"</m:t></m:r><m:r><m:t>)</m:t></m:r>
|
382
|
+
<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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><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><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>"integer"</m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
|
383
|
+
</m:oMath>
|
384
|
+
</div>}, '<div style="mso-element:footnote-list"/>')}
|
385
|
+
#{WORD_FTR1}
|
386
|
+
OUTPUT
|
387
|
+
end
|
388
|
+
|
389
|
+
it "processes mstyle" do
|
390
|
+
Html2Doc.process(html_input(%[<div>{{bb (-log_2 (p_u)) bb "BB" bbb "BBB" cc "CC" bcc "BCC" tt "TT" fr "FR" bfr "BFR" sf "SF" bsf "BSFα" sfi "SFI" sfbi "SFBIα" bii "BII" ii "II"}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"])
|
391
|
+
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
392
|
+
to match_fuzzy(<<~OUTPUT)
|
393
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
394
|
+
#{word_body(%{
|
395
|
+
<div><m:oMath>
|
396
|
+
<span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>−</m:t></m:r></span><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>log</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>2</m:t></m:r></span></m:sub></m:sSub><m:d><m:dPr><m:sepChr m:val=","></m:sepChr></m:dPr><m:e><m:sSub><m:e><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>p</m:t></m:r></span></m:e><m:sub><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:sty m:val="b"></m:sty></m:rPr><m:t>u</m:t></m:r></span></m:sub></m:sSub></m:e></m:d><span style="font-style:normal;font-weight:bold;"><m:r><m:rPr><m:nor></m:nor><m:sty m:val="b"></m:sty></m:rPr><m:t>BB</m:t></m:r></span><m:r><m:rPr><m:nor></m:nor><m:scr m:val="double-struck"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>𝔹𝔹𝔹</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr></m:rPr><m:t>𝒞𝒞</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="script"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>𝓑𝓒𝓒</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="monospace"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>𝚃𝚃</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>𝔉ℜ</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="fraktur"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>𝕭𝕱𝕽</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="p"></m:sty></m:rPr><m:t>𝖲𝖥</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="b"></m:sty></m:rPr><m:t>𝗕𝗦𝗙𝝰</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr></m:rPr><m:t>𝖲𝖥𝖨</m:t></m:r><m:r><m:rPr><m:nor></m:nor><m:scr m:val="sans-serif"></m:scr><m:sty m:val="bi"></m:sty></m:rPr><m:t>𝙎𝙁𝘽𝙄𝞪</m:t></m:r><span class="nostem" style="font-weight:bold;"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="bi"></m:sty></m:rPr><m:t>BII</m:t></m:r></span><span class="nostem"><em></em><m:r><m:rPr><m:nor></m:nor><m:sty m:val="i"></m:sty></m:rPr><m:t>II</m:t></m:r></span>
|
378
397
|
</m:oMath>
|
379
398
|
</div>}, '<div style="mso-element:footnote-list"/>')}
|
380
399
|
#{WORD_FTR1}
|
@@ -386,11 +405,11 @@ RSpec.describe Html2Doc do
|
|
386
405
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
387
406
|
to match_fuzzy(<<~OUTPUT)
|
388
407
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
389
|
-
#{word_body(
|
408
|
+
#{word_body('
|
390
409
|
<div><m:oMath>
|
391
|
-
<m:r><m:t>text</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t> integer </m:t></m:r><m:r><m:t>)</m:t></m:r>
|
410
|
+
<m:r><m:t>text</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t> integer </m:t></m:r><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>)</m:t></m:r></span>
|
392
411
|
</m:oMath>
|
393
|
-
</div>
|
412
|
+
</div>', '<div style="mso-element:footnote-list"/>')}
|
394
413
|
#{WORD_FTR1}
|
395
414
|
OUTPUT
|
396
415
|
end
|
@@ -410,6 +429,21 @@ RSpec.describe Html2Doc do
|
|
410
429
|
OUTPUT
|
411
430
|
end
|
412
431
|
|
432
|
+
it "unwraps accent in MathML" do
|
433
|
+
Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
|
434
|
+
<mover accent='true'><mrow><mi>p</mi></mrow><mrow><mo>^</mo></mrow></mover>
|
435
|
+
</math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
|
436
|
+
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
437
|
+
to match_fuzzy(<<~OUTPUT)
|
438
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
439
|
+
#{word_body('<div><m:oMath>
|
440
|
+
<m:acc><m:accPr><m:chr m:val="^"></m:chr></m:accPr><m:e><m:r><m:t>p</m:t></m:r></m:e></m:acc>
|
441
|
+
</m:oMath>
|
442
|
+
</div>', '<div style="mso-element:footnote-list"/>')}
|
443
|
+
#{WORD_FTR1}
|
444
|
+
OUTPUT
|
445
|
+
end
|
446
|
+
|
413
447
|
it "left-aligns AsciiMath" do
|
414
448
|
Html2Doc.process(html_input("<div style='text-align:left;'>{{sum_(i=1)^n i^3=((n(n+1))/2)^2}}</div>"), filename: "test", asciimathdelims: ["{{", "}}"])
|
415
449
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
@@ -417,7 +451,7 @@ RSpec.describe Html2Doc do
|
|
417
451
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
418
452
|
#{word_body(%{
|
419
453
|
<div style="text-align:left;"><m:oMathPara><m:oMathParaPr><m:jc m:val="left"/></m:oMathParaPr><m:oMath>
|
420
|
-
<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>
|
454
|
+
<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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><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>
|
421
455
|
</m:oMath>
|
422
456
|
</m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
|
423
457
|
#{WORD_FTR1}
|
@@ -431,13 +465,21 @@ RSpec.describe Html2Doc do
|
|
431
465
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
432
466
|
#{word_body(%{
|
433
467
|
<div style="text-align:right;"><m:oMathPara><m:oMathParaPr><m:jc m:val="right"/></m:oMathParaPr><m:oMath>
|
434
|
-
<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>
|
468
|
+
<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><span style="font-style:normal;"><m:r><m:rPr><m:sty m:val="p"></m:sty></m:rPr><m:t>=</m:t></m:r></span><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>
|
435
469
|
</m:oMath>
|
436
470
|
</m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
|
437
471
|
#{WORD_FTR1}
|
438
472
|
OUTPUT
|
439
473
|
end
|
440
474
|
|
475
|
+
it "raises error in processing of broken AsciiMath" do
|
476
|
+
begin
|
477
|
+
expect{ Html2Doc.process(html_input(%[<div style='text-align:right;'>{{u_c = 6.6"unitsml(kHz)}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"]) }.to output('parsing: u_c = 6.6"unitsml(kHz)').to_stderr
|
478
|
+
rescue StandardError
|
479
|
+
end
|
480
|
+
expect{ Html2Doc.process(html_input(%[<div style='text-align:right;'>{{u_c = 6.6"unitsml(kHz)}}</div>]), filename: "test", asciimathdelims: ["{{", "}}"]) }.to raise_error(StandardError)
|
481
|
+
end
|
482
|
+
|
441
483
|
it "wraps msup after munderover in MathML" do
|
442
484
|
Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
|
443
485
|
<munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>0</mn></mrow><mrow><mi>n</mi></mrow></munderover><msup><mn>2</mn><mrow><mi>i</mi></mrow></msup></math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
|
@@ -498,7 +540,7 @@ RSpec.describe Html2Doc do
|
|
498
540
|
expect(testdoc).to match(%r{Content-Type: image/png})
|
499
541
|
expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
|
500
542
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
501
|
-
#{image_clean(word_body('<img src="
|
543
|
+
#{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
|
502
544
|
#{image_clean(WORD_FTR3)}
|
503
545
|
OUTPUT
|
504
546
|
end
|
@@ -510,7 +552,7 @@ RSpec.describe Html2Doc do
|
|
510
552
|
expect(testdoc).to match(%r{Content-Type: image/gif})
|
511
553
|
expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
|
512
554
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
513
|
-
#{image_clean(word_body('<img src="
|
555
|
+
#{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.gif" width="400" height="118"></img>', '<div style="mso-element:footnote-list"/>'))}
|
514
556
|
#{image_clean(WORD_FTR3).gsub(/image\.png/, "image.gif")}
|
515
557
|
OUTPUT
|
516
558
|
end
|
@@ -522,7 +564,7 @@ RSpec.describe Html2Doc do
|
|
522
564
|
expect(testdoc).to match(%r{Content-Type: image/jpeg})
|
523
565
|
expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
|
524
566
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
525
|
-
#{image_clean(word_body('<img src="
|
567
|
+
#{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.jpg" width="208" height="680"></img>', '<div style="mso-element:footnote-list"/>'))}
|
526
568
|
#{image_clean(WORD_FTR3).gsub(/image\.png/, "image.jpg")}
|
527
569
|
OUTPUT
|
528
570
|
end
|
@@ -576,7 +618,7 @@ RSpec.describe Html2Doc do
|
|
576
618
|
expect(testdoc).to match(%r{Content-Type: image/png})
|
577
619
|
expect(image_clean(guid_clean(testdoc))).to match_fuzzy(<<~OUTPUT)
|
578
620
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
579
|
-
#{image_clean(word_body('<img src="
|
621
|
+
#{image_clean(word_body('<img src="cid:cb7b0d19-891e-4634-815a-570d019d454c.png" width="400" height="388"></img>', '<div style="mso-element:footnote-list"/>'))}
|
580
622
|
#{image_clean(WORD_FTR3)}
|
581
623
|
OUTPUT
|
582
624
|
end
|
@@ -753,7 +795,7 @@ RSpec.describe Html2Doc do
|
|
753
795
|
Html2Doc.process(html_input(simple_body), filename: "spec/test", debug: true)
|
754
796
|
testdoc = File.read("spec/test.doc", encoding: "utf-8")
|
755
797
|
base64_image = testdoc[/image\/png\n\n(.*?)\n\n----/m, 1].gsub!("\n", "")
|
756
|
-
base64_image_basename = testdoc[%r{Content-
|
798
|
+
base64_image_basename = testdoc[%r{Content-ID: <([0-9a-z\-]+)\.png}m, 1]
|
757
799
|
doc_bin_image = Base64.strict_decode64(base64_image)
|
758
800
|
file_bin_image = IO.read("spec/test_files/#{base64_image_basename}.png", mode: "rb")
|
759
801
|
expect(doc_bin_image).to eq file_bin_image
|
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: 1.0
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
name: nokogiri
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.10.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.10.4
|
69
69
|
- !ruby/object:Gem::Dependency
|
@@ -100,14 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.0.
|
103
|
+
version: 2.0.2
|
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: 2.0.
|
110
|
+
version: 2.0.2
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: plane1converter
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.0.1
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.0.1
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: byebug
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,16 +210,16 @@ dependencies:
|
|
196
210
|
name: rubocop
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
198
212
|
requirements:
|
199
|
-
- -
|
213
|
+
- - "~>"
|
200
214
|
- !ruby/object:Gem::Version
|
201
|
-
version:
|
215
|
+
version: 1.5.2
|
202
216
|
type: :development
|
203
217
|
prerelease: false
|
204
218
|
version_requirements: !ruby/object:Gem::Requirement
|
205
219
|
requirements:
|
206
|
-
- -
|
220
|
+
- - "~>"
|
207
221
|
- !ruby/object:Gem::Version
|
208
|
-
version:
|
222
|
+
version: 1.5.2
|
209
223
|
- !ruby/object:Gem::Dependency
|
210
224
|
name: simplecov
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,15 +273,11 @@ extensions: []
|
|
259
273
|
extra_rdoc_files: []
|
260
274
|
files:
|
261
275
|
- ".gitattributes"
|
262
|
-
- ".github/workflows/
|
263
|
-
- ".github/workflows/ubuntu.yml"
|
264
|
-
- ".github/workflows/windows.yml"
|
276
|
+
- ".github/workflows/rake.yml"
|
265
277
|
- ".gitignore"
|
266
278
|
- ".hound.yml"
|
267
279
|
- ".oss-guides.rubocop.yml"
|
268
280
|
- ".rspec"
|
269
|
-
- ".rubocop.ribose.yml"
|
270
|
-
- ".rubocop.tb.yml"
|
271
281
|
- ".rubocop.yml"
|
272
282
|
- CODE_OF_CONDUCT.md
|
273
283
|
- Gemfile
|
@@ -324,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
334
|
- !ruby/object:Gem::Version
|
325
335
|
version: '0'
|
326
336
|
requirements: []
|
327
|
-
rubygems_version: 3.
|
337
|
+
rubygems_version: 3.1.4
|
328
338
|
signing_key:
|
329
339
|
specification_version: 4
|
330
340
|
summary: Convert HTML document to Microsoft Word document
|
data/.github/workflows/macos.yml
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: macos
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
paths-ignore:
|
10
|
-
- .github/workflows/ubuntu.yml
|
11
|
-
- .github/workflows/windows.yml
|
12
|
-
|
13
|
-
jobs:
|
14
|
-
test-macos:
|
15
|
-
name: Test on Ruby ${{ matrix.ruby }} macOS
|
16
|
-
runs-on: macos-latest
|
17
|
-
continue-on-error: ${{ matrix.experimental }}
|
18
|
-
strategy:
|
19
|
-
fail-fast: false
|
20
|
-
matrix:
|
21
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
-
experimental: [false]
|
23
|
-
include:
|
24
|
-
- ruby: '2.7'
|
25
|
-
experimental: true
|
26
|
-
steps:
|
27
|
-
- uses: actions/checkout@master
|
28
|
-
- name: Use Ruby
|
29
|
-
uses: actions/setup-ruby@v1
|
30
|
-
with:
|
31
|
-
ruby-version: ${{ matrix.ruby }}
|
32
|
-
- name: Update gems
|
33
|
-
run: |
|
34
|
-
sudo gem install bundler --force
|
35
|
-
bundle install --jobs 4 --retry 3
|
36
|
-
- name: Run specs
|
37
|
-
run: |
|
38
|
-
bundle exec rake
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: ubuntu
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
tags:
|
9
|
-
- '*'
|
10
|
-
pull_request:
|
11
|
-
paths-ignore:
|
12
|
-
- .github/workflows/macos.yml
|
13
|
-
- .github/workflows/windows.yml
|
14
|
-
|
15
|
-
jobs:
|
16
|
-
test-linux:
|
17
|
-
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
18
|
-
runs-on: ubuntu-latest
|
19
|
-
continue-on-error: ${{ matrix.experimental }}
|
20
|
-
strategy:
|
21
|
-
fail-fast: false
|
22
|
-
matrix:
|
23
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
24
|
-
experimental: [false]
|
25
|
-
include:
|
26
|
-
- ruby: '2.7'
|
27
|
-
experimental: true
|
28
|
-
steps:
|
29
|
-
- uses: actions/checkout@master
|
30
|
-
- name: Use Ruby
|
31
|
-
uses: actions/setup-ruby@v1
|
32
|
-
with:
|
33
|
-
ruby-version: ${{ matrix.ruby }}
|
34
|
-
- name: Update gems
|
35
|
-
run: |
|
36
|
-
gem install bundler
|
37
|
-
bundle install --jobs 4 --retry 3
|
38
|
-
- name: Run specs
|
39
|
-
run: |
|
40
|
-
bundle exec rake
|
41
|
-
- name: Trigger repositories
|
42
|
-
if: matrix.ruby == '2.6'
|
43
|
-
env:
|
44
|
-
GH_USERNAME: metanorma-ci
|
45
|
-
GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
46
|
-
run: |
|
47
|
-
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
|
48
|
-
[[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
|
49
|
-
CLIENT_PAYLOAD=$(cat <<EOF
|
50
|
-
"{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
|
51
|
-
EOF
|
52
|
-
)
|
53
|
-
for repo in $REPOS
|
54
|
-
do
|
55
|
-
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
|
56
|
-
done
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
-
# See https://github.com/metanorma/cimas
|
3
|
-
name: windows
|
4
|
-
|
5
|
-
on:
|
6
|
-
push:
|
7
|
-
branches: [ master ]
|
8
|
-
pull_request:
|
9
|
-
paths-ignore:
|
10
|
-
- .github/workflows/macos.yml
|
11
|
-
- .github/workflows/ubuntu.yml
|
12
|
-
|
13
|
-
jobs:
|
14
|
-
test-windows:
|
15
|
-
name: Test on Ruby ${{ matrix.ruby }} Windows
|
16
|
-
runs-on: windows-latest
|
17
|
-
continue-on-error: ${{ matrix.experimental }}
|
18
|
-
strategy:
|
19
|
-
fail-fast: false
|
20
|
-
matrix:
|
21
|
-
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
-
experimental: [false]
|
23
|
-
include:
|
24
|
-
- ruby: '2.7'
|
25
|
-
experimental: true
|
26
|
-
steps:
|
27
|
-
- uses: actions/checkout@master
|
28
|
-
- name: Use Ruby
|
29
|
-
uses: actions/setup-ruby@v1
|
30
|
-
with:
|
31
|
-
ruby-version: ${{ matrix.ruby }}
|
32
|
-
- name: Update gems
|
33
|
-
shell: pwsh
|
34
|
-
run: |
|
35
|
-
gem install bundler
|
36
|
-
bundle config --local path vendor/bundle
|
37
|
-
bundle install --jobs 4 --retry 3
|
38
|
-
- name: Run specs
|
39
|
-
run: |
|
40
|
-
bundle exec rake
|