isodoc 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -1
- data/isodoc.gemspec +2 -2
- data/lib/isodoc/class_utils.rb +1 -1
- data/lib/isodoc/function/blocks.rb +1 -1
- data/lib/isodoc/function/cleanup.rb +1 -1
- data/lib/isodoc/function/inline.rb +2 -2
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/to_word_html.rb +2 -2
- data/lib/isodoc/function/utils.rb +1 -1
- data/lib/isodoc/html_function/html.rb +2 -2
- data/lib/isodoc/presentation_function/block.rb +3 -3
- data/lib/isodoc/presentation_function/image.rb +1 -1
- data/lib/isodoc/presentation_function/inline.rb +2 -2
- data/lib/isodoc/presentation_function/section.rb +4 -2
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +3 -3
- data/lib/isodoc/word_function/postprocess.rb +1 -1
- data/lib/isodoc/word_function/postprocess_cover.rb +5 -5
- data/spec/isodoc/metadata_spec.rb +1 -1
- data/spec/isodoc/postproc_spec.rb +8 -11
- data/spec/spec_helper.rb +8 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aff7d421567c13d1c20aa58af56f75a5ef83d78c5268580cef8236b951e41f4d
|
4
|
+
data.tar.gz: 3f81f0d40caa3e069cc814195e565e824c5fd072a8ca408aa70ce2d7026862eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 722f301c40200078c8753612504b5311bd5f1f87041143c9172b70a9b121066579ffb7fd9ce13ebce46a052360e105590fce318324a25175878685ca65958210
|
7
|
+
data.tar.gz: 1f78ddc58e32b347464eb1f73245fc85b4ddb3cb6ac5d27aa9bdaf6f0cc47dfd1db74e648e26ee8ad2860d28eef7530d503471a8ade31f572d9d495299ee033b
|
data/isodoc.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
30
30
|
|
31
31
|
spec.add_dependency "asciimath"
|
32
|
-
spec.add_dependency "html2doc", "~> 1.4.
|
32
|
+
spec.add_dependency "html2doc", "~> 1.4.1"
|
33
33
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
34
34
|
spec.add_dependency "isodoc-i18n", "~> 1.0.0"
|
35
35
|
spec.add_dependency "liquid", "~> 4"
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "emf2svg"
|
38
38
|
spec.add_dependency "mathml2asciimath"
|
39
39
|
spec.add_dependency "metanorma-utils"
|
40
|
-
|
40
|
+
|
41
41
|
spec.add_dependency "relaton-cli"
|
42
42
|
spec.add_dependency "relaton-render", ">= 0.3.1"
|
43
43
|
spec.add_dependency "roman-numerals"
|
data/lib/isodoc/class_utils.rb
CHANGED
@@ -169,7 +169,7 @@ module IsoDoc
|
|
169
169
|
return if author.nil? && source.nil?
|
170
170
|
|
171
171
|
out.p **{ class: "QuoteAttribution" } do |p|
|
172
|
-
p << "
|
172
|
+
p << "— #{author.text}" if author
|
173
173
|
p << ", " if author && source
|
174
174
|
eref_parse(source, p) if source
|
175
175
|
end
|
@@ -134,8 +134,8 @@ module IsoDoc
|
|
134
134
|
|
135
135
|
text = node.to_s
|
136
136
|
if in_sourcecode
|
137
|
-
text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br
|
138
|
-
.gsub(/ (?= )/, "
|
137
|
+
text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/> ")
|
138
|
+
.gsub(/ (?= )/, " ")
|
139
139
|
end
|
140
140
|
out << text
|
141
141
|
end
|
@@ -73,14 +73,14 @@ module IsoDoc
|
|
73
73
|
|
74
74
|
def make_body1(body, _docxml)
|
75
75
|
body.div **{ class: "title-section" } do |div1|
|
76
|
-
div1.p { |p| p << "
|
76
|
+
div1.p { |p| p << " " } # placeholder
|
77
77
|
end
|
78
78
|
section_break(body)
|
79
79
|
end
|
80
80
|
|
81
81
|
def make_body2(body, _docxml)
|
82
82
|
body.div **{ class: "prefatory-section" } do |div2|
|
83
|
-
div2.p { |p| p << "
|
83
|
+
div2.p { |p| p << " " } # placeholder
|
84
84
|
end
|
85
85
|
section_break(body)
|
86
86
|
end
|
@@ -20,7 +20,7 @@ module IsoDoc
|
|
20
20
|
return if @bare
|
21
21
|
|
22
22
|
body.div **{ class: "title-section" } do |div1|
|
23
|
-
div1.p { |p| p << "
|
23
|
+
div1.p { |p| p << " " } # placeholder
|
24
24
|
end
|
25
25
|
section_break(body)
|
26
26
|
end
|
@@ -29,7 +29,7 @@ module IsoDoc
|
|
29
29
|
return if @bare
|
30
30
|
|
31
31
|
body.div **{ class: "prefatory-section" } do |div2|
|
32
|
-
div2.p { |p| p << "
|
32
|
+
div2.p { |p| p << " " } # placeholder
|
33
33
|
end
|
34
34
|
section_break(body)
|
35
35
|
end
|
@@ -31,7 +31,7 @@ module IsoDoc
|
|
31
31
|
return if labelled_ancestor(elem)
|
32
32
|
|
33
33
|
lbl = @xrefs.anchor(elem["id"], :label, false) or return
|
34
|
-
prefix_name(elem, "
|
34
|
+
prefix_name(elem, " — ",
|
35
35
|
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
36
36
|
end
|
37
37
|
|
@@ -60,7 +60,7 @@ module IsoDoc
|
|
60
60
|
else
|
61
61
|
l10n("#{@i18n.example} #{n[:label]}")
|
62
62
|
end
|
63
|
-
prefix_name(elem, "
|
63
|
+
prefix_name(elem, " — ", lbl, "name")
|
64
64
|
end
|
65
65
|
|
66
66
|
def note(docxml)
|
@@ -130,7 +130,7 @@ module IsoDoc
|
|
130
130
|
return if elem["unnumbered"] && !elem.at(ns("./name"))
|
131
131
|
|
132
132
|
n = @xrefs.anchor(elem["id"], :label, false)
|
133
|
-
prefix_name(elem, "
|
133
|
+
prefix_name(elem, " — ", l10n("#{lower2cap @i18n.table} #{n}"),
|
134
134
|
"name")
|
135
135
|
end
|
136
136
|
|
@@ -32,7 +32,7 @@ module IsoDoc
|
|
32
32
|
return if elem.at(ns("./figure")) && !elem.at(ns("./name"))
|
33
33
|
|
34
34
|
lbl = @xrefs.anchor(elem["id"], :label, false) or return
|
35
|
-
prefix_name(elem, "
|
35
|
+
prefix_name(elem, " — ",
|
36
36
|
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
37
37
|
end
|
38
38
|
|
@@ -158,7 +158,7 @@ module IsoDoc
|
|
158
158
|
# TODO: move to localization file
|
159
159
|
def eref_localities1_zh(_target, type, from, upto, node)
|
160
160
|
ret = "第#{from}" if from
|
161
|
-
ret += "
|
161
|
+
ret += "–#{upto}" if upto
|
162
162
|
loc = eref_locality_populate(type, node)
|
163
163
|
ret += " #{loc}" unless node["droploc"] == "true"
|
164
164
|
ret
|
@@ -172,7 +172,7 @@ module IsoDoc
|
|
172
172
|
return l10n(eref_localities1_zh(target, type, from, upto, node))
|
173
173
|
ret = eref_locality_populate(type, node)
|
174
174
|
ret += " #{from}" if from
|
175
|
-
ret += "
|
175
|
+
ret += "–#{upto}" if upto
|
176
176
|
l10n(ret)
|
177
177
|
end
|
178
178
|
|
@@ -56,11 +56,11 @@ module IsoDoc
|
|
56
56
|
|
57
57
|
def single_term_clause(elem)
|
58
58
|
t = elem.at(ns("./terms | ./definitions | ./references"))
|
59
|
-
t.at(ns("./title"))
|
59
|
+
t.at(ns("./title"))&.remove
|
60
60
|
t.xpath(ns(".//clause | .//terms | .//definitions | .//references"))
|
61
61
|
.each do |c|
|
62
62
|
tit = c.at(ns("./title")) or return
|
63
|
-
tit["depth"] = tit["depth"].to_i - 1
|
63
|
+
tit["depth"] = tit["depth"].to_i - 1 unless tit["depth"] == "1"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -84,6 +84,8 @@ module IsoDoc
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def bibitem(xml)
|
87
|
+
@xrefs.klass.implicit_reference(xml) and
|
88
|
+
xml["hidden"] = "true"
|
87
89
|
bibrender(xml)
|
88
90
|
end
|
89
91
|
|
data/lib/isodoc/version.rb
CHANGED
@@ -20,7 +20,7 @@ module IsoDoc
|
|
20
20
|
|
21
21
|
def make_body1(body, _docxml)
|
22
22
|
body.div **{ class: "WordSection1" } do |div1|
|
23
|
-
div1.p { |p| p << "
|
23
|
+
div1.p { |p| p << " " } # placeholder
|
24
24
|
end
|
25
25
|
section_break(body)
|
26
26
|
end
|
@@ -34,7 +34,7 @@ module IsoDoc
|
|
34
34
|
introduction docxml, div2
|
35
35
|
preface docxml, div2
|
36
36
|
acknowledgements docxml, div2
|
37
|
-
div2.p { |p| p << "
|
37
|
+
div2.p { |p| p << " " } # placeholder
|
38
38
|
end
|
39
39
|
section_break(body)
|
40
40
|
end
|
@@ -64,7 +64,7 @@ module IsoDoc
|
|
64
64
|
def para_parse(node, out)
|
65
65
|
out.p **attr_code(para_attrs(node)) do |p|
|
66
66
|
unless @termdomain.empty?
|
67
|
-
p << "
|
67
|
+
p << "<#{@termdomain}> "
|
68
68
|
@termdomain = ""
|
69
69
|
end
|
70
70
|
node.children.each { |n| parse(n, p) unless n.name == "note" }
|
@@ -60,7 +60,7 @@ module IsoDoc
|
|
60
60
|
<span lang="EN-GB"><span
|
61
61
|
style='mso-element:field-begin'></span><span
|
62
62
|
style='mso-spacerun:yes'> </span>TOC
|
63
|
-
\\o
|
63
|
+
\\o "1-#{level}" \\h \\z \\u <span
|
64
64
|
style='mso-element:field-separator'></span></span>
|
65
65
|
TOC
|
66
66
|
end
|
@@ -68,7 +68,7 @@ module IsoDoc
|
|
68
68
|
WORD_TOC_SUFFIX1 = <<~TOC.freeze
|
69
69
|
<p class="MsoToc1"><span lang="EN-GB"><span
|
70
70
|
style='mso-element:field-end'></span></span><span
|
71
|
-
lang="EN-GB"><o:p
|
71
|
+
lang="EN-GB"><o:p> </o:p></span></p>
|
72
72
|
TOC
|
73
73
|
|
74
74
|
def make_WordToC(docxml, level)
|
@@ -86,7 +86,7 @@ module IsoDoc
|
|
86
86
|
<span lang="EN-GB"><span
|
87
87
|
style='mso-element:field-begin'></span><span
|
88
88
|
style='mso-spacerun:yes'> </span>TOC
|
89
|
-
\\h \\z \\t
|
89
|
+
\\h \\z \\t "RecommendationTitle,RecommendationTestTitle,recommendationtitle,recommendationtesttitle"
|
90
90
|
<span style='mso-element:field-separator'></span></span>
|
91
91
|
TOC
|
92
92
|
|
@@ -94,7 +94,7 @@ module IsoDoc
|
|
94
94
|
<span lang="EN-GB"><span
|
95
95
|
style='mso-element:field-begin'></span><span
|
96
96
|
style='mso-spacerun:yes'> </span>TOC
|
97
|
-
\\h \\z \\t
|
97
|
+
\\h \\z \\t "TableTitle,tabletitle" <span
|
98
98
|
style='mso-element:field-separator'></span></span>
|
99
99
|
TOC
|
100
100
|
|
@@ -102,7 +102,7 @@ module IsoDoc
|
|
102
102
|
<span lang="EN-GB"><span
|
103
103
|
style='mso-element:field-begin'></span><span
|
104
104
|
style='mso-spacerun:yes'> </span>TOC
|
105
|
-
\\h \\z \\t
|
105
|
+
\\h \\z \\t "FigureTitle,figuretitle" <span
|
106
106
|
style='mso-element:field-separator'></span></span>
|
107
107
|
TOC
|
108
108
|
|
@@ -113,7 +113,7 @@ RSpec.describe IsoDoc do
|
|
113
113
|
:circulateddate=>"2015",
|
114
114
|
:confirmeddate=>"2017",
|
115
115
|
:copieddate=>"2016",
|
116
|
-
:createddate=>"2010
|
116
|
+
:createddate=>"2010–2011",
|
117
117
|
:doc=>"URL E",
|
118
118
|
:docnumber=>"17301-1",
|
119
119
|
:docnumeric=>"17301",
|
@@ -529,7 +529,8 @@ RSpec.describe IsoDoc do
|
|
529
529
|
word = File.read("test.doc")
|
530
530
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
531
531
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
532
|
-
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
532
|
+
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
533
|
+
.gsub(/<o:p> <\/o:p>/, "")))
|
533
534
|
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
534
535
|
<div class="WordSection2">
|
535
536
|
/* an empty word intro page */
|
@@ -573,7 +574,6 @@ RSpec.describe IsoDoc do
|
|
573
574
|
<span style="mso-element:field-end"></span>
|
574
575
|
</span>
|
575
576
|
<span lang="EN-GB" xml:lang="EN-GB">
|
576
|
-
<p class="MsoNormal"> </p>
|
577
577
|
</span>
|
578
578
|
</p>
|
579
579
|
<p class="MsoNormal"> </p>
|
@@ -611,7 +611,8 @@ RSpec.describe IsoDoc do
|
|
611
611
|
word = File.read("test.doc")
|
612
612
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
613
613
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
614
|
-
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
614
|
+
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
615
|
+
.gsub(/<o:p> <\/o:p>/, "")))
|
615
616
|
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
616
617
|
<div class="WordSection2">
|
617
618
|
/* an empty word intro page */
|
@@ -667,7 +668,6 @@ RSpec.describe IsoDoc do
|
|
667
668
|
<span style="mso-element:field-end"></span>
|
668
669
|
</span>
|
669
670
|
<span lang="EN-GB" xml:lang="EN-GB">
|
670
|
-
<p class="MsoNormal"> </p>
|
671
671
|
</span>
|
672
672
|
</p>
|
673
673
|
<p class="MsoNormal"> </p>
|
@@ -719,7 +719,8 @@ RSpec.describe IsoDoc do
|
|
719
719
|
word = File.read("test.doc")
|
720
720
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
721
721
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
722
|
-
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
722
|
+
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
723
|
+
.gsub(/<o:p> <\/o:p>/, "")))
|
723
724
|
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
724
725
|
<div class='WordSection2'>
|
725
726
|
/* an empty word intro page */
|
@@ -830,7 +831,6 @@ RSpec.describe IsoDoc do
|
|
830
831
|
<span style='mso-element:field-end'/>
|
831
832
|
</span>
|
832
833
|
<span lang='EN-GB' xml:lang='EN-GB'>
|
833
|
-
<p class='MsoNormal'> </p>
|
834
834
|
</span>
|
835
835
|
</p>
|
836
836
|
<p class='MsoNormal'> </p>
|
@@ -856,7 +856,8 @@ RSpec.describe IsoDoc do
|
|
856
856
|
word = File.read("test.doc")
|
857
857
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
858
858
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
859
|
-
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
859
|
+
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")
|
860
|
+
.gsub(/<o:p> <\/o:p>/, "")))
|
860
861
|
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
861
862
|
<div class='WordSection2'>
|
862
863
|
/* an empty word intro page */
|
@@ -967,7 +968,6 @@ RSpec.describe IsoDoc do
|
|
967
968
|
<span style='mso-element:field-end'/>
|
968
969
|
</span>
|
969
970
|
<span lang='EN-GB' xml:lang='EN-GB'>
|
970
|
-
<p class='MsoNormal'> </p>
|
971
971
|
</span>
|
972
972
|
</p>
|
973
973
|
<p class='TOCTitle'>List of tables</p>
|
@@ -1006,7 +1006,6 @@ RSpec.describe IsoDoc do
|
|
1006
1006
|
<span style='mso-element:field-end'/>
|
1007
1007
|
</span>
|
1008
1008
|
<span lang='EN-GB' xml:lang='EN-GB'>
|
1009
|
-
<p class='MsoNormal'> </p>
|
1010
1009
|
</span>
|
1011
1010
|
</p>
|
1012
1011
|
<p class='TOCTitle'>List of figures</p>
|
@@ -1045,7 +1044,6 @@ RSpec.describe IsoDoc do
|
|
1045
1044
|
<span style='mso-element:field-end'/>
|
1046
1045
|
</span>
|
1047
1046
|
<span lang='EN-GB' xml:lang='EN-GB'>
|
1048
|
-
<p class='MsoNormal'> </p>
|
1049
1047
|
</span>
|
1050
1048
|
</p>
|
1051
1049
|
<p class='TOCTitle'>List of recommendations</p>
|
@@ -1133,7 +1131,6 @@ RSpec.describe IsoDoc do
|
|
1133
1131
|
<span style='mso-element:field-end'/>
|
1134
1132
|
</span>
|
1135
1133
|
<span lang='EN-GB' xml:lang='EN-GB'>
|
1136
|
-
<p class='MsoNormal'> </p>
|
1137
1134
|
</span>
|
1138
1135
|
</p>
|
1139
1136
|
<p class='MsoNormal'> </p>
|
data/spec/spec_helper.rb
CHANGED
@@ -22,6 +22,13 @@ RSpec.configure do |config|
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def xmlpp(xml)
|
25
|
+
c = HTMLEntities.new
|
26
|
+
xml &&= xml.split(/(&\S+?;)/).map do |n|
|
27
|
+
if /^&\S+?;$/.match?(n)
|
28
|
+
c.encode(c.decode(n), :hexadecimal)
|
29
|
+
else n
|
30
|
+
end
|
31
|
+
end.join
|
25
32
|
s = ""
|
26
33
|
f = REXML::Formatters::Pretty.new(2)
|
27
34
|
f.compact = true
|
@@ -30,7 +37,7 @@ def xmlpp(xml)
|
|
30
37
|
end
|
31
38
|
|
32
39
|
def metadata(hash)
|
33
|
-
|
40
|
+
hash.sort.to_h.delete_if do |_k, v|
|
34
41
|
v.nil? || (v.respond_to?(:empty?) && v.empty?)
|
35
42
|
end
|
36
43
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.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: 2022-05-
|
11
|
+
date: 2022-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.4.
|
33
|
+
version: 1.4.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.4.
|
40
|
+
version: 1.4.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: htmlentities
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,20 +122,6 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: nokogiri
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 1.12.0
|
132
|
-
type: :runtime
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 1.12.0
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: relaton-cli
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|