metanorma-standoc 2.1.4 → 2.1.5

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: d55c699cf84e05288a133b4e0b9305cfb14809780ec379b8d617a928338f1fca
4
- data.tar.gz: 772eaa9e0e09e9ad7c40b70ade1825d437ba079673767b31c3c5b493cf29af4f
3
+ metadata.gz: 9487b5701cc86946c27e560e244cc4f84fceb61b0a93dd271068875654eb49a0
4
+ data.tar.gz: c647cf6fb530aba3bc96c9087e7a9d49408ce239a6c6aa3a4a46a0e8cf1a5763
5
5
  SHA512:
6
- metadata.gz: fba5328a1ebbc7d236174893d3e98ece5768c3d8935c326506692023d1254c1a2bda95f842956b4830d18c949ba817d4ca4f00548c569999ae38381c1406f02f
7
- data.tar.gz: d3aed7321347c856c5f8ff600118773094ffc948a5f7b3be6655dff48749c4780a5a4048baf1a04d4aad94e22b650648c91c7ca9bc159680beb48ec4275a8904
6
+ metadata.gz: c8356539be6d28f5dc6d4d148cfcabb8ed7dbc033392544d382d36e1e392e33da6b29a64b535f6c24cdab85a4d17d1dc5698367f0edff8f45eb02b1f8ed97330
7
+ data.tar.gz: 13c49550edea0d6169fef67357a5030e146cdf62fec3cb41900db7490d95c09f9dbb1c4f4b55bea4836651ba11fcaf0714b20f37fc3a96a48dd31596cf564549
@@ -28,6 +28,8 @@ module Metanorma
28
28
  passthrough_cleanup(xmldoc)
29
29
  sections_cleanup(xmldoc)
30
30
  obligations_cleanup(xmldoc)
31
+ para_index_cleanup(xmldoc)
32
+ block_index_cleanup(xmldoc)
31
33
  table_cleanup(xmldoc)
32
34
  formula_cleanup(xmldoc)
33
35
  form_cleanup(xmldoc)
@@ -51,7 +53,7 @@ module Metanorma
51
53
  termdef_cleanup(xmldoc)
52
54
  RelatonIev::iev_cleanup(xmldoc, @bibdb)
53
55
  element_name_cleanup(xmldoc)
54
- index_cleanup(xmldoc)
56
+ term_index_cleanup(xmldoc)
55
57
  bpart_cleanup(xmldoc)
56
58
  quotesource_cleanup(xmldoc)
57
59
  callout_cleanup(xmldoc)
@@ -66,7 +66,7 @@ module Metanorma
66
66
  def subfigure_cleanup(xmldoc)
67
67
  xmldoc.xpath("//example[figure]").each do |e|
68
68
  next unless e.elements.map(&:name).reject do |m|
69
- %w(name figure).include? m
69
+ %w(name figure index).include? m
70
70
  end.empty?
71
71
 
72
72
  e.name = "figure"
@@ -178,6 +178,46 @@ module Metanorma
178
178
  end
179
179
  end
180
180
  end
181
+
182
+ def block_index_cleanup(xmldoc)
183
+ xmldoc.xpath("//quote | //td | //th | //formula | //li | //dt | "\
184
+ "//dd | //example | //note | //figure | //sourcecode | "\
185
+ "//admonition | //termnote | //termexample | //form | "\
186
+ "//requirement | //recommendation | //permission | "\
187
+ "//imagemap | //svgmap").each do |b|
188
+ b.xpath("./p[indexterm]").each do |p|
189
+ indexterm_para?(p) or next
190
+ p.replace(p.children)
191
+ end
192
+ end
193
+ end
194
+
195
+ def indexterm_para?(para)
196
+ p = para.dup
197
+ p.xpath("./index").each(&:remove)
198
+ p.text.strip.empty?
199
+ end
200
+
201
+ def include_indexterm?(elem)
202
+ return false if elem.nil?
203
+
204
+ !%w(image literal sourcecode).include?(elem.name)
205
+ end
206
+
207
+ def para_index_cleanup(xmldoc)
208
+ xmldoc.xpath("//p[index]").select { |p| indexterm_para?(p) }
209
+ .each do |p|
210
+ para_index_cleanup1(p, p.previous_element, p.next_element)
211
+ end
212
+ end
213
+
214
+ def para_index_cleanup1(para, prev, foll)
215
+ if include_indexterm?(prev)
216
+ prev << para.remove.children
217
+ elsif include_indexterm?(foll) && !foll.children.empty?
218
+ foll.children.first.previous = para.remove.children
219
+ end
220
+ end
181
221
  end
182
222
  end
183
223
  end
@@ -100,9 +100,13 @@ module Metanorma
100
100
  end
101
101
  end
102
102
 
