html2doc 1.0.2 → 1.0.7
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 +63 -0
- data/README.adoc +1 -3
- data/html2doc.gemspec +3 -2
- data/lib/html2doc/math.rb +82 -4
- data/lib/html2doc/mime.rb +3 -3
- data/lib/html2doc/mml2omml.xsl +35 -7
- data/lib/html2doc/version.rb +1 -1
- data/spec/html2doc_spec.rb +58 -14
- metadata +25 -14
- data/.github/workflows/macos.yml +0 -39
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c22a4eab1de78ef99f9dc065388e1023bfda37877d9624d7f28e1d742d920d3
|
4
|
+
data.tar.gz: 1ff70531f2924ba344fefeecec7b14cb99e80212b8a58fd5fef834741cc0b25d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f3f558a9e69bbc9eb88e0af9fcca6b37942b3ca49eabfc152107818d35fa266952329f7615a5cd2d487c63d269176701648fa81fece8fa9c6924782a6c1cccf
|
7
|
+
data.tar.gz: cd70002eea55dfc0d310d2430adb8d3d1d4cca0ff86c1dc2e7ae5bac4dd7ca659ef07a6d55393388961c7cb826470da33f97fc8f4850d7cfdb070fbf91ae39d6
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
|
14
|
+
runs-on: ${{ matrix.os }}
|
15
|
+
continue-on-error: ${{ matrix.experimental }}
|
16
|
+
strategy:
|
17
|
+
fail-fast: false
|
18
|
+
matrix:
|
19
|
+
ruby: [ '2.6', '2.5', '2.4' ]
|
20
|
+
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
+
experimental: [ false ]
|
22
|
+
include:
|
23
|
+
- ruby: '2.7'
|
24
|
+
os: 'ubuntu-latest'
|
25
|
+
experimental: true
|
26
|
+
- ruby: '2.7'
|
27
|
+
os: 'windows-latest'
|
28
|
+
experimental: true
|
29
|
+
- ruby: '2.7'
|
30
|
+
os: 'macos-latest'
|
31
|
+
experimental: true
|
32
|
+
steps:
|
33
|
+
- uses: actions/checkout@master
|
34
|
+
|
35
|
+
- uses: ruby/setup-ruby@v1
|
36
|
+
with:
|
37
|
+
ruby-version: ${{ matrix.ruby }}
|
38
|
+
|
39
|
+
- uses: actions/cache@v1
|
40
|
+
with:
|
41
|
+
path: vendor/bundle
|
42
|
+
key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
|
43
|
+
restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
|
44
|
+
|
45
|
+
- run: bundle config set path 'vendor/bundle'
|
46
|
+
|
47
|
+
- run: bundle install --jobs 4 --retry 3
|
48
|
+
|
49
|
+
- run: bundle exec rake
|
50
|
+
|
51
|
+
notify:
|
52
|
+
name: Trigger notify workflow
|
53
|
+
needs: rake
|
54
|
+
runs-on: ubuntu-latest
|
55
|
+
steps:
|
56
|
+
- name: Trigger notify workflow
|
57
|
+
uses: Sibz/github-status-action@v1
|
58
|
+
with:
|
59
|
+
authToken: ${{ secrets.GITHUB_TOKEN }}
|
60
|
+
context: 'tests-passed-successfully'
|
61
|
+
description: 'Tests passed successfully'
|
62
|
+
state: 'success'
|
63
|
+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
|
data/README.adoc
CHANGED
@@ -3,9 +3,7 @@
|
|
3
3
|
https://github.com/metanorma/html2doc/workflows/main/badge.svg
|
4
4
|
|
5
5
|
image:https://img.shields.io/gem/v/html2doc.svg["Gem Version", link="https://rubygems.org/gems/html2doc"]
|
6
|
-
image:https://github.com/metanorma/html2doc/workflows/
|
7
|
-
image:https://github.com/metanorma/html2doc/workflows/macos/badge.svg["OSX Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Amacos"]
|
8
|
-
image:https://github.com/metanorma/html2doc/workflows/windows/badge.svg["Windows Build Status", link="https://github.com/metanorma/html2doc/actions?query=workflow%3Awindows"]
|
6
|
+
image:https://github.com/metanorma/html2doc/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/html2doc/actions?workflow=rake"]
|
9
7
|
image:https://codeclimate.com/github/metanorma/html2doc/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/html2doc"]
|
10
8
|
image:https://img.shields.io/github/issues-pr-raw/metanorma/html2doc.svg["Pull Requests", link="https://github.com/metanorma/html2doc/pulls"]
|
11
9
|
image:https://img.shields.io/github/commits-since/metanorma/html2doc/latest.svg["Commits since latest",link="https://github.com/metanorma/html2doc/releases"]
|
data/html2doc.gemspec
CHANGED
@@ -28,10 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
29
29
|
spec.add_dependency "image_size"
|
30
30
|
spec.add_dependency "mime-types"
|
31
|
-
spec.add_dependency "nokogiri", "
|
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,7 +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
|
+
return [nil, nil] if realSize.nil? || realSize[0].nil? || realSize[1].nil?
|
72
72
|
s[1] = s[0] * realSize[1] / realSize[0] if s[1].zero? && !s[0].zero?
|
73
73
|
s[0] = s[1] * realSize[0] / realSize[1] if s[0].zero? && !s[1].zero?
|
74
74
|
s = [(s[0] * maxheight / s[1]).ceil, maxheight] if s[1] > maxheight
|
@@ -92,7 +92,7 @@ module Html2Doc
|
|
92
92
|
next unless i.element? && %w(img v:imagedata).include?(i.name)
|
93
93
|
#warnsvg(i["src"])
|
94
94
|
next if /^http/.match i["src"]
|
95
|
-
next if %r{^data:image/[^;]+;base64}.match i["src"]
|
95
|
+
next if %r{^data:(image|application)/[^;]+;base64}.match i["src"]
|
96
96
|
local_filename = %r{^([A-Z]:)?/}.match(i["src"]) ? i["src"] :
|
97
97
|
File.join(localdir, i["src"])
|
98
98
|
new_filename = "#{mkuuid}#{File.extname(i["src"])}"
|
@@ -113,7 +113,7 @@ module Html2Doc
|
|
113
113
|
|
114
114
|
def self.header_image_cleanup1(a, dir, filename, localdir)
|
115
115
|
if a.size == 2 && !(/ src="https?:/.match a[1]) &&
|
116
|
-
!(%r{ src="data:image/[^;]+;base64}.match a[1])
|
116
|
+
!(%r{ src="data:(image|application)/[^;]+;base64}.match a[1])
|
117
117
|
m = / src=['"](?<src>[^"']+)['"]/.match a[1]
|
118
118
|
#warnsvg(m[:src])
|
119
119
|
m2 = /\.(?<suffix>[a-zA-Z_0-9]+)$/.match m[:src]
|
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.7
|
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:
|
11
|
+
date: 2021-01-11 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:
|
103
|
+
version: 2.0.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::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
|
104
118
|
type: :runtime
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - "~>"
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
124
|
+
version: 0.0.1
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: byebug
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -259,9 +273,7 @@ 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"
|
@@ -309,7 +321,7 @@ licenses:
|
|
309
321
|
- CC-BY-SA-3.0
|
310
322
|
- BSD-2-Clause
|
311
323
|
metadata: {}
|
312
|
-
post_install_message:
|
324
|
+
post_install_message:
|
313
325
|
rdoc_options: []
|
314
326
|
require_paths:
|
315
327
|
- lib
|
@@ -324,9 +336,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
336
|
- !ruby/object:Gem::Version
|
325
337
|
version: '0'
|
326
338
|
requirements: []
|
327
|
-
|
328
|
-
|
329
|
-
signing_key:
|
339
|
+
rubygems_version: 3.0.3
|
340
|
+
signing_key:
|
330
341
|
specification_version: 4
|
331
342
|
summary: Convert HTML document to Microsoft Word document
|
332
343
|
test_files: []
|
data/.github/workflows/macos.yml
DELETED
@@ -1,39 +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
|
-
architecture: 'x64'
|
33
|
-
- name: Update gems
|
34
|
-
run: |
|
35
|
-
sudo gem install bundler --force
|
36
|
-
bundle install --jobs 4 --retry 3
|
37
|
-
- name: Run specs
|
38
|
-
run: |
|
39
|
-
bundle exec rake
|
@@ -1,53 +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
|
-
architecture: 'x64'
|
35
|
-
- name: Update gems
|
36
|
-
run: |
|
37
|
-
gem install bundler
|
38
|
-
bundle install --jobs 4 --retry 3
|
39
|
-
- name: Run specs
|
40
|
-
run: |
|
41
|
-
bundle exec rake
|
42
|
-
- name: Trigger dependent repositories
|
43
|
-
if: github.ref == 'refs/heads/master' && matrix.ruby == '2.6'
|
44
|
-
env:
|
45
|
-
GH_USERNAME: ${{ secrets.PAT_USERNAME }}
|
46
|
-
GH_ACCESS_TOKEN: ${{ secrets.PAT_TOKEN }}
|
47
|
-
run: |
|
48
|
-
curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
|
49
|
-
[[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
|
50
|
-
for repo in $DEPENDENT_REPOS
|
51
|
-
do
|
52
|
-
sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "{ \"ref\": \"${GITHUB_REF}\" }"
|
53
|
-
done
|
@@ -1,41 +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
|
-
architecture: 'x64'
|
33
|
-
- name: Update gems
|
34
|
-
shell: pwsh
|
35
|
-
run: |
|
36
|
-
gem install bundler
|
37
|
-
bundle config --local path vendor/bundle
|
38
|
-
bundle install --jobs 4 --retry 3
|
39
|
-
- name: Run specs
|
40
|
-
run: |
|
41
|
-
bundle exec rake
|