metanorma-standoc 1.10.6 → 1.11.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +19 -23
  3. data/Rakefile +1 -1
  4. data/lib/asciidoctor/standoc/base.rb +10 -17
  5. data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
  6. data/lib/asciidoctor/standoc/blocks.rb +23 -23
  7. data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
  8. data/lib/asciidoctor/standoc/cleanup.rb +46 -12
  9. data/lib/asciidoctor/standoc/cleanup_block.rb +3 -71
  10. data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
  11. data/lib/asciidoctor/standoc/cleanup_inline.rb +42 -106
  12. data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
  13. data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
  14. data/lib/asciidoctor/standoc/cleanup_reqt.rb +5 -24
  15. data/lib/asciidoctor/standoc/cleanup_section_names.rb +5 -5
  16. data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
  17. data/lib/asciidoctor/standoc/cleanup_table.rb +68 -0
  18. data/lib/asciidoctor/standoc/cleanup_terms.rb +37 -77
  19. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +162 -0
  20. data/lib/asciidoctor/standoc/cleanup_text.rb +5 -2
  21. data/lib/asciidoctor/standoc/cleanup_xref.rb +107 -0
  22. data/lib/asciidoctor/standoc/converter.rb +14 -0
  23. data/lib/asciidoctor/standoc/inline.rb +7 -5
  24. data/lib/asciidoctor/standoc/isodoc.rng +419 -77
  25. data/lib/asciidoctor/standoc/lists.rb +15 -15
  26. data/lib/asciidoctor/standoc/macros.rb +14 -43
  27. data/lib/asciidoctor/standoc/macros_note.rb +45 -0
  28. data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
  29. data/lib/asciidoctor/standoc/macros_terms.rb +55 -8
  30. data/lib/asciidoctor/standoc/ref_sect.rb +26 -18
  31. data/lib/asciidoctor/standoc/reqt.rng +23 -2
  32. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
  33. data/lib/asciidoctor/standoc/terms.rb +12 -2
  34. data/lib/asciidoctor/standoc/utils.rb +36 -23
  35. data/lib/asciidoctor/standoc/validate.rb +45 -27
  36. data/lib/asciidoctor/standoc/validate_section.rb +5 -2
  37. data/lib/metanorma/standoc/version.rb +1 -1
  38. data/metanorma-standoc.gemspec +1 -1
  39. data/spec/asciidoctor/base_spec.rb +4 -36
  40. data/spec/asciidoctor/blank_spec.rb +37 -0
  41. data/spec/asciidoctor/blocks_spec.rb +208 -49
  42. data/spec/asciidoctor/cleanup_sections_spec.rb +153 -12
  43. data/spec/asciidoctor/cleanup_spec.rb +104 -285
  44. data/spec/asciidoctor/cleanup_terms_spec.rb +990 -0
  45. data/spec/asciidoctor/inline_spec.rb +38 -2
  46. data/spec/asciidoctor/lists_spec.rb +6 -6
  47. data/spec/asciidoctor/macros_plantuml_spec.rb +37 -2
  48. data/spec/asciidoctor/macros_spec.rb +191 -114
  49. data/spec/asciidoctor/refs_spec.rb +12 -30
  50. data/spec/asciidoctor/section_spec.rb +18 -18
  51. data/spec/asciidoctor/validate_spec.rb +87 -2
  52. data/spec/fixtures/datamodel_description_sections_tree.xml +3 -2
  53. data/spec/spec_helper.rb +6 -7
  54. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +51 -51
  55. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
  56. data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
  57. data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
  58. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +34 -34
  59. data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
  60. data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
  61. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +16 -16
  62. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +51 -49
  63. metadata +12 -5
@@ -125,7 +125,7 @@ RSpec.describe Asciidoctor::Standoc do
125
125
  <p id="_">For the purposes of this document,
126
126
  the following terms and definitions apply.</p>
127
127
  <term id="term-term1">
128
- <preferred>Term1</preferred>
128
+ <preferred><expression><name>Term1</name></expression></preferred>
129
129
  </term>
130
130
  </terms>
131
131
  <clause id="_" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title>
@@ -147,14 +147,14 @@ RSpec.describe Asciidoctor::Standoc do
147
147
  <terms id="_" obligation="normative">
148
148
  <title>Intro 5</title>
149
149
  <term id="term-term1-1">
150
- <preferred>Term1</preferred>
150
+ <preferred><expression><name>Term1</name></expression></preferred>
151
151
  </term>
152
152
  </terms>
153
153
  </clause>
154
154
  <terms id="_" obligation="normative">
155
155
  <title>Normal Terms</title>
156
156
  <term id="term-term2">