103
+ def termlookup_cleanup(xmldoc)
104
+ Metanorma::Standoc::TermLookupCleanup.new(xmldoc, @log).call
105
+ end
106
+
103
107
  def termdef_cleanup(xmldoc)
104
108
  termdef_unnest_cleanup(xmldoc)
105
- Metanorma::Standoc::TermLookupCleanup.new(xmldoc, @log).call
109
+ termlookup_cleanup(xmldoc)
106
110
  term_nonverbal_designations(xmldoc)
107
111
  term_dl_to_metadata(xmldoc)
108
112
  term_termsource_to_designation(xmldoc)
@@ -117,7 +121,7 @@ module Metanorma
117
121
  termdocsource_cleanup(xmldoc)
118
122
  end
119
123
 
120
- def index_cleanup(xmldoc)
124
+ def term_index_cleanup(xmldoc)
121
125
  return unless @index_terms
122
126
 
123
127
  xmldoc.xpath("//preferred").each do |p|
@@ -2504,6 +2504,16 @@
2504
2504
  <text/>
2505
2505
  </element>
2506
2506
  </optional>
2507
+ <optional>
2508
+ <element name="amendment">
2509
+ <text/>
2510
+ </element>
2511
+ </optional>
2512
+ <optional>
2513
+ <element name="corrigendum">
2514
+ <text/>
2515
+ </element>
2516
+ </optional>
2507
2517
  <optional>
2508
2518
  <element name="language">
2509
2519
  <text/>
@@ -104,9 +104,9 @@ module Metanorma
104
104
  ret = { id: code }
105
105
  return ret if code.blank?
106
106
 
107
- analyse_ref_nofetch(
108
- analyse_ref_hidden(
109
- analyse_ref_dropid(analyse_ref_repo_path(analyse_ref_numeric(ret))),
107
+ analyse_ref_numeric(
108
+ analyse_ref_repo_path(
109
+ analyse_ref_dropid(analyse_ref_hidden(analyse_ref_nofetch(ret))),
110
110
  ),
111
111
  )
112
112
  end
@@ -121,8 +121,7 @@ module Metanorma
121
121
  end
122
122
 
123
123
  def ref_attributes(match)
124
-
125
- code = analyse_ref_code(match[:code])
124
+ code = analyse_ref_code(match[:code])
126
125
 
127
126
  { id: match[:anchor], type: "standard",
128
127
  suppress_identifier: code[:dropid] || nil }
@@ -38,6 +38,8 @@ module Metanorma
38
38
  when "symbols and abbreviated terms",
39
39
  "symbols", "abbreviated terms", "abbreviations"
40
40
  "symbols and abbreviated terms"
41
+ when "acknowledgements", "acknowledgments"
42
+ "acknowledgements"
41
43
  else
42
44
  ret
43
45
  end
@@ -68,7 +68,7 @@ module Metanorma
68
68
  end
69
69
 
70
70
  def remove_missing_ref(node, target)
71
- if node.at("../concept[@type = 'symbol']")
71
+ if node.at("./parent::concept[@type = 'symbol']")
72
72
  remove_missing_ref_symbol(node, target)
73
73
  else
74
74
  remove_missing_ref_term(node, target)
@@ -60,7 +60,7 @@ module Metanorma
60
60
  "[not(ancestor::boilerplate)]".freeze
61
61
 
62
62
  def isodoc(lang, script, i18nyaml = nil)
63
- conv = html_converter(EmptyAttr.new)
63
+ conv = presentation_xml_converter(EmptyAttr.new)
64
64
  i18n = conv.i18n_init(lang, script, i18nyaml)
65
65
  conv.metadata_init(lang, script, i18n)
66
66
  conv
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.1.4".freeze
22
+ VERSION = "2.1.5".freeze
23
23
  end
24
24
  end
@@ -1070,6 +1070,56 @@ RSpec.describe Metanorma::Standoc do
1070
1070
  .to be_equivalent_to xmlpp(output)
1071
1071
  end
1072
1072
 
1073
+ it "ignores index terms when processing figures marked up as examples" do
1074
+ input = <<~INPUT
1075
+ #{ASCIIDOC_BLANK_HDR}
1076
+
1077
+ ====
1078
+ image::spec/examples/rice_images/rice_image3_1.png[]
1079
+ ====
1080
+
1081
+ ====
1082
+ ((indexterm))
1083
+
1084
+ image::spec/examples/rice_images/rice_image3_3.png[]
1085
+ ====
1086
+
1087
+ ====
1088
+ (((indexterm2)))
1089
+
1090
+ image::spec/examples/rice_images/rice_image3_2.png[]
1091
+ ====
1092
+ INPUT
1093
+ output = <<~OUTPUT
1094
+ #{BLANK_HDR}
1095
+ <sections>
1096
+ <figure id='_'>
1097
+ <image src='spec/examples/rice_images/rice_image3_1.png' id='_' mimetype='image/png' height='auto' width='auto'/>
1098
+ </figure>
1099
+ <example id='_'>
1100
+ <p id='_'>
1101
+ indexterm
1102
+ <index>
1103
+ <primary>indexterm</primary>
1104
+ </index>
1105
+ </p>
1106
+ <figure id='_'>
1107
+ <image src='spec/examples/rice_images/rice_image3_3.png' id='_' mimetype='image/png' height='auto' width='auto'/>
1108
+ </figure>
1109
+ </example>
1110
+ <figure id='_'>
1111
+ <index>
1112
+ <primary>indexterm2</primary>
1113
+ </index>
1114
+ <image src='spec/examples/rice_images/rice_image3_2.png' id='_' mimetype='image/png' height='auto' width='auto'/>
1115
+ </figure>
1116
+ </sections>
1117
+ </standard-document>
1118
+ OUTPUT
1119
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
1120
+ .to be_equivalent_to xmlpp(output)
1121
+ end
1122
+
1073
1123
  it "processes images" do
1074
1124
  input = <<~INPUT
1075
1125
  #{ASCIIDOC_BLANK_HDR}
@@ -1184,4 +1184,87 @@ RSpec.describe Metanorma::Standoc do
1184
1184
  .gsub(%r{<style.*?</style>}m, "<style/>")))
