metanorma-standoc 1.10.8 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/lib/asciidoctor/standoc/base.rb +5 -4
  4. data/lib/asciidoctor/standoc/cleanup.rb +20 -11
  5. data/lib/asciidoctor/standoc/cleanup_inline.rb +20 -7
  6. data/lib/asciidoctor/standoc/cleanup_maths.rb +5 -6
  7. data/lib/asciidoctor/standoc/cleanup_reqt.rb +2 -21
  8. data/lib/asciidoctor/standoc/cleanup_symbols.rb +48 -0
  9. data/lib/asciidoctor/standoc/cleanup_terms.rb +37 -77
  10. data/lib/asciidoctor/standoc/cleanup_terms_designations.rb +162 -0
  11. data/lib/asciidoctor/standoc/converter.rb +2 -0
  12. data/lib/asciidoctor/standoc/inline.rb +7 -5
  13. data/lib/asciidoctor/standoc/isodoc.rng +218 -27
  14. data/lib/asciidoctor/standoc/macros_plantuml.rb +29 -14
  15. data/lib/asciidoctor/standoc/macros_terms.rb +49 -5
  16. data/lib/asciidoctor/standoc/ref_sect.rb +24 -17
  17. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +50 -11
  18. data/lib/asciidoctor/standoc/terms.rb +12 -2
  19. data/lib/asciidoctor/standoc/utils.rb +36 -23
  20. data/lib/asciidoctor/standoc/validate.rb +24 -15
  21. data/lib/metanorma/standoc/version.rb +1 -1
  22. data/metanorma-standoc.gemspec +1 -1
  23. data/spec/asciidoctor/base_spec.rb +4 -3
  24. data/spec/asciidoctor/blocks_spec.rb +149 -21
  25. data/spec/asciidoctor/cleanup_sections_spec.rb +7 -7
  26. data/spec/asciidoctor/cleanup_spec.rb +21 -195
  27. data/spec/asciidoctor/cleanup_terms_spec.rb +990 -0
  28. data/spec/asciidoctor/inline_spec.rb +2 -2
  29. data/spec/asciidoctor/macros_plantuml_spec.rb +36 -1
  30. data/spec/asciidoctor/macros_spec.rb +189 -112
  31. data/spec/asciidoctor/refs_spec.rb +2 -24
  32. data/spec/asciidoctor/section_spec.rb +18 -18
  33. data/spec/asciidoctor/validate_spec.rb +59 -2
  34. data/spec/spec_helper.rb +1 -0
  35. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +46 -46
  36. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +12 -12
  37. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  38. data/spec/vcr_cassettes/isobib_get_123_1.yml +26 -26
  39. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +32 -32
  40. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  41. data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
  42. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  43. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -65
  44. metadata +8 -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"
@@ -518,4 +554,25 @@ RSpec.describe Asciidoctor::Standoc do
518
554
  expect(File.read("test.err"))
519
555
  .to include "Crossreference target id1 is undefined"
520
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
521
578
  end
data/spec/spec_helper.rb CHANGED
@@ -72,6 +72,7 @@ ASCIIDOC_BLANK_HDR = <<~"HDR".freeze
72
72
  :nodoc:
73
73
  :novalid:
74
74
  :no-isobib:
75
+ :data-uri-image: false
75
76
 
76
77
  HDR
77
78