157
- <preferred>Term2</preferred>
157
+ <preferred><expression><name>Term2</name></expression></preferred>
158
158
  </term>
159
159
  </terms>
160
160
  <definitions id="_" obligation="normative"><title>Symbols and abbreviated terms</title><clause id="_" inline-header="false" obligation="normative">
@@ -278,7 +278,7 @@ RSpec.describe Asciidoctor::Standoc do
278
278
  <title>Terms and definitions</title>
279
279
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
280
280
  <term id='term-term1' number='4bis'>
281
- <preferred>Term1</preferred>
281
+ <preferred><expression><name>Term1</name></expression></preferred>
282
282
  </term>
283
283
  </terms>
284
284
  <terms id='_' number='5bis' obligation='normative'>
@@ -291,7 +291,7 @@ RSpec.describe Asciidoctor::Standoc do
291
291
  </clause>
292
292
  </clause>
293
293
  <term id='term-intro-2' number='8bis'>
294
- <preferred>Intro 2</preferred>
294
+ <preferred><expression><name>Intro 2</name></expression></preferred>
295
295
  </term>
296
296
  <definitions id='_' number='9bis' obligation='normative'>
297
297
  <title>Symbols and abbreviated terms</title>
@@ -478,7 +478,7 @@ RSpec.describe Asciidoctor::Standoc do
478
478
  <p id="_">For the purposes of this document,
479
479
  the following terms and definitions apply.</p>
480
480
  <term id="term-term1" language="en" script="Latn">
481
- <preferred>Term1</preferred>
481
+ <preferred><expression><name>Term1</name></expression></preferred>
482
482
  </term>
483
483
  </terms>
484
484
  <clause id="_" language="en" script="Latn" obligation="normative"><title>Terms, definitions, symbols and abbreviated terms</title>
@@ -500,14 +500,14 @@ RSpec.describe Asciidoctor::Standoc do
500
500
  <terms id="_" language="en" script="Latn" obligation="normative">
501
501
  <title>Intro 5</title>
502
502
  <term id="term-term1-1">
503
- <preferred>Term1</preferred>
503
+ <preferred><expression><name>Term1</name></expression></preferred>
504
504
  </term>
505
505
  </terms>
506
506
  </clause>
507
507
  <terms id="_" language="en" script="Latn" obligation="normative">
508
508
  <title>Normal Terms</title>
509
509
  <term id="term-term2">
510
- <preferred>Term2</preferred>
510
+ <preferred><expression><name>Term2</name></expression></preferred>
511
511
  </term>
512
512
  </terms>
513
513
  <definitions id="_" language="en" script="Latn" obligation="normative"><title>Symbols and abbreviated terms</title><clause id="_" language="en" script="Latn" inline-header="false" obligation="normative">
@@ -633,7 +633,7 @@ RSpec.describe Asciidoctor::Standoc do
633
633
  <title>Terms and definitions</title>
634
634
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
635
635
  <term id='term-term1'>
636
- <preferred>Term1</preferred>
636
+ <preferred><expression><name>Term1</name></expression></preferred>
637
637
  </term>
638
638
  </terms>
639
639
  <clause id='_' obligation='normative'>
@@ -642,7 +642,7 @@ RSpec.describe Asciidoctor::Standoc do
642
642
  <terms id='_' obligation='normative'>
643
643
  <title>Normal Terms</title>
644
644
  <term id='term-term2'>
645
- <preferred>Term2</preferred>
645
+ <preferred><expression><name>Term2</name></expression></preferred>
646
646
  </term>
647
647
  </terms>
648
648
  <definitions id='_' obligation="normative" type="symbols">
@@ -704,7 +704,7 @@ RSpec.describe Asciidoctor::Standoc do
704
704
  <title>Terms, definitions and symbols</title>
705
705
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
706
706
  <term id='term-term'>
707
- <preferred>Term</preferred>
707
+ <preferred><expression><name>Term</name></expression></preferred>
708
708
  </term>
709
709
  <definitions id='_' obligation="normative" type="symbols">
710
710
  <title>Symbols</title>
@@ -736,7 +736,7 @@ RSpec.describe Asciidoctor::Standoc do
736
736
  <title>Terms, definitions and abbreviated terms</title>
737
737
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
738
738
  <term id='term-term'>
739
- <preferred>Term</preferred>
739
+ <preferred><expression><name>Term</name></expression></preferred>
740
740
  </term>
741
741
  <definitions id='_' obligation="normative" type="abbreviated_terms">
742
742
  <title>Abbreviated terms</title>
@@ -769,7 +769,7 @@ RSpec.describe Asciidoctor::Standoc do
769
769
  <title>Terms, definitions, symbols and abbreviated terms</title>
770
770
  <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
771
771
  <term id='term-term'>