1185
1185
  .to be_equivalent_to xmlpp(output)
1186
1186
  end
1187
+
1188
+ it "removes paras with indexterms" do
1189
+ input = <<~INPUT
1190
+ #{ASCIIDOC_BLANK_HDR}
1191
+
1192
+ == Clause 1
1193
+
1194
+ Paragraph
1195
+
1196
+ (((index)))
1197
+
1198
+ [NOTE]
1199
+ --
1200
+
1201
+ (((index)))
1202
+
1203
+ Note
1204
+ --
1205
+
1206
+ [NOTE]
1207
+ --
1208
+
1209
+ (((index)))
1210
+
1211
+ --
1212
+
1213
+ == Clause 2
1214
+
1215
+ Paragraph
1216
+
1217
+ ((index))
1218
+
1219
+ INPUT
1220
+
1221
+ output = <<~OUTPUT
1222
+ #{BLANK_HDR}
1223
+ <sections>
1224
+ <clause id='_' inline-header='false' obligation='normative'>
1225
+ <title>Clause 1</title>
1226
+ <p id='_'>
1227
+ Paragraph
1228
+ <index>
1229
+ <primary>index</primary>
1230
+ </index>
1231
+ </p>
1232
+ <note id='_'>
1233
+ <p id='_'>
1234
+ <index>
1235
+ <primary>index</primary>
1236
+ </index>
1237
+ Note
1238
+ </p>
1239
+ </note>
1240
+ <note id='_'>
1241
+ <p id='_'>
1242
+ <index>
1243
+ <primary>index</primary>
1244
+ </index>
1245
+ </p>
1246
+ </note>
1247
+ </clause>
1248
+ <clause id='_' inline-header='false' obligation='normative'>
1249
+ <title>Clause 2</title>
1250
+ <p id='_'>Paragraph</p>
1251
+ <p id='_'>
1252
+ index
1253
+ <index>
1254
+ <primary>index</primary>
1255
+ </index>
1256
+ </p>
1257
+ </clause>
1258
+ </sections>
1259
+ </standard-document>
1260
+ OUTPUT
1261
+ xml = Nokogiri::XML(Asciidoctor.convert(input, *OPTIONS))
1262
+ xml.xpath("//*[local-name() = 'image']").each do |x|
1263
+ x.replace("<image/>")
1264
+ end
1265
+ expect(xmlpp(strip_guid(xml.to_xml)
1266
+ .gsub(%r{<style.*?</style>}m, "<style/>")))
1267
+ .to be_equivalent_to xmlpp(output)
1268
+ end
1269
+
1187
1270
  end
@@ -50,7 +50,7 @@ ISO_124_DATED = <<~XML.freeze
50
50
  <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:61884:en</uri>
51
51
  <uri type="rss">https://www.iso.org/contents/data/standard/06/18/61884.detail.rss</uri>
52
52
  <docidentifier type="ISO" primary="true">ISO 124:2014</docidentifier>
53
- <docidentifier type='URN'>urn:iso:std:iso:124:stage-90.93:ed-7:en</docidentifier>
53
+ <docidentifier type='URN'>urn:iso:std:iso:124:stage-90.93:ed-7</docidentifier>
54
54
  <docnumber>124</docnumber>
55
55
  <date type="published">
