metanorma-standoc 1.8.6 → 1.8.7

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: d29f898d11836b1b9ae020605081f35a144ed06406a24776b93841d05cafac62
4
- data.tar.gz: 5f47fb98bf9189ab80a18fe9f32150e0cf840f6860ec2317147122583748f162
3
+ metadata.gz: df453526eab7a001b67712f6f0bd885a9242d5e489e8a0d8f138bb3a2f653f1e
4
+ data.tar.gz: e632b1a38bff75199ae1047188702e28275ebb3563c921e2a5bc545a5c4ec43f
5
5
  SHA512:
6
- metadata.gz: 92cf686a035d48f5b0507d0fffa91b2b207f741cc14a939b498330065e204b6a194bab1b7796115ff790ae0f29e046d7bf429da1dd51b554b5251febd9b350eb
7
- data.tar.gz: 91a13d5900acf6099186c51e294dd6f441bd298fdafa958bc53d8a0ef95dbfad4427cfad1464cffb1ced2ae840158cb9364c00249a25595b4cfea9a65d4f2136
6
+ metadata.gz: 44bba71bdd21993acfd38de5d3ae020df5bf569a31c0bd208b223a2bef628093f476ae9bf18e3f8e1f716b898238648a9f14ffe24446148e38e0719340b826ff
7
+ data.tar.gz: 40a66dea77906193f52dd4fd99023963a1e0ed1f6e584832bef19022e5278933ba28c85e7624feb0282f94f1e95471a13340a189dbd61835129c3f5f8d10f0b4
data/.gitignore CHANGED
@@ -10,3 +10,5 @@ spec/examples/rice.html
10
10
  spec/examples/rice.xml
11
11
  spec/examples/rice_files/
12
12
  Gemfile.lock
13
+
14
+ .rubocop-https--*
data/.rubocop.yml CHANGED
@@ -1,10 +1,14 @@
1
1
  # This project follows the Ribose OSS style guide.
2
2
  # https://github.com/riboseinc/oss-guides
3
3
  # All project-specific additions and overrides should be specified in this file.
4
-
5
4
  inherit_from:
6
5
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
6
+
7
+ # local repo-specific modifications
8
+
7
9
  AllCops:
10
+ DisplayCopNames: false
11
+ StyleGuideCopsOnly: false
8
12
  TargetRubyVersion: 2.4
9
13
  Rails:
10
14
  Enabled: true
@@ -43,6 +43,7 @@ module Asciidoctor
43
43
  i18nyaml: node.attr("i18nyaml"),
44
44
  scope: node.attr("scope"),
45
45
  htmlstylesheet: node.attr("htmlstylesheet"),
46
+ htmlstylesheet_override: node.attr("htmlstylesheet-override"),
46
47
  htmlcoverpage: node.attr("htmlcoverpage"),
47
48
  htmlintropage: node.attr("htmlintropage"),
48
49
  scripts: node.attr("scripts"),
@@ -67,6 +68,7 @@ module Asciidoctor
67
68
  i18nyaml: node.attr("i18nyaml"),
68
69
  scope: node.attr("scope"),
69
70
  wordstylesheet: node.attr("wordstylesheet"),
71
+ wordstylesheet_override: node.attr("wordstylesheet-override"),
70
72
  standardstylesheet: node.attr("standardstylesheet"),
71
73
  header: node.attr("header"),
72
74
  wordcoverpage: node.attr("wordcoverpage"),
@@ -124,7 +124,7 @@
124
124
  <value>application/tei+xml</value>
125
125
  <value>text/x-asciidoc</value>
126
126
  <value>text/markdown</value>
127
- <value>application/x-isodoc+xml</value>
127
+ <value>application/x-metanorma+xml</value>
128
128
  <text/>
129
129
  </choice>
130
130
  </attribute>
@@ -452,6 +452,7 @@
452
452
  <attribute name="type">
453
453
  <choice>
454
454
  <value>isni</value>
455
+ <value>orcid</value>
455
456
  <value>uri</value>
456
457
  </choice>
457
458
  </attribute>
@@ -461,10 +462,7 @@
461
462
  <define name="org-identifier">
462
463
  <element name="identifier">
463
464
  <attribute name="type">
464
- <choice>
465
- <value>orcid</value>
466
- <value>uri</value>
467
- </choice>
465
+ <data type="string" datatypeLibrary=""/>
468
466
  </attribute>
469
467
  <text/>
470
468
  </element>
@@ -1106,7 +1104,7 @@
1106
1104
  <value>complementOf</value>
1107
1105
  <value>obsoletes</value>
1108
1106
  <value>obsoletedBy</value>
