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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d8386094c2e6b1ea70008d548b0f0c475242457dcb58152a04bd7e59403cc7b
4
- data.tar.gz: 4606afd5a06cede44afc418efc3e67267a5f75c615626475df57f6e881f8adcc
3
+ metadata.gz: aff7d421567c13d1c20aa58af56f75a5ef83d78c5268580cef8236b951e41f4d
4
+ data.tar.gz: 3f81f0d40caa3e069cc814195e565e824c5fd072a8ca408aa70ce2d7026862eb
5
5
  SHA512:
6
- metadata.gz: 453d7f0089ed9325a0e1b9fbe49b223365811f3115d3b08cc3862be80e56933a3a229273c84b6c52a153e8b8772b8aab50b06215cff2cba76547e8f6105002f3
7
- data.tar.gz: a40f39df17dffbd8ef3286d841c1f5e96ff6abcbc1e41433895126217fa77b78cc650e4f7ba8ccea3948d6cb569cd1725b74e8df19d7cd7f608c9c95960b02a9
6
+ metadata.gz: 722f301c40200078c8753612504b5311bd5f1f87041143c9172b70a9b121066579ffb7fd9ce13ebce46a052360e105590fce318324a25175878685ca65958210
7
+ data.tar.gz: 1f78ddc58e32b347464eb1f73245fc85b4ddb3cb6ac5d27aa9bdaf6f0cc47dfd1db74e648e26ee8ad2860d28eef7530d503471a8ade31f572d9d495299ee033b
@@ -21,4 +21,4 @@ jobs:
21
21
  event_name: ${{ github.event_name }}
22
22
  secrets:
23
23
  rubygems-api-key: ${{ secrets.METANORMA_CI_RUBYGEMS_API_KEY }}
24
-
24
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
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.0"
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
- spec.add_dependency "nokogiri", "~> 1.12.0"
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"
@@ -7,7 +7,7 @@ module IsoDoc
7
7
  return date.text unless from || on || to
8
8
  return on.text if on
9
9
 
10
- ret = "#{from.text}–"
10
+ ret = "#{from.text}–"
11
11
  ret += to.text if to
12
12
  ret
13
13
  end
@@ -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 << "&mdash; #{author.text}" if author
172
+ p << "&#x2014; #{author.text}" if author
173
173
  p << ", " if author && source
174
174
  eref_parse(source, p) if source
175
175
  end
@@ -66,7 +66,7 @@ module IsoDoc
66
66
  title = d.at("./title")
67
67
  n = title.next_element
68
68
  n&.children&.first
69
- &.add_previous_sibling("#{title.remove.text}&mdash;")
69
+ &.add_previous_sibling("#{title.remove.text}&#x2014;")
70
70
  end
71
71
  docxml
72
72
  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/>&nbsp;")
138
- .gsub(/ (?= )/, "&nbsp;")
137
+ text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/>&#xa0;")
138
+ .gsub(/ (?= )/, "&#xa0;")
139
139
  end
140
140
  out << text
141
141
  end
@@ -82,7 +82,7 @@ module IsoDoc
82
82
  node.xpath(ns("./note")).each { |n| parse(n, out) }
83
83
  end
84
84
  @in_table = false
85
- # out.p { |p| p << "&nbsp;" }
85
+ # out.p { |p| p << "&#xa0;" }
86
86
  end
87
87
 
88
88
  SW = "solid windowtext".freeze
@@ -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 << "&nbsp;" } # placeholder
76
+ div1.p { |p| p << "&#xa0;" } # 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 << "&nbsp;" } # placeholder
83
+ div2.p { |p| p << "&#xa0;" } # placeholder
84
84
  end
85
85
  section_break(body)
86
86
  end
@@ -12,7 +12,7 @@ module IsoDoc
12
12
  end
13
13
 
14
14
  def insert_tab(out, count)
15
- tab = %w(Hans Hant).include?(@script) ? "&#x3000;" : "&nbsp; "
15
+ tab = %w(Hans Hant).include?(@script) ? "&#x3000;" : "&#xa0; "
16
16
  [1..count].each { out << tab }
17
17
  end
18
18
 
@@ -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 << "&nbsp;" } # placeholder
23
+ div1.p { |p| p << "&#xa0;" } # 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 << "&nbsp;" } # placeholder
32
+ div2.p { |p| p << "&#xa0;" } # 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, "&nbsp;&mdash; ",
34
+ prefix_name(elem, "&#xa0;&#x2014; ",
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, "&nbsp;&mdash; ", lbl, "name")
63
+ prefix_name(elem, "&#xa0;&#x2014; ", 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, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.table} #{n}"),
133
+ prefix_name(elem, "&#xa0;&#x2014; ", 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, "&nbsp;&mdash; ",
35
+ prefix_name(elem, "&#xa0;&#x2014; ",
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 += "&ndash;#{upto}" if upto
161
+ ret += "&#x2013;#{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 += "&ndash;#{upto}" if upto
175
+ ret += "&#x2013;#{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")).remove
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
 
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.1.1".freeze
3
3
  end
@@ -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 << "&nbsp;" } # placeholder
23
+ div1.p { |p| p << "&#xa0;" } # 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 << "&nbsp;" } # placeholder
37
+ div2.p { |p| p << "&#xa0;" } # 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 << "&lt;#{@termdomain}&gt; "
67
+ p << "&#x3c;#{@termdomain}&#x3e; "
68
68
  @termdomain = ""
69
69
  end
70
70
  node.children.each { |n| parse(n, p) unless n.name == "note" }
@@ -187,7 +187,7 @@ module IsoDoc
187
187
  next unless t.children.empty?
188
188
 
189
189
  t["style"] = t["style"].sub(/;?$/, ";font-size:0pt;")
190
- t.children = "&nbsp;"
190
+ t.children = "&#xa0;"
191
191
  end
192
192
  end
193
193
 
@@ -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'>&#xA0;</span>TOC
63
- \\o &quot;1-#{level}&quot; \\h \\z \\u <span
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>&nbsp;</o:p></span></p>
71
+ lang="EN-GB"><o:p>&#xA0;</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'>&#xA0;</span>TOC
89
- \\h \\z \\t &quot;RecommendationTitle,RecommendationTestTitle,recommendationtitle,recommendationtesttitle&quot;
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'>&#xA0;</span>TOC
97
- \\h \\z \\t &quot;TableTitle,tabletitle&quot; <span
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'>&#xA0;</span>TOC
105
- \\h \\z \\t &quot;FigureTitle,figuretitle&quot; <span
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&ndash;2011",
116
+ :createddate=>"2010&#x2013;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>&#xA0;<\/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">&#xA0;</p>
577
577
  </span>
578
578
  </p>
579
579
  <p class="MsoNormal">&#xA0;</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>&#xA0;<\/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">&#xA0;</p>
671
671
  </span>
672
672
  </p>
673
673
  <p class="MsoNormal">&#xA0;</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>&#xA0;<\/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'>&#xA0;</p>
834
834
  </span>
835
835
  </p>
836
836
  <p class='MsoNormal'>&#xA0;</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>&#xA0;<\/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'>&#xA0;</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'>&#xA0;</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'>&#xA0;</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'>&#xA0;</p>
1137
1134
  </span>
1138
1135
  </p>
1139
1136
  <p class='MsoNormal'>&#xA0;</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
- Hash[hash.sort].delete_if do |_k, v|
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.0
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-09 00:00:00.000000000 Z
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.0
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.0
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