56
56
  <on>2014-03</on>
@@ -82,6 +82,7 @@ ISO_124_DATED = <<~XML.freeze
82
82
  <relation type="obsoletes">
83
83
  <bibitem type="standard">
84
84
  <formattedref format="text/plain">ISO 124:2011</formattedref>
85
+ <docidentifier type='ISO' primary='true'>ISO 124:2011</docidentifier>
85
86
  </bibitem>
86
87
  </relation>
87
88
  <place>Geneva</place>
@@ -95,7 +96,7 @@ ISO_124_DATED = <<~XML.freeze
95
96
  <text>Latex and raw rubber</text>
96
97
  </ics>
97
98
  <structuredidentifier type="ISO">
98
- <project-number part="">ISO 124</project-number>
99
+ <project-number>ISO 124</project-number>
99
100
  </structuredidentifier>
100
101
  </ext>
101
102
  </bibdata>
@@ -209,7 +210,7 @@ ISO_123_DATED = <<~XML.freeze
209
210
  <uri type="obp">https://www.iso.org/obp/ui/#!iso:std:23281:en</uri>
210
211
  <uri type="rss">https://www.iso.org/contents/data/standard/02/32/23281.detail.rss</uri>
211
212
  <docidentifier type="ISO" primary="true">ISO 123:2001</docidentifier>
212
- <docidentifier type='URN'>urn:iso:std:iso:123:stage-90.93:ed-3:en</docidentifier>
213
+ <docidentifier type='URN'>urn:iso:std:iso:123:stage-90.93:ed-3</docidentifier>
213
214
  <docnumber>123</docnumber>
214
215
  <date type="published">
215
216
  <on>2001-05</on>
@@ -247,6 +248,7 @@ ISO_123_DATED = <<~XML.freeze
247
248
  <relation type="obsoletes">
248
249
  <bibitem type="standard">
249
250
  <formattedref format="text/plain">ISO 123:1985</formattedref>
251
+ <docidentifier type='ISO' primary='true'>ISO 123:1985</docidentifier>
250
252
  </bibitem>
251
253
  </relation>
252
254
  <place>Geneva</place>
@@ -260,7 +262,7 @@ ISO_123_DATED = <<~XML.freeze
260
262
  <text>Latex and raw rubber</text>
261
263
  </ics>
262
264
  <structuredidentifier type="ISO">
263
- <project-number part="">ISO 123</project-number>
265
+ <project-number>ISO 123</project-number>
264
266
  </structuredidentifier>
265
267
  </ext>
266
268
  </bibdata>
@@ -1706,7 +1706,7 @@ RSpec.describe Metanorma::Standoc do
1706
1706
  <uri type='src'>https://www.iso.org/standard/3944.html</uri>
1707
1707
  <uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
1708
1708
  <docidentifier type='ISO' primary='true'>ISO 131</docidentifier>
1709
- <docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
1709
+ <docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1</docidentifier>
1710
1710
  <docnumber>131</docnumber>
1711
1711
  <contributor>
1712
1712
  <role type='publisher'/>
@@ -1734,6 +1734,7 @@ RSpec.describe Metanorma::Standoc do
1734
1734
  <relation type='obsoletes'>
1735
1735
  <bibitem type='standard'>
1736
1736
  <formattedref format='text/plain'>ISO/R 357:1963</formattedref>
1737
+ <docidentifier type='ISO' primary='true'>ISO/R 357:1963</docidentifier>
1737
1738
  </bibitem>
1738
1739
  </relation>
1739
1740
  <relation type='instance'>
@@ -1748,7 +1749,7 @@ RSpec.describe Metanorma::Standoc do
1748
1749
  <uri type='src'>https://www.iso.org/standard/3944.html</uri>
1749
1750
  <uri type='rss'>https://www.iso.org/contents/data/standard/00/39/3944.detail.rss</uri>
1750
1751
  <docidentifier type='ISO' primary='true'>ISO 131:1979</docidentifier>
1751
- <docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1:en</docidentifier>
1752
+ <docidentifier type='URN'>urn:iso:std:iso:131:stage-95.99:ed-1</docidentifier>
1752
1753
  <docnumber>131</docnumber>
1753
1754
  <date type='published'>
1754
1755
  <on>1979-11</on>
@@ -1779,6 +1780,7 @@ RSpec.describe Metanorma::Standoc do
1779
1780
  <relation type='obsoletes'>
1780
1781
  <bibitem type='standard'>
1781
1782
  <formattedref format='text/plain'>ISO/R 357:1963</formattedref>
1783
+ <docidentifier type='ISO' primary='true'>ISO/R 357:1963</docidentifier>
1782
1784
  </bibitem>
1783
1785
  </relation>
1784
1786
  <place>Geneva</place>