1109
- <value>cited</value>
1107
+ <value>cites</value>
1110
1108
  <value>isCitedIn</value>
1111
1109
  </choice>
1112
1110
  </define>
@@ -45,8 +45,9 @@ module Asciidoctor
45
45
  noko do |xml|
46
46
  xml.figure **literal_attrs(node) do |f|
47
47
  figure_title(node, f)
48
- f.pre node.lines.join("\n"), **attr_code(id: Metanorma::Utils::anchor_or_uuid,
49
- alt: node.attr("alt"))
48
+ f.pre node.lines.join("\n"),
49
+ **attr_code(id: Metanorma::Utils::anchor_or_uuid,
50
+ alt: node.attr("alt"))
50
51
  end
51
52
  end
52
53
  end
@@ -78,9 +79,19 @@ module Asciidoctor
78
79
  example_proper(node)
79
80
  end
80
81
 
82
+ def svgmap_attrs(node)
83
+ attr_code( { id: node.id,
84
+ unnumbered: node.option?("unnumbered") ? "true" : nil,
85
+ number: node.attr("number"),
86
+ subsequence: node.attr("subsequence") }.
87
+ merge(keep_attrs(node)))
88
+ end
89
+
81
90
  def svgmap_example(node)
82
91
  noko do |xml|
83
- xml.svgmap **attr_code(example_attrs(node).merge(src: node.attr("src"), alt: node.attr("alt"))) do |ex|
92
+ xml.svgmap **attr_code(svgmap_attrs(node).merge(
93
+ src: node.attr("src"), alt: node.attr("alt"))) do |ex|
94
+ figure_title(node, ex)
84
95
  ex << node.content
85
96
  end
86
97
  end.join("\n")
@@ -129,8 +140,9 @@ module Asciidoctor
129
140
  end
130
141
 
131
142
  def para_attrs(node)
132
- attr_code(keep_attrs(node).merge(align: node.attr("align"),
133
- id: Metanorma::Utils::anchor_or_uuid(node)))
143
+ attr_code(keep_attrs(node).
144
+ merge(align: node.attr("align"),
145
+ id: Metanorma::Utils::anchor_or_uuid(node)))
134
146
  end
135
147
 
136
148
  def paragraph(node)
@@ -143,8 +155,9 @@ module Asciidoctor
143
155
  end
144
156
 
145
157
  def quote_attrs(node)
146
- attr_code(keep_attrs(node).merge(align: node.attr("align"),
147
- id: Metanorma::Utils::anchor_or_uuid(node)))
158
+ attr_code(keep_attrs(node).
159
+ merge(align: node.attr("align"),
160
+ id: Metanorma::Utils::anchor_or_uuid(node)))
148
161
  end
149
162
 
150
163
  def quote_attribution(node, out)
@@ -168,11 +181,12 @@ module Asciidoctor
168
181
  end
169
182
 
170
183
  def listing_attrs(node)
171
- attr_code(keep_attrs(node).merge(lang: node.attr("language"),
172
- id: Metanorma::Utils::anchor_or_uuid(node),
173
- unnumbered: node.option?("unnumbered") ? "true" : nil,
174
- number: node.attr("number"),
175
- filename: node.attr("filename")))
184
+ attr_code(keep_attrs(node).
185
+ merge(lang: node.attr("language"),
186
+ id: Metanorma::Utils::anchor_or_uuid(node),
187
+ unnumbered: node.option?("unnumbered") ? "true" : nil,
188
+ number: node.attr("number"),
189
+ filename: node.attr("filename")))
176
190
  end
177
191
 
178
192
  # NOTE: html escaping is performed by Nokogiri
@@ -29,7 +29,7 @@ module Asciidoctor
29
29
  def dl2_table_cleanup(xmldoc)
30
30
  q = "//table/following-sibling::*[1][self::p]"
31
31
  xmldoc.xpath(q).each do |s|
32
- if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? && s.next_element.name == "dl"
32
+ if s.text =~ /^\s*key[^a-z]*$/i && s&.next_element&.name == "dl"
33
33
  s.next_element["key"] = "true"
34
34
  s.previous_element << s.next_element.remove
35
35
  s.remove
@@ -95,7 +95,7 @@ module Asciidoctor
95
95
  def formula_cleanup_where2(x)
96
96
  q = "//formula/following-sibling::*[1][self::p]"
97
97
  x.xpath(q).each do |s|
98
- if s.text =~ /^\s*where[^a-z]*$/i && !s.next_element.nil? && s.next_element.name == "dl"
98
+ if s.text =~ /^\s*where[^a-z]*$/i && s&.next_element&.name == "dl"
99
99
  s.next_element["key"] = "true"