772
- <preferred>Term</preferred>
772
+ <preferred><expression><name>Term</name></expression></preferred>
773
773
  </term>
774
774
  <definitions id='_' type='abbreviated_terms' obligation='normative'>
775
775
  <title>Abbreviated terms</title>
@@ -930,7 +930,7 @@ RSpec.describe Asciidoctor::Standoc do
930
930
  <title>Terms and definitions</title><p id="_">For the purposes of this document, the terms and definitions
931
931
  given in <eref bibitemid="iso1234"/> and <eref bibitemid="iso5678"/> and the following apply.</p>
932
932
  <term id="term-term1">
933
- <preferred>Term1</preferred>
933
+ <preferred><expression><name>Term1</name></expression></preferred>
934
934
  </term>
935
935
  </terms></sections>
936
936
  </standard-document>
@@ -1136,8 +1136,8 @@ RSpec.describe Asciidoctor::Standoc do
1136
1136
  <terms id='terms-concepts' obligation='normative'>
1137
1137
  <title>Basic concepts</title>
1138
1138
  <term id='term-date'>
1139
- <preferred>date</preferred>
1140
- <definition>
1139
+ <preferred><expression><name>date</name></expression></preferred>
1140
+ <definition><verbaldefinition>
1141
1141
  <p id='_'>
1142
1142
  <em>time</em>
1143
1143
  (
@@ -1152,7 +1152,7 @@ RSpec.describe Asciidoctor::Standoc do
1152
1152
  <xref target='term-time-scale'/>
1153
1153
  )
1154
1154
  </p>
1155
- </definition>
1155
+ </verbaldefinition></definition>
1156
1156
  </term>
1157
1157
  </terms>
1158
1158
  </clause>
@@ -1190,7 +1190,7 @@ RSpec.describe Asciidoctor::Standoc do
1190
1190
  <terms id='t1' obligation='normative'>
1191
1191
  <title>Terms and definitions</title>
1192
1192
  <term id='t2'>
1193
- <preferred>Term1</preferred>
1193
+ <preferred><expression><name>Term1</name></expression></preferred>
1194
1194
  </term>
1195
1195
  </terms>
1196
1196
  </preface>
@@ -329,7 +329,8 @@ RSpec.describe Asciidoctor::Standoc do
329
329
  INPUT
330
330
  expect(File.read("test.err"))
331
331
  .not_to include "does not match IEV 103-01-02"
332
- FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
332
+ FileUtils.mv File.expand_path("~/.iev.pstore1"),
333
+ File.expand_path("~/.iev/cache"), force: true
333
334
  end
334
335
 
335
336
  # it "No warning if attributes on formatted strong or stem extraneous to Metanomra XML" do
@@ -355,7 +356,9 @@ RSpec.describe Asciidoctor::Standoc do
355
356
 
356
357
  {{<<def>>,term,option="noital"}}
357
358
  INPUT
358
- expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(RuntimeError)
359
+ expect do
360
+ Asciidoctor.convert(input, *OPTIONS)
361
+ end.to raise_error(RuntimeError)
359
362
  rescue SystemExit, RuntimeError
360
363
  end
361
364
  expect(File.read("test.err"))
@@ -396,6 +399,39 @@ RSpec.describe Asciidoctor::Standoc do
396
399
  expect(File.exist?("test.xml")).to be false
397
400
  end
398
401
 
402
+ it "warns and aborts if related/xref does not point to term or definition" do
403
+ FileUtils.rm_f "test.xml"
404
+ FileUtils.rm_f "test.err"
405
+ begin
406
+ input = <<~INPUT
407
+ = Document title
408
+ Author
409
+ :docfile: test.adoc
410
+ :nodoc:
411
+
412
+ [[abc]]
413
+ == Clause 1
414
+ [[ghi]]A:: B
415
+
416
+ == Symbols and Abbreviated Terms
417
+ [[def]]DEF:: def
418
+
419
+ related:see[<<abc>>,term]
420
+ related:see[<<def>>,term]
421
+ related:see[<<ghi>>,term]
422
+ INPUT
423
+ expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
424
+ rescue SystemExit
425
+ end
426
+ expect(File.read("test.err"))
427
+ .to include "Related term is pointing to abc, which is not a term or symbol"
428
+ expect(File.read("test.err"))
429
+ .not_to include "Related term is pointing to def, which is not a term or symbol"
430
+ expect(File.read("test.err"))
431
+ .to include "Related term is pointing to ghi, which is not a term or symbol"
432
+ expect(File.exist?("test.xml")).to be false
433
+ end
434
+
399
435
  it "warns and aborts if id used twice" do
400
436
  FileUtils.rm_f "test.xml"
