html2doc 1.8.9 → 1.9.1
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/html2doc.gemspec +2 -1
- data/lib/html2doc/math.rb +11 -5
- data/lib/html2doc/notes.rb +23 -15
- data/lib/html2doc/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: abee9d2b61164e6a1ca6a93832d2f0883fd7f759287590e0a3995287f1711964
|
4
|
+
data.tar.gz: efaee47d719f40b076dbc851299e7fd59594a77b3af1654fe3827ba1cce28e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7898834a57a94b995beea51a93270efa90b19f247f8d3bb4d8ee95d9216e9c3828ff8991432a7ac561fe7257fe5ae43760733f035d5562e4f6fc2953c5a9f597
|
7
|
+
data.tar.gz: 78ac742fe5ca906728541c21973739ea6b22256762fc361a9fc7264e3f966fd14f0f29e8f30e2f5a77b8c739201089decf88f3b4c8361f01ecea0413b1c3f464
|
data/html2doc.gemspec
CHANGED
@@ -28,9 +28,10 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_dependency "base64"
|
30
30
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
31
|
+
spec.add_dependency "lutaml-model", "~> 0.7.0"
|
31
32
|
spec.add_dependency "metanorma-utils", ">= 1.9.0"
|
32
33
|
spec.add_dependency "mime-types"
|
33
|
-
spec.add_dependency "nokogiri", "~> 1.
|
34
|
+
spec.add_dependency "nokogiri", "~> 1.18.3"
|
34
35
|
spec.add_dependency "plane1converter", "~> 0.0.1"
|
35
36
|
spec.add_dependency "plurimath", "~> 0.9.0"
|
36
37
|
spec.add_dependency "thread_safe"
|
data/lib/html2doc/math.rb
CHANGED
@@ -167,7 +167,8 @@ class Html2Doc
|
|
167
167
|
doc.root = ooxml_cleanup(xml, docnamespaces)
|
168
168
|
# d = xml.parent["block"] != "false" # display_style
|
169
169
|
ooxml = Nokogiri::XML(Plurimath::Math
|
170
|
-
.parse(doc.root.to_xml(indent: 0), :mathml)
|
170
|
+
.parse(doc.root.to_xml(indent: 0), :mathml)
|
171
|
+
.to_omml(split_on_linebreak: true))
|
171
172
|
ooxml = unitalic(accent_tr(ooxml))
|
172
173
|
ooxml = ooml_clean(uncenter(xml, ooxml))
|
173
174
|
xml.swap(ooxml)
|
@@ -217,15 +218,20 @@ class Html2Doc
|
|
217
218
|
alignnode = math.xpath(STYLE_BEARING_NODE).last
|
218
219
|
ooxml.document? and ooxml = ooxml.root
|
219
220
|
ret = uncenter_unneeded(math, ooxml, alignnode) and return ret
|
220
|
-
dir =
|
221
|
-
|
222
|
-
ooxml.name == "oMathPara" or
|
223
|
-
ooxml.wrap("<m:oMathPara></m:oMathPara>")
|
221
|
+
dir = ooxml_alignment(alignnode)
|
222
|
+
ooxml.name == "oMathPara" or ooxml.wrap("<m:oMathPara></m:oMathPara>")
|
224
223
|
ooxml.elements.first.previous =
|
225
224
|
"<m:oMathParaPr><m:jc m:val='#{dir}'/></m:oMathParaPr>"
|
226
225
|
ooxml
|
227
226
|
end
|
228
227
|
|
228
|
+
def ooxml_alignment(alignnode)
|
229
|
+
dir = "left"
|
230
|
+
/text-align:\s*right/.match?(alignnode["style"]) and dir = "right"
|
231
|
+
/text-align:\s*center/.match?(alignnode["style"]) and dir = "center"
|
232
|
+
dir
|
233
|
+
end
|
234
|
+
|
229
235
|
def uncenter_unneeded(math, ooxml, alignnode)
|
230
236
|
(math_block?(ooxml, math) || !alignnode) and return ooxml
|
231
237
|
math_only_para?(alignnode) and return nil
|
data/lib/html2doc/notes.rb
CHANGED
@@ -2,22 +2,27 @@ require "uuidtools"
|
|
2
2
|
|
3
3
|
class Html2Doc
|
4
4
|
def footnotes(docxml)
|
5
|
-
i = 1
|
5
|
+
#i = 1
|
6
|
+
indexes = {}
|
7
|
+
@footnote_idx = 1
|
6
8
|
fn = []
|
7
9
|
docxml.xpath("//a").each do |a|
|
8
|
-
|
9
|
-
|
10
|
-
i += 1
|
10
|
+
process_footnote_link(docxml, a, indexes, fn) or next
|
11
|
+
#i += 1
|
11
12
|
end
|
12
|
-
process_footnote_texts(docxml, fn)
|
13
|
+
process_footnote_texts(docxml, fn, indexes)
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
+
# Currently cannot deal with separate footnote containers in each chapter
|
17
|
+
# We may eventually need to support that
|
18
|
+
def process_footnote_texts(docxml, footnotes, indexes)
|
16
19
|
body = docxml.at("//body")
|
17
20
|
list = body.add_child("<div style='mso-element:footnote-list'/>")
|
18
|
-
footnotes.
|
19
|
-
|
21
|
+
footnotes.each do |f|
|
22
|
+
#require 'debug'; binding.b
|
23
|
+
fn = list.first.add_child(footnote_container(docxml, indexes[f["id"]]))
|
20
24
|
f.parent = fn.first
|
25
|
+
f["id"] = ""
|
21
26
|
footnote_div_to_p(f)
|
22
27
|
end
|
23
28
|
footnote_cleanup(docxml)
|
@@ -47,14 +52,17 @@ class Html2Doc
|
|
47
52
|
DIV
|
48
53
|
end
|
49
54
|
|
50
|
-
def process_footnote_link(docxml, elem,
|
51
|
-
|
52
|
-
|
55
|
+
def process_footnote_link(docxml, elem, indexes, footnote)
|
56
|
+
footnote?(elem) or return false
|
53
57
|
href = elem["href"].gsub(/^#/, "")
|
58
|
+
#require "debug"; binding.b
|
54
59
|
note = docxml.at("//*[@name = '#{href}' or @id = '#{href}']")
|
55
|
-
|
56
|
-
|
57
|
-
|
60
|
+
note.nil? and return false
|
61
|
+
unless indexes[href]
|
62
|
+
indexes[href] = @footnote_idx
|
63
|
+
@footnote_idx += 1
|
64
|
+
end
|
65
|
+
set_footnote_link_attrs(elem, indexes[href])
|
58
66
|
if elem.at("./span[@class = 'MsoFootnoteReference']")
|
59
67
|
process_footnote_link1(elem)
|
60
68
|
else elem.children = FN
|
@@ -73,7 +81,7 @@ class Html2Doc
|
|
73
81
|
end
|
74
82
|
|
75
83
|
def transform_footnote_text(note)
|
76
|
-
note["id"] = ""
|
84
|
+
#note["id"] = ""
|
77
85
|
note.xpath(".//div").each { |div| div.replace(div.children) }
|
78
86
|
note.xpath(".//aside | .//p").each do |p|
|
79
87
|
p.name = "p"
|
data/lib/html2doc/version.rb
CHANGED
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.
|
4
|
+
version: 1.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.3.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: lutaml-model
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: metanorma-utils
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +86,14 @@ dependencies:
|
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
89
|
+
version: 1.18.3
|
76
90
|
type: :runtime
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - "~>"
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
96
|
+
version: 1.18.3
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: plane1converter
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|