html2doc 1.0.1 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +8 -1
- data/.github/workflows/ubuntu.yml +20 -7
- data/.github/workflows/windows.yml +8 -1
- data/README.adoc +1 -1
- data/html2doc.gemspec +2 -1
- data/lib/html2doc/math.rb +82 -4
- data/lib/html2doc/mime.rb +1 -0
- data/lib/html2doc/mml2omml.xsl +35 -7
- data/lib/html2doc/version.rb +1 -1
- data/spec/html2doc_spec.rb +58 -14
- metadata +22 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed67d44964092ea651bf40f1e7d4843d9ed84b9e2e3c9a8fe51c77e6ed1b4e8c
|
4
|
+
data.tar.gz: 2bc1662270ac499f54710568ae9ed31f78113556278a0f34510d30683a08b48a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5503cb2408a86644d3481b82002fba01f333a841ff0de0113cdd15de99984fd6aa458ba8af82e521d3fdce79d6f27aae69b9a760be66e85b8de874681710c36b
|
7
|
+
data.tar.gz: b48073035e3000fa1cfc9b3eabf1a5d3e5e2f79dd61aa20881b73cb186d75a69c01e8c7951016bf7a997ab6b7e5911ad2e69b845ecc0783b15aeaa54c6f4f55a
|
data/.github/workflows/macos.yml
CHANGED
@@ -6,22 +6,29 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/ubuntu.yml
|
11
|
+
- .github/workflows/windows.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-macos:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} macOS
|
13
16
|
runs-on: macos-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
21
29
|
uses: actions/setup-ruby@v1
|
22
30
|
with:
|
23
31
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
32
|
- name: Update gems
|
26
33
|
run: |
|
27
34
|
sudo gem install bundler --force
|
@@ -5,23 +5,32 @@ name: ubuntu
|
|
5
5
|
on:
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
|
+
tags:
|
9
|
+
- '*'
|
8
10
|
pull_request:
|
11
|
+
paths-ignore:
|
12
|
+
- .github/workflows/macos.yml
|
13
|
+
- .github/workflows/windows.yml
|
9
14
|
|
10
15
|
jobs:
|
11
16
|
test-linux:
|
12
17
|
name: Test on Ruby ${{ matrix.ruby }} Ubuntu
|
13
18
|
runs-on: ubuntu-latest
|
19
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
20
|
strategy:
|
15
21
|
fail-fast: false
|
16
22
|
matrix:
|
17
23
|
ruby: [ '2.6', '2.5', '2.4' ]
|
24
|
+
experimental: [false]
|
25
|
+
include:
|
26
|
+
- ruby: '2.7'
|
27
|
+
experimental: true
|
18
28
|
steps:
|
19
29
|
- uses: actions/checkout@master
|
20
30
|
- name: Use Ruby
|
21
31
|
uses: actions/setup-ruby@v1
|
22
32
|
with:
|
23
33
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
34
|
- name: Update gems
|
26
35
|
run: |
|
27
36
|
gem install bundler
|
@@ -29,15 +38,19 @@ jobs:
|
|
29
38
|
- name: Run specs
|
30
39
|
run: |
|
31
40
|
bundle exec rake
|
32
|
-
- name: Trigger
|
33
|
-
if:
|
41
|
+
- name: Trigger repositories
|
42
|
+
if: matrix.ruby == '2.6'
|
34
43
|
env:
|
35
|
-
GH_USERNAME:
|
36
|
-
GH_ACCESS_TOKEN: ${{ secrets.
|
44
|
+
GH_USERNAME: metanorma-ci
|
45
|
+
GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
|
37
46
|
run: |
|
38
47
|
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
|
39
48
|
[[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
|
40
|
-
|
49
|
+
CLIENT_PAYLOAD=$(cat <<EOF
|
50
|
+
"{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
|
51
|
+
EOF
|
52
|
+
)
|
53
|
+
for repo in $REPOS
|
41
54
|
do
|
42
|
-
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "
|
55
|
+
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
|
43
56
|
done
|
@@ -6,22 +6,29 @@ on:
|
|
6
6
|
push:
|
7
7
|
branches: [ master ]
|
8
8
|
pull_request:
|
9
|
+
paths-ignore:
|
10
|
+
- .github/workflows/macos.yml
|
11
|
+
- .github/workflows/ubuntu.yml
|
9
12
|
|
10
13
|
jobs:
|
11
14
|
test-windows:
|
12
15
|
name: Test on Ruby ${{ matrix.ruby }} Windows
|
13
16
|
runs-on: windows-latest
|
17
|
+
continue-on-error: ${{ matrix.experimental }}
|
14
18
|
strategy:
|
15
19
|
fail-fast: false
|
16
20
|
matrix:
|
17
21
|
ruby: [ '2.6', '2.5', '2.4' ]
|
22
|
+
experimental: [false]
|
23
|
+
include:
|
24
|
+
- ruby: '2.7'
|
25
|
+
experimental: true
|
18
26
|
steps:
|
19
27
|
- uses: actions/checkout@master
|
20
28
|
- name: Use Ruby
|
21
29
|
uses: actions/setup-ruby@v1
|
22
30
|
with:
|
23
31
|
ruby-version: ${{ matrix.ruby }}
|
24
|
-
architecture: 'x64'
|
25
32
|
- name: Update gems
|
26
33
|
shell: pwsh
|
27
34
|
run: |
|
data/README.adoc
CHANGED
@@ -24,7 +24,7 @@ This work is driven by the Word document generation procedure documented in http
|
|
24
24
|
|
25
25
|
The gem currently does the following:
|
26
26
|
|
27
|
-
* Convert any AsciiMath and MathML to Word's native mathematical formatting language, OOXML. Word supports copy-pasting MathML into Word and converting it into OOXML; however the conversion is not infallible (we have found problems with `\sum`: Word claims parameters were missing, and inserting dotted squares to indicate as much), and you may need to post-edit the OOXML.
|
27
|
+
* Convert any AsciiMath and MathML to Word's native mathematical formatting language, OOXML. Word supports copy-pasting MathML into Word and converting it into OOXML; however the conversion is not infallible (we have in the past found problems with `\sum`: Word claims parameters were missing, and inserting dotted squares to indicate as much), and you may need to post-edit the OOXML.
|
28
28
|
** The gem does attempt to repair the MathML input, to bring it in line with Word's OOXML's expectations. If you find any issues with AsciiMath or MathML input, please raise an issue.
|
29
29
|
* Identify any footnotes in the document (defined as hyperlinks with attributes `class = "Footnote"` or `epub:type = "footnote"`), and render them as Microsoft Word footnotes.
|
30
30
|
** The corresponding footnote content is any `div` or `aside` element with the same `@id` attribute as the footnote points to; e.g. `<a href="#ftn1" epub:type="footnote"><sup>3</sup></a></span>`, pointing to `<aside id="ftn3">`.
|
data/html2doc.gemspec
CHANGED
@@ -31,7 +31,8 @@ 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", "~>
|
34
|
+
spec.add_dependency "asciimath", "~> 2.0.0"
|
35
|
+
spec.add_dependency "plane1converter", "~> 0.0.1"
|
35
36
|
|
36
37
|
spec.add_development_dependency "byebug", "~> 9.1"
|
37
38
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
data/lib/html2doc/math.rb
CHANGED
@@ -2,6 +2,7 @@ require "uuidtools"
|
|
2
2
|
require "asciimath"
|
3
3
|
require "htmlentities"
|
4
4
|
require "nokogiri"
|
5
|
+
require "plane1converter"
|
5
6
|
|
6
7
|
module Html2Doc
|
7
8
|
@xsltemplate =
|
@@ -9,7 +10,8 @@ module Html2Doc
|
|
9
10
|
encoding: "utf-8"))
|
10
11
|
|
11
12
|
def self.asciimath_to_mathml1(x)
|
12
|
-
AsciiMath.
|
13
|
+
AsciiMath::MathMLBuilder.new(:msword => true).append_expression(
|
14
|
+
AsciiMath.parse(HTMLEntities.new.decode(x)).ast).to_s.
|
13
15
|
gsub(/<math>/, "<math xmlns='http://www.w3.org/1998/Math/MathML'>")
|
14
16
|
end
|
15
17
|
|
@@ -24,17 +26,93 @@ module Html2Doc
|
|
24
26
|
end.join
|
25
27
|
end
|
26
28
|
|
29
|
+
def self.unwrap_accents(doc)
|
30
|
+
doc.xpath("//*[@accent = 'true']").each do |x|
|
31
|
+
x.elements.length > 1 or next
|
32
|
+
x.elements[1].name == "mrow" and
|
33
|
+
x.elements[1].replace(x.elements[1].children)
|
34
|
+
end
|
35
|
+
doc
|
36
|
+
end
|
37
|
+
|
27
38
|
# random fixes to MathML input that OOXML needs to render properly
|
28
39
|
def self.ooxml_cleanup(m, docnamespaces)
|
40
|
+
m = unwrap_accents(mathml_preserve_space(
|
41
|
+
mathml_insert_rows(m, docnamespaces), docnamespaces))
|
42
|
+
m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
|
43
|
+
m
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.mathml_insert_rows(m, docnamespaces)
|
29
47
|
m.xpath(%w(msup msub msubsup munder mover munderover).
|
30
48
|
map { |m| ".//xmlns:#{m}" }.join(" | "), docnamespaces).each do |x|
|
31
49
|
next unless x.next_element && x.next_element != "mrow"
|
32
50
|
x.next_element.wrap("<mrow/>")
|
33
51
|
end
|
34
|
-
m.add_namespace(nil, "http://www.w3.org/1998/Math/MathML")
|
35
52
|
m
|
36
53
|
end
|
37
54
|
|
55
|
+
def self.mathml_preserve_space(m, docnamespaces)
|
56
|
+
m.xpath(".//xmlns:mtext", docnamespaces).each do |x|
|
57
|
+
x.children = x.children.to_xml.gsub(/^\s/, " ").gsub(/\s$/, " ")
|
58
|
+
end
|
59
|
+
m
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.unitalic(m)
|
63
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'p']]").each do |x|
|
64
|
+
x.wrap("<span style='font-style:normal;'></span>")
|
65
|
+
end
|
66
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'bi']]").each do |x|
|
67
|
+
x.wrap("<span class='nostem' style='font-weight:bold;'><em></em></span>")
|
68
|
+
end
|
69
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'i']]").each do |x|
|
70
|
+
x.wrap("<span class='nostem'><em></em></span>")
|
71
|
+
end
|
72
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:scr)]/xmlns:sty[@m:val = 'b']]").each do |x|
|
73
|
+
x.wrap("<span style='font-style:normal;font-weight:bold;'></span>")
|
74
|
+
end
|
75
|
+
m.xpath(".//xmlns:r[xmlns:rPr/xmlns:scr[@m:val = 'monospace']]").each do |x|
|
76
|
+
toPlane1(x, :monospace)
|
77
|
+
end
|
78
|
+
m.xpath(".//xmlns:r[xmlns:rPr/xmlns:scr[@m:val = 'double-struck']]").each do |x|
|
79
|
+
toPlane1(x, :doublestruck)
|
80
|
+
end
|
81
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:sty) or xmlns:sty/@m:val = 'p']/xmlns:scr[@m:val = 'script']]").each do |x|
|
82
|
+
toPlane1(x, :script)
|
83
|
+
end
|
84
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'b']/xmlns:scr[@m:val = 'script']]").each do |x|
|
85
|
+
toPlane1(x, :scriptbold)
|
86
|
+
end
|
87
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:sty) or xmlns:sty/@m:val = 'p']/xmlns:scr[@m:val = 'fraktur']]").each do |x|
|
88
|
+
toPlane1(x, :fraktur)
|
89
|
+
end
|
90
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'b']/xmlns:scr[@m:val = 'fraktur']]").each do |x|
|
91
|
+
toPlane1(x, :frakturbold)
|
92
|
+
end
|
93
|
+
m.xpath(".//xmlns:r[xmlns:rPr[not(xmlns:sty) or xmlns:sty/@m:val = 'p']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
94
|
+
toPlane1(x, :sans)
|
95
|
+
end
|
96
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'b']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
97
|
+
toPlane1(x, :sansbold)
|
98
|
+
end
|
99
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'i']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
100
|
+
toPlane1(x, :sansitalic)
|
101
|
+
end
|
102
|
+
m.xpath(".//xmlns:r[xmlns:rPr[xmlns:sty/@m:val = 'bi']/xmlns:scr[@m:val = 'sans-serif']]").each do |x|
|
103
|
+
toPlane1(x, :sansbolditalic)
|
104
|
+
end
|
105
|
+
m
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.toPlane1(x, font)
|
109
|
+
x.traverse do |n|
|
110
|
+
next unless n.text?
|
111
|
+
n.replace(Plane1Converter.conv(HTMLEntities.new.decode(n.text), font))
|
112
|
+
end
|
113
|
+
x
|
114
|
+
end
|
115
|
+
|
38
116
|
def self.mathml_to_ooml(docxml)
|
39
117
|
docnamespaces = docxml.collect_namespaces
|
40
118
|
m = docxml.xpath("//*[local-name() = 'math']")
|
@@ -44,10 +122,10 @@ module Html2Doc
|
|
44
122
|
element = ooxml_cleanup(x, docnamespaces)
|
45
123
|
doc = Nokogiri::XML::Document::new()
|
46
124
|
doc.root = element
|
47
|
-
ooxml = (esc_space(@xsltemplate.transform(doc))).to_s.
|
125
|
+
ooxml = (unitalic(esc_space(@xsltemplate.transform(doc)))).to_s.
|
48
126
|
gsub(/<\?[^>]+>\s*/, "").
|
49
127
|
gsub(/ xmlns(:[^=]+)?="[^"]+"/, "").
|
50
|
-
gsub(%r{<(/)?([a-z])}, "<\\1m:\\2")
|
128
|
+
gsub(%r{<(/)?(?!span)(?!em)([a-z])}, "<\\1m:\\2")
|
51
129
|
ooxml = uncenter(x, ooxml)
|
52
130
|
x.swap(ooxml)
|
53
131
|
end
|
data/lib/html2doc/mime.rb
CHANGED
@@ -68,6 +68,7 @@ module Html2Doc
|
|
68
68
|
realSize = ImageSize.path(path).size
|
69
69
|
s = [i["width"].to_i, i["height"].to_i]
|
70
70
|
s = realSize if s[0].zero? && s[1].zero?
|
71
|
+
return [nil, nil] if realSize[0].nil? || realSize[1].nil?
|
71
72
|
s[1] = s[0] * realSize[1] / realSize[0] if s[1].zero? && !s[0].zero?
|
72
73
|
s[0] = s[1] * realSize[0] / realSize[1] if s[0].zero? && !s[1].zero?
|
73
74
|
s = [(s[0] * maxheight / s[1]).ceil, maxheight] if s[1] > maxheight
|
data/lib/html2doc/mml2omml.xsl
CHANGED
@@ -878,9 +878,21 @@
|
|
878
878
|
</xsl:otherwise>
|
879
879
|
</xsl:choose>
|
880
880
|
</xsl:if>
|
881
|
-
|
881
|
+
</xsl:variable>
|
882
|
+
<!-- NN 20200831 https://github.com/metanorma/metanorma-nist/issues/155 Read in ancestor mstyle -->
|
883
|
+
<xsl:variable name="mathvariant2">
|
884
|
+
<xsl:choose>
|
885
|
+
<xsl:when test="$mathvariant=''">
|
886
|
+
<xsl:value-of select="$ndCur/ancestor::mml:mstyle[@mathvariant][1]/@mathvariant"/>
|
887
|
+
</xsl:when>
|
888
|
+
<xsl:otherwise>
|
889
|
+
<xsl:value-of select="$mathvariant"/>
|
890
|
+
</xsl:otherwise>
|
891
|
+
</xsl:choose>
|
892
|
+
</xsl:variable>
|
893
|
+
<!-- END NN -->
|
882
894
|
<xsl:call-template name="CreateMathRPR">
|
883
|
-
<xsl:with-param name="mathvariant" select="$
|
895
|
+
<xsl:with-param name="mathvariant" select="$mathvariant2"/>
|
884
896
|
<xsl:with-param name="fontstyle" select="$fontstyle"/>
|
885
897
|
<xsl:with-param name="fontweight" select="$fontweight"/>
|
886
898
|
<xsl:with-param name="ndCur" select="$ndCur"/>
|
@@ -905,7 +917,7 @@
|
|
905
917
|
<xsl:with-param name="fontweight" select="$fontweight"/>
|
906
918
|
<xsl:with-param name="ndCur" select="$ndCur"/>
|
907
919
|
</xsl:call-template>
|
908
|
-
|
920
|
+
</xsl:variable>
|
909
921
|
<xsl:if test="$fLit=1 or $fNor=1 or ($sFontCur!='italic' and $sFontCur!='')">
|
910
922
|
<rPr>
|
911
923
|
<xsl:if test="$fNor=1">
|
@@ -919,7 +931,7 @@
|
|
919
931
|
<xsl:with-param name="fNor" select="$fNor"/>
|
920
932
|
</xsl:call-template>
|
921
933
|
</rPr>
|
922
|
-
|
934
|
+
</xsl:if>
|
923
935
|
</xsl:template>
|
924
936
|
|
925
937
|
<!-- %%Template: GetFontCur
|
@@ -935,8 +947,10 @@
|
|
935
947
|
</xsl:when>
|
936
948
|
<xsl:when test="not($ndCur)">
|
937
949
|
<xsl:value-of select="'italic'"/>
|
938
|
-
|
939
|
-
|
950
|
+
</xsl:when>
|
951
|
+
<!--<xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) <= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN' or $ndCur/self::mml:mo">-->
|
952
|
+
<!-- https://github.com/metanorma/metanorma-nist/issues/155 : DO NOT italicise mml:mo -->
|
953
|
+
<xsl:when test="$ndCur/self::mml:mi and (string-length(normalize-space($ndCur)) <= 1) or $ndCur/self::mml:mn and string(number($ndCur/text()))!='NaN'">
|
940
954
|
|
941
955
|
<!-- The default for the above three cases is fontstyle=italic fontweight=normal.-->
|
942
956
|
<xsl:choose>
|
@@ -1000,6 +1014,12 @@
|
|
1000
1014
|
</sty>
|
1001
1015
|
</xsl:when>
|
1002
1016
|
<xsl:when test="$font='italic'">
|
1017
|
+
<!-- NN 20200901 https://github.com/metanorma/metanorma-itu/issues/173 italic needs to be added explicitly to mtext -->
|
1018
|
+
<xsl:if test="$fNor=1">
|
1019
|
+
<sty>
|
1020
|
+
<xsl:attribute name="m:val">i</xsl:attribute>
|
1021
|
+
</sty>
|
1022
|
+
</xsl:if>
|
1003
1023
|
</xsl:when>
|
1004
1024
|
<xsl:when test="$font='script'">
|
1005
1025
|
<scr>
|
@@ -1067,8 +1087,16 @@
|
|
1067
1087
|
<xsl:attribute name="m:val">bi</xsl:attribute>
|
1068
1088
|
</sty>
|
1069
1089
|
</xsl:when>
|
1070
|
-
<xsl:when test="$font='monospace'"
|
1090
|
+
<xsl:when test="$font='monospace'">
|
1071
1091
|
<!-- We can't do monospace, so leave empty -->
|
1092
|
+
<!-- NN 2020 https://github.com/metanorma/html2doc/issues/47 no, we will -->
|
1093
|
+
<scr>
|
1094
|
+
<xsl:attribute name="m:val">monospace</xsl:attribute>
|
1095
|
+
</scr>
|
1096
|
+
<sty>
|
1097
|
+
<xsl:attribute name="m:val">p</xsl:attribute>
|
1098
|
+
</sty>
|
1099
|
+
</xsl:when>
|
1072
1100
|
<xsl:when test="$font='bold'">
|
1073
1101
|
<sty>
|
1074
1102
|
<xsl:attribute name="m:val">b</xsl:attribute>
|
data/lib/html2doc/version.rb
CHANGED
data/spec/html2doc_spec.rb
CHANGED
@@ -372,11 +372,25 @@ RSpec.describe Html2Doc do
|
|
372
372
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
373
373
|
to match_fuzzy(<<~OUTPUT)
|
374
374
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
375
|
-
#{word_body(
|
375
|
+
#{word_body(%{
|
376
376
|
<div><m:oMath>
|
377
|
-
|
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><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>
|
378
378
|
</m:oMath>
|
379
|
-
</div>
|
379
|
+
</div>}, '<div style="mso-element:footnote-list"/>')}
|
380
|
+
#{WORD_FTR1}
|
381
|
+
OUTPUT
|
382
|
+
end
|
383
|
+
|
384
|
+
it "processes mstyle" do
|
385
|
+
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: ["{{", "}}"])
|
386
|
+
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
387
|
+
to match_fuzzy(<<~OUTPUT)
|
388
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
389
|
+
#{word_body(%{
|
390
|
+
<div><m:oMath>
|
391
|
+
<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>
|
392
|
+
</m:oMath>
|
393
|
+
</div>}, '<div style="mso-element:footnote-list"/>')}
|
380
394
|
#{WORD_FTR1}
|
381
395
|
OUTPUT
|
382
396
|
end
|
@@ -386,11 +400,41 @@ RSpec.describe Html2Doc do
|
|
386
400
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
387
401
|
to match_fuzzy(<<~OUTPUT)
|
388
402
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
389
|
-
#{word_body(
|
403
|
+
#{word_body('
|
390
404
|
<div><m:oMath>
|
391
|
-
<m:r><m:rPr><m:nor></m:nor></m:rPr><m:t>
|
405
|
+
<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
406
|
</m:oMath>
|
393
|
-
</div>
|
407
|
+
</div>', '<div style="mso-element:footnote-list"/>')}
|
408
|
+
#{WORD_FTR1}
|
409
|
+
OUTPUT
|
410
|
+
end
|
411
|
+
|
412
|
+
it "processes spaces in MathML mtext" do
|
413
|
+
Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
|
414
|
+
<mrow><mi>H</mi><mtext> original </mtext><mi>J</mi></mrow>
|
415
|
+
</math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
|
416
|
+
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
417
|
+
to match_fuzzy(<<~OUTPUT)
|
418
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
419
|
+
#{word_body('<div><m:oMath>
|
420
|
+
<m:r><m:t>H</m:t></m:r><m:r><m:rPr><m:nor></m:nor></m:rPr><m:t> original </m:t></m:r><m:r><m:t>J</m:t></m:r>
|
421
|
+
</m:oMath>
|
422
|
+
</div>', '<div style="mso-element:footnote-list"/>')}
|
423
|
+
#{WORD_FTR1}
|
424
|
+
OUTPUT
|
425
|
+
end
|
426
|
+
|
427
|
+
it "unwraps accent in MathML" do
|
428
|
+
Html2Doc.process(html_input("<div><math xmlns='http://www.w3.org/1998/Math/MathML'>
|
429
|
+
<mover accent='true'><mrow><mi>p</mi></mrow><mrow><mo>^</mo></mrow></mover>
|
430
|
+
</math></div>"), filename: "test", asciimathdelims: ["{{", "}}"])
|
431
|
+
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
432
|
+
to match_fuzzy(<<~OUTPUT)
|
433
|
+
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
434
|
+
#{word_body('<div><m:oMath>
|
435
|
+
<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>
|
436
|
+
</m:oMath>
|
437
|
+
</div>', '<div style="mso-element:footnote-list"/>')}
|
394
438
|
#{WORD_FTR1}
|
395
439
|
OUTPUT
|
396
440
|
end
|
@@ -400,11 +444,11 @@ RSpec.describe Html2Doc do
|
|
400
444
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
401
445
|
to match_fuzzy(<<~OUTPUT)
|
402
446
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
403
|
-
#{word_body(
|
404
|
-
<div style
|
405
|
-
|
447
|
+
#{word_body(%{
|
448
|
+
<div style="text-align:left;"><m:oMathPara><m:oMathParaPr><m:jc m:val="left"/></m:oMathParaPr><m:oMath>
|
449
|
+
<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>
|
406
450
|
</m:oMath>
|
407
|
-
</m:oMathPara></div>
|
451
|
+
</m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
|
408
452
|
#{WORD_FTR1}
|
409
453
|
OUTPUT
|
410
454
|
end
|
@@ -414,11 +458,11 @@ RSpec.describe Html2Doc do
|
|
414
458
|
expect(guid_clean(File.read("test.doc", encoding: "utf-8"))).
|
415
459
|
to match_fuzzy(<<~OUTPUT)
|
416
460
|
#{WORD_HDR} #{DEFAULT_STYLESHEET} #{WORD_HDR_END}
|
417
|
-
#{word_body(
|
418
|
-
<div style
|
419
|
-
|
461
|
+
#{word_body(%{
|
462
|
+
<div style="text-align:right;"><m:oMathPara><m:oMathParaPr><m:jc m:val="right"/></m:oMathParaPr><m:oMath>
|
463
|
+
<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>
|
420
464
|
</m:oMath>
|
421
|
-
</m:oMathPara></div>
|
465
|
+
</m:oMathPara></div>}, '<div style="mso-element:footnote-list"/>')}
|
422
466
|
#{WORD_FTR1}
|
423
467
|
OUTPUT
|
424
468
|
end
|
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.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -100,14 +100,28 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.0.0
|
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:
|
110
|
+
version: 2.0.0
|
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
|
@@ -309,7 +323,7 @@ licenses:
|
|
309
323
|
- CC-BY-SA-3.0
|
310
324
|
- BSD-2-Clause
|
311
325
|
metadata: {}
|
312
|
-
post_install_message:
|
326
|
+
post_install_message:
|
313
327
|
rdoc_options: []
|
314
328
|
require_paths:
|
315
329
|
- lib
|
@@ -324,9 +338,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
338
|
- !ruby/object:Gem::Version
|
325
339
|
version: '0'
|
326
340
|
requirements: []
|
327
|
-
|
328
|
-
|
329
|
-
signing_key:
|
341
|
+
rubygems_version: 3.0.3
|
342
|
+
signing_key:
|
330
343
|
specification_version: 4
|
331
344
|
summary: Convert HTML document to Microsoft Word document
|
332
345
|
test_files: []
|