401
437
  FileUtils.rm_f "test.err"
@@ -490,4 +526,53 @@ RSpec.describe Asciidoctor::Standoc do
490
526
  expect(File.read("test.err"))
491
527
  .to include "Could not resolve footnoteblock:[id1]"
492
528
  end
529
+
530
+ it "Warning if xref/@target does not point to a real identifier" do
531
+ FileUtils.rm_f "test.err"
532
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
533
+ = Document title
534
+ Author
535
+ :docfile: test.adoc
536
+ :no-pdf:
537
+
538
+ <<id1>>
539
+
540
+ [[id2]]
541
+ [NOTE]
542
+ --
543
+ |===
544
+ |a |b
545
+
546
+ |c |d
547
+ |===
548
+
549
+ * A
550
+ * B
551
+ * C
552
+ --
553
+ INPUT
554
+ expect(File.read("test.err"))
555
+ .to include "Crossreference target id1 is undefined"
556
+ end
557
+
558
+ it "Warning if metadata deflist not after a designation" do
559
+ FileUtils.rm_f "test.err"
560
+ Asciidoctor.convert(<<~"INPUT", *OPTIONS)
561
+ = Document title
562
+ Author
563
+ :docfile: test.adoc
564
+ :no-pdf:
565
+
566
+ == Terms and definitions
567
+
568
+ === Term 1
569
+
570
+ Definition
571
+
572
+ [%metadata]
573
+ language:: fr
574
+ INPUT
575
+ expect(File.read("test.err"))
576
+ .to include "Metadata definition list does not follow a term designation"
577
+ end
493
578
  end
@@ -37,7 +37,7 @@
37
37
  <table id='section-EAID_82206E96_8D23_48dd_AC2F_31939C484AF2' width='100%'>
38
38
  <name>
39
39
  Elements of &#8220;ISO 19135 Procedures for item registration
40
- XML::RE_Register&#8221; (class)
40
+ XML::RE_Register&#8221; (interface)
41
41
  </name>
42
42
  <tbody>
43
43
  <tr>
@@ -288,7 +288,7 @@
288
288
  as its value a set of URI&#8217;s, each referencing
289
289
  information about online resources associated with the
290
290
  register. EXAMPLE
291
- &#239;&#191;&#189;http://www.digest.org/Navigate2.htm&#239;&#191;
291
+ &#239;&#191;&#189;http://www.digest.org/Navigate2.htm&#239;&#191;&#189; and &#239;&#191;&#189;http://www.epa.gov/opppmsd1/PPISdata/index.html&#239;&#191;&#189; are sample valuescorresponding value of the attribute
292
292
  <em>OnLineResource.linkage</em>
293
293
  specifies a resource providing access to the complete
294
294
  content of the register. EXAMPLE
@@ -313,6 +313,7 @@
313
313
  <td colspan='7' valign='top' align='left'>
314
314
  <p id='_'>
315
315
  <tt>count(self.version +self.dateOfLastChange) &gt;= 1</tt>
316
+ : ``
316
317
  </p>
317
318
  </td>
318
319
  </tr>
data/spec/spec_helper.rb CHANGED
@@ -40,11 +40,9 @@ RSpec.configure do |config|
40
40
  end
41
41
 
42
42
  config.around :each do |example|
43
- begin
44
- example.run
45
- rescue SystemExit
46
- fail "Unexpected exit encountered"
47
- end
43
+ example.run
44
+ rescue SystemExit
45
+ fail "Unexpected exit encountered"
48
46
  end
49
47
  end
50
48
 
@@ -74,6 +72,7 @@ ASCIIDOC_BLANK_HDR = <<~"HDR".freeze
74
72
  :nodoc:
75
73
  :novalid:
76
74
  :no-isobib:
75
+ :data-uri-image: false
77
76
 
78
77
  HDR
79
78
 
@@ -231,7 +230,7 @@ def stub_fetch_ref(**opts)
231
230
  xml = ""
232
231
 
233
232
  hit = double("hit")
234
- expect(hit).to receive(:"[]").with("title") do
233
+ expect(hit).to receive(:[]).with("title") do
235
234
  Nokogiri::XML(xml).at("//docidentifier").content
236
235
  end.at_least(:once)
237
236
 
@@ -261,7 +260,7 @@ end
261
260
  private
262
261
 
263
262
  def get_xml(search, code, opts)
264
- c = code.gsub(%r{[\/\s:-]}, "_").sub(%r{_+$}, "").downcase
263
+ c = code.gsub(%r{[/\s:-]}, "_").sub(%r{_+$}, "").downcase
265
264
  o = opts.keys.join "_"
266
265
  file = examples_path("#{[c, o].join '_'}.xml")
267
266
  if File.exist? file