100
100
  s.previous_element << s.next_element.remove
101
101
  s.remove
@@ -114,7 +114,7 @@ module Asciidoctor
114
114
  def figure_dl_cleanup2(xmldoc)
115
115
  q = "//figure/following-sibling::*[self::p]"
116
116
  xmldoc.xpath(q).each do |s|
117
- if s.text =~ /^\s*key[^a-z]*$/i && !s.next_element.nil? && s.next_element.name == "dl"
117
+ if s.text =~ /^\s*key[^a-z]*$/i && s&.next_element&.name == "dl"
118
118
  s.next_element["key"] = "true"
119
119
  s.previous_element << s.next_element.remove
120
120
  s.remove
@@ -125,7 +125,9 @@ module Asciidoctor
125
125
  # examples containing only figures become subfigures of figures
126
126
  def subfigure_cleanup(xmldoc)
127
127
  xmldoc.xpath("//example[figure]").each do |e|
128
- next unless e.elements.map { |m| m.name }.reject { |m| %w(name figure).include? m }.empty?
128
+ next unless e.elements.map { |m| m.name }.reject do |m|
129
+ %w(name figure).include? m
130
+ end.empty?
129
131
  e.name = "figure"
130
132
  end
131
133
  end
@@ -140,7 +142,8 @@ module Asciidoctor
140
142
  ELEMS_ALLOW_NOTES = %w[p formula ul ol dl figure].freeze
141
143
 
142
144
  # if a note is at the end of a section, it is left alone
143
- # if a note is followed by a non-note block, it is moved inside its preceding block if it is not delimited
145
+ # if a note is followed by a non-note block,
146
+ # it is moved inside its preceding block if it is not delimited
144
147
  # (so there was no way of making that block include the note)
145
148
  def note_cleanup(xmldoc)
146
149
  q = "//note[following-sibling::*[not(local-name() = 'note')]]"
@@ -150,8 +153,10 @@ module Asciidoctor
150
153
  prev = n.previous_element || next
151
154
  n.parent = prev if ELEMS_ALLOW_NOTES.include? prev.name
152
155
  end
153
- xmldoc.xpath("//note[@keep-separate]").each { |n| n.delete("keep-separate") }
154
- xmldoc.xpath("//termnote[@keep-separate]").each { |n| n.delete("keep-separate") }
156
+ xmldoc.xpath("//note[@keep-separate] | "\
157
+ "//termnote[@keep-separate]").each do |n|
158
+ n.delete("keep-separate")
159
+ end
155
160
  end
156
161
 
157
162
  def requirement_cleanup(x)
@@ -184,18 +189,50 @@ module Asciidoctor
184
189
  end
185
190
 
186
191
  def requirement_cleanup1(r)
187
- while d = r.at("./description[following-sibling::*[1][self::description]]")
192
+ while d = r.at("./description[following-sibling::*[1]"\
193
+ "[self::description]]")
188
194
  n = d.next.remove
189
195
  d << n.children
190
196
  end
191
- r.xpath("./description[normalize-space(.)='']").each { |d| d.replace("\n") }
197
+ r.xpath("./description[normalize-space(.)='']").each do |d|
198
+ d.replace("\n")
199
+ end
192
200
  end
193
201
 
194
202
  def svgmap_cleanup(xmldoc)
203
+ svgmap_moveattrs(xmldoc)
195
204
  svgmap_populate(xmldoc)
196
205
  Metanorma::Utils::svgmap_rewrite(xmldoc, @localdir)
197
206
  end
198
207
 
208
+ def guid?(x)
209
+ /^_[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i.
210
+ match(x)
211
+ end
212
+
213
+ def svgmap_moveattrs(xmldoc)
214
+ xmldoc.xpath("//svgmap").each do |s|
215
+ f = s.at(".//figure") or next
216
+ if t = s.at("./name") and !f.at("./name")
217
+ f.children.first.previous = t.remove
218
+ end
219
+ if s["id"] && guid?(f["id"])
220
+ f["id"] = s["id"]
221
+ s.delete("id")
222
+ end
223
+ svgmap_moveattrs1(s, f)
224
+ end
225
+ end
226
+
227
+ def svgmap_moveattrs1(s, f)
228
+ %w(unnumbered number subsequence keep-with-next
229
+ keep-lines-together).each do |a|
230
+ next if f[a] || !s[a]
231
+ f[a] = s[a]
232
+ s.delete(a)
233
+ end
234
+ end
235
+
199
236
  def svgmap_populate(xmldoc)
200
237
  xmldoc.xpath("//svgmap").each do |s|
201
238
  s1 = s.dup
@@ -204,8 +241,8 @@ module Asciidoctor
204
241
  s1.xpath(".//li").each do |li|
205
242
  t = li&.at(".//eref | .//link | .//xref") or next
206
243
  href = t.xpath("./following-sibling::node()")
207
- next if href.empty?
208
- s << %[<target href="#{svgmap_target(href)}">#{t.to_xml}</target>]
244
+ href.empty? or
245
+ s << %[<target href="#{svgmap_target(href)}">#{t.to_xml}</target>]
209
246
  end
210
247
  end
211
248
  end
@@ -74,7 +74,7 @@ module Asciidoctor
74
74
  end
75
75
  end
76
76
 
77
- UNITSML_NS = "http://unitsml.nist.gov/2005".freeze
77
+ UNITSML_NS = "https://schema.unitsml.org/unitsml/1.0".freeze
78
78
 
79
79
  def add_misc_container(xmldoc)
80
80
  unless ins = xmldoc.at("//misc-container")
@@ -20,12 +20,12 @@ module Asciidoctor
20
20
  node.attr("style") == "bibliography" or
21
21
  @log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
22
22
  @biblio = true
23
- xml.references **attr_code(attrs.merge(normative: false)) do |xml_section|
24
- #title = node.level == 1 ? "Bibliography" : node.title
25
- xml_section.title { |t| t << node.title }
26
- xml_section << node.content
27
- end
28
- @biblio = false
23
+ xml.references **attr_code(attrs.merge(
24
+ normative: node.attr("normative") || false)) do |xml_section|
25
+ xml_section.title { |t| t << node.title }
26
+ xml_section << node.content
27
+ end
28
+ @biblio = false
29
29
  end
30
30
 
31
31
  def bibitem_parse(attrs, xml, node)
@@ -43,12 +43,12 @@ module Asciidoctor
43
43
  node.attr("style") == "bibliography" or
44
44
  @log.add("AsciiDoc Input", node, "Section not marked up as [bibliography]!")
45
45
  @norm_ref = true
46
- xml.references **attr_code(attrs.merge(normative: true)) do |xml_section|
47
- #xml_section.title { |t| t << "Normative References" }
48
- xml_section.title { |t| t << node.title }
49
- xml_section << node.content
50
- end
51
- @norm_ref = false
46
+ xml.references **attr_code(attrs.merge(
47
+ normative: node.attr("normative") || true)) do |xml_section|
48
+ xml_section.title { |t| t << node.title }
49
+ xml_section << node.content
50
+ end
51
+ @norm_ref = false
52
52
  end
53
53
 
54
54
  def global_ievcache_name
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION= "1.8.6".freeze
22
+ VERSION= "1.8.7".freeze
23
23
  end
24
24
  end
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
  spec.add_dependency "metanorma-utils", "~> 1.0.2"
41
41
  spec.add_dependency "mathml2asciimath"
42
42
  spec.add_dependency "latexmath"
43
- spec.add_dependency "asciimath2unitsml", "~> 0.2.0"
43
+ spec.add_dependency "asciimath2unitsml", "~> 0.3.0"
44
44
 
45
45
  spec.add_development_dependency "byebug"
46
46
  spec.add_development_dependency "sassc", "2.4.0"
@@ -49,7 +49,7 @@ Gem::Specification.new do |spec|
49
49
  spec.add_development_dependency "guard-rspec", "~> 4.7"
50
50
  spec.add_development_dependency "rake", "~> 13.0"
51
51
  spec.add_development_dependency "rspec", "~> 3.6"
52
- spec.add_development_dependency "rubocop", "= 0.54.0"
52
+ spec.add_development_dependency "rubocop", "~> 1.5.2"
53
53
  spec.add_development_dependency "simplecov", "~> 0.15"
54
54
  spec.add_development_dependency "timecop", "~> 0.9"
55
55
  spec.add_development_dependency "vcr", "~> 5.0.0"
@@ -709,6 +709,7 @@ OUTPUT
709
709
  :header-font: Comic Sans
710
710
  :monospace-font: Andale Mono
711
711
  :htmlstylesheet: spec/assets/html.scss
712
+ :htmlstylesheet-override: spec/assets/html-override.css
712
713
  :htmlcoverpage: spec/assets/htmlcover.html
713
714
  :htmlintropage: spec/assets/htmlintro.html
714
715
  :scripts: spec/assets/scripts.html
@@ -727,6 +728,7 @@ OUTPUT
727
728
  expect(html).to match(%r[an empty html cover page])
728
729
  expect(html).to match(%r[an empty html intro page])
729
730
  expect(html).to match(%r[This is > a script])
731
+ expect(html).to match(%r[html-override])
730
732
  end
731
733
 
732
734
  it "uses specified fonts and assets in Word" do
@@ -741,6 +743,7 @@ OUTPUT
741
743
  :header-font: Comic Sans
742
744
  :monospace-font: Andale Mono
743
745
  :wordstylesheet: spec/assets/word.scss
746
+ :wordstylesheet-override: spec/assets/word-override.css
744
747
  :wordcoverpage: spec/assets/wordcover.html
745
748
  :wordintropage: spec/assets/wordintro.html
746
749
  :header: spec/assets/header.html
@@ -758,6 +761,7 @@ OUTPUT
758
761
  expect(html).to match(%r[h1[^{]+\{[^{]+font-family: Comic Sans;]m)
759
762
  expect(html).to match(%r[an empty word cover page])
760
763
  expect(html).to match(%r[an empty word intro page])
764
+ expect(html).to match(%r[word-override])
761
765
  expect(html).to include('\o "1-3"')
762
766
  expect(html).to include(%[Content-Location: file:///C:/Doc/test_files/header.html
763
767
  Content-Transfer-Encoding: base64
@@ -560,15 +560,15 @@ INPUT
560
560
  </title>
561
561
  <p id='_'>There are no normative references in this document.</p>
562
562
  </references>
563
- <references id='_' normative='false' obligation='informative'>
564
- <title>Bibliography
563
+ <references id='_' normative='true' obligation='informative'>
564
+ <title>Normative References 2.
565
565
  <fn reference='1'>
566
566
  <p id='_'>A</p>
567
567
  </fn>
568
568
  </title>
569
569
  </references>
570
570
  <references id='_' normative='false' obligation='informative'>
571
- <title>Bibliography.
571
+ <title>Bibliography
572
572
  <fn reference='1'>
573
573
  <p id='_'>A</p>
574
574
  </fn>
@@ -803,8 +803,8 @@ INPUT
803
803
  <title>Normative references</title>
804
804
  <p id='_'>There are no normative references in this document.</p>
805
805
  </references>
806
- <references id='_' normative='false' obligation='informative'>
807
- <title>Bibliography</title>
806
+ <references id='_' normative='true' obligation='informative'>
807
+ <title>Normative References 2</title>
808
808
  </references>
809
809
  <references id='_' normative='false' obligation='informative'>
810
810
  <title>Bibliography</title>
@@ -1037,11 +1037,11 @@ INPUT
1037
1037
  <title>Références normatives</title>
1038
1038
  <p id='_'>Le présent document ne contient aucune référence normative.</p>
1039
1039
  </references>
1040
- <references id='_' normative='false' obligation='informative'>
1041
- <title>Bibliographie</title>
1040
+ <references id='_' normative='true' obligation='informative'>
1041
+ <title>Normative References 2</title>
1042
1042
  </references>
1043
1043
  <references id='_' normative='false' obligation='informative'>
1044
- <title>Bibliography</title>
1044
+ <title>Bibliographie</title>
1045
1045
  </references>
1046
1046
  <clause id='_' obligation='informative'>
1047
1047
  <title>Bibliography 2</title>
@@ -1268,11 +1268,11 @@ INPUT
1268
1268
  <title>规范性引用文件</title>
1269
1269
  <p id='_'>本文件并没有规范性引用文件。</p>
1270
1270
  </references>
1271
- <references id='_' normative='false' obligation='informative'>
1272
- <title>参考文献</title>
1271
+ <references id='_' normative='true' obligation='informative'>
1272
+ <title>Normative References 2</title>
1273
1273
  </references>
1274
1274
  <references id='_' normative='false' obligation='informative'>
1275
- <title>Bibliography</title>
1275
+ <title>参考文献</title>
1276
1276
  </references>
1277
1277
  <clause id='_' obligation='informative'>
1278
1278
  <title>Bibliography 2</title>
@@ -1499,11 +1499,11 @@ INPUT
1499
1499
  <title>Normaj citaĵoj</title>
1500
1500
  <p id='_'>There are no normative references in this document.</p>
1501
1501
  </references>
1502
- <references id='_' normative='false' obligation='informative'>
1503
- <title>Bibliografio</title>
1502
+ <references id='_' normative='true' obligation='informative'>
1503
+ <title>Normative References 2</title>
1504
1504
  </references>
1505
1505
  <references id='_' normative='false' obligation='informative'>
1506
- <title>Bibliography</title>
1506
+ <title>Bibliografio</title>
1507
1507
  </references>
1508
1508
  <clause id='_' obligation='informative'>
1509
1509
  <title>Bibliography 2</title>