metanorma-standoc 1.3.28 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +8 -7
  3. data/.github/workflows/ubuntu.yml +14 -11
  4. data/.github/workflows/windows.yml +8 -8
  5. data/.gitignore +1 -0
  6. data/lib/asciidoctor/standoc/base.rb +29 -48
  7. data/lib/asciidoctor/standoc/biblio.rng +36 -6
  8. data/lib/asciidoctor/standoc/blocks.rb +32 -96
  9. data/lib/asciidoctor/standoc/blocks_notes.rb +89 -0
  10. data/lib/asciidoctor/standoc/cleanup.rb +12 -6
  11. data/lib/asciidoctor/standoc/cleanup_block.rb +5 -2
  12. data/lib/asciidoctor/standoc/cleanup_inline.rb +1 -1
  13. data/lib/asciidoctor/standoc/cleanup_ref.rb +47 -1
  14. data/lib/asciidoctor/standoc/cleanup_section.rb +8 -125
  15. data/lib/asciidoctor/standoc/cleanup_terms.rb +134 -0
  16. data/lib/asciidoctor/standoc/converter.rb +16 -0
  17. data/lib/asciidoctor/standoc/datamodel/attributes_table_preprocessor.rb +57 -0
  18. data/lib/asciidoctor/standoc/datamodel/diagram_preprocessor.rb +102 -0
  19. data/lib/asciidoctor/standoc/datamodel/plantuml_renderer.rb +408 -0
  20. data/lib/asciidoctor/standoc/inline.rb +11 -6
  21. data/lib/asciidoctor/standoc/isodoc.rng +444 -1
  22. data/lib/asciidoctor/standoc/lists.rb +12 -12
  23. data/lib/asciidoctor/standoc/macros.rb +13 -8
  24. data/lib/asciidoctor/standoc/macros_yaml2text.rb +44 -21
  25. data/lib/asciidoctor/standoc/ref.rb +78 -79
  26. data/lib/asciidoctor/standoc/ref_sect.rb +124 -0
  27. data/lib/asciidoctor/standoc/reqt.rb +11 -6
  28. data/lib/asciidoctor/standoc/reqt.rng +23 -0
  29. data/lib/asciidoctor/standoc/section.rb +2 -46
  30. data/lib/asciidoctor/standoc/table.rb +3 -2
  31. data/lib/asciidoctor/standoc/validate.rb +8 -2
  32. data/lib/asciidoctor/standoc/validate_section.rb +0 -2
  33. data/lib/asciidoctor/standoc/views/datamodel/model_representation.adoc.erb +30 -0
  34. data/lib/asciidoctor/standoc/views/datamodel/plantuml_representation.adoc.erb +20 -0
  35. data/lib/metanorma/standoc/processor.rb +5 -7
  36. data/lib/metanorma/standoc/version.rb +1 -1
  37. data/metanorma-standoc.gemspec +2 -2
  38. data/spec/asciidoctor-standoc/blocks_spec.rb +68 -23
  39. data/spec/asciidoctor-standoc/cleanup_spec.rb +85 -5
  40. data/spec/asciidoctor-standoc/datamodel/attributes_table_preprocessor_spec.rb +111 -0
  41. data/spec/asciidoctor-standoc/datamodel/diagram_preprocessor_spec.rb +72 -0
  42. data/spec/asciidoctor-standoc/inline_spec.rb +7 -3
  43. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +4 -4
  44. data/spec/asciidoctor-standoc/lists_spec.rb +7 -5
  45. data/spec/asciidoctor-standoc/macros_spec.rb +54 -2
  46. data/spec/asciidoctor-standoc/macros_yaml2text_spec.rb +2 -1
  47. data/spec/asciidoctor-standoc/refs_dl_spec.rb +4 -2
  48. data/spec/asciidoctor-standoc/refs_spec.rb +283 -24
  49. data/spec/asciidoctor-standoc/table_spec.rb +3 -3
  50. data/spec/asciidoctor-standoc/validate_spec.rb +77 -7
  51. data/spec/assets/iso123.rxl +107 -0
  52. data/spec/assets/xref_error.adoc +7 -0
  53. data/spec/examples/datamodel/address_class_profile.adoc +4 -0
  54. data/spec/examples/datamodel/address_component_profile.adoc +4 -0
  55. data/spec/examples/datamodel/blank_definition_profile.adoc +4 -0
  56. data/spec/examples/datamodel/common_models_diagram.adoc +4 -0
  57. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +90 -0
  58. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +63 -0
  59. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +15 -0
  60. data/spec/examples/datamodel/models/models/AddressProfile.yml +36 -0
  61. data/spec/examples/datamodel/models/models/AttributeProfile.yml +32 -0
  62. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +79 -0
  63. data/spec/examples/datamodel/models/models/Localization copy.yml +23 -0
  64. data/spec/examples/datamodel/models/models/Localization.yml +23 -0
  65. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +36 -0
  66. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +15 -0
  67. data/spec/examples/datamodel/models/models/Signature.yml +20 -0
  68. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +20 -0
  69. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +16 -0
  70. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +16 -0
  71. data/spec/examples/datamodel/models/models/Validity.yml +14 -0
  72. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +22 -0
  73. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +2 -0
  74. data/spec/examples/datamodel/models/style.uml.inc +37 -0
  75. data/spec/examples/datamodel/models/views/CommonModels.yml +9 -0
  76. data/spec/examples/datamodel/models/views/TopDown.yml +62 -0
  77. data/spec/examples/datamodel/top_down_diagram.adoc +4 -0
  78. data/spec/fixtures/macros_datamodel/address_class_profile.xml +149 -0
  79. data/spec/fixtures/macros_datamodel/address_component_profile.xml +71 -0
  80. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +51 -0
  81. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +7 -0
  82. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +7 -0
  83. data/spec/metanorma/processor_spec.rb +4 -4
  84. data/spec/spec_helper.rb +13 -2
  85. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +85 -85
  86. data/spec/vcr_cassettes/isobib_get_123.yml +19 -198
  87. data/spec/vcr_cassettes/isobib_get_123_1.yml +361 -0
  88. data/spec/vcr_cassettes/isobib_get_123_2001.yml +22 -22
  89. data/spec/vcr_cassettes/isobib_get_124.yml +21 -21
  90. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +10 -10
  91. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +47 -44
  92. metadata +53 -11
@@ -28,9 +28,9 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "asciidoctor", "~> 2.0.0"
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "isodoc", "~> 1.0.20"
31
+ spec.add_dependency "isodoc", "~> 1.1.0"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
- spec.add_dependency "relaton", "~> 1.0.0"
33
+ spec.add_dependency "relaton", "~> 1.2.0"
34
34
  spec.add_dependency "relaton-iev", "~> 1.0.0"
35
35
  spec.add_dependency "sterile", "~> 1.0.14"
36
36
  spec.add_dependency "concurrent-ruby"
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
  require "open3"
3
3
 
4
4
  RSpec.describe Asciidoctor::Standoc do
5
- it "processes pass blocks" do
5
+ it "processes format-specific pass blocks" do
6
6
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
7
7
  #{ASCIIDOC_BLANK_HDR}
8
8
 
@@ -19,6 +19,26 @@ RSpec.describe Asciidoctor::Standoc do
19
19
  OUTPUT
20
20
  end
21
21
 
22
+ it "processes Metanorma XML pass blocks" do
23
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
24
+ #{ASCIIDOC_BLANK_HDR}
25
+
26
+ ++++
27
+ <abc>X &gt;
28
+ ++++
29
+
30
+ ++++
31
+ Y</abc>
32
+ ++++
33
+ INPUT
34
+ #{BLANK_HDR}
35
+ <sections>
36
+ <abc>X &gt; Y</abc>
37
+ </sections>
38
+ </standard-document>
39
+ OUTPUT
40
+ end
41
+
22
42
  it "processes open blocks" do
23
43
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
24
44
  #{ASCIIDOC_BLANK_HDR}
@@ -43,7 +63,7 @@ RSpec.describe Asciidoctor::Standoc do
43
63
  #{ASCIIDOC_BLANK_HDR}
44
64
 
45
65
  [[ABC]]
46
- [stem%inequality]
66
+ [stem%inequality,number=3,keep-with-next=true,keep-lines-together=true]
47
67
  ++++
48
68
  r = 1 %
49
69
  r = 1 %
@@ -67,7 +87,7 @@ RSpec.describe Asciidoctor::Standoc do
67
87
  INPUT
68
88
  #{BLANK_HDR}
69
89
  <sections>
70
- <formula id="ABC" inequality="true">
90
+ <formula id="ABC" inequality="true" number="3" keep-with-next="true" keep-lines-together="true">
71
91
  <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem>
72
92
  </formula>
73
93
 
@@ -76,7 +96,7 @@ RSpec.describe Asciidoctor::Standoc do
76
96
  </formula>
77
97
  <formula id="_" subsequence="A">
78
98
  <stem type="MathML">
79
- <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
99
+ <math xmlns="http://www.w3.org/1998/Math/MathML">
80
100
  <mrow>
81
101
  <mi>M</mi>
82
102
  <mo>=</mo>
@@ -310,6 +330,11 @@ RSpec.describe Asciidoctor::Standoc do
310
330
  === Term1
311
331
 
312
332
  NOTE: This is a note
333
+
334
+ [NOTE,keep-separate=true]
335
+ ====
336
+ XYZ
337
+ ====
313
338
  INPUT
314
339
  #{BLANK_HDR}
315
340
  <sections>
@@ -321,6 +346,9 @@ RSpec.describe Asciidoctor::Standoc do
321
346
  <termnote id="_">
322
347
  <p id="_">This is a note</p>
323
348
  </termnote>
349
+ <termnote id='_'>
350
+ <p id='_'>XYZ</p>
351
+ </termnote>
324
352
  </term>
325
353
  </terms>
326
354
  </sections>
@@ -395,6 +423,11 @@ RSpec.describe Asciidoctor::Standoc do
395
423
 
396
424
  [[ABC]]
397
425
  NOTE: This is a note
426
+
427
+ [NOTE,keep-separate=true,number=7,subsequence=A,beforeclauses=true,keep-with-next=true,keep-lines-together=true,type=classified]
428
+ ====
429
+ XYZ
430
+ ====
398
431
  INPUT
399
432
  #{BLANK_HDR}
400
433
  <preface><foreword id="_" obligation="informative">
@@ -403,6 +436,9 @@ RSpec.describe Asciidoctor::Standoc do
403
436
  <p id="_">This is a note</p>
404
437
  </note>
405
438
  </foreword></preface><sections>
439
+ <note id='_' number="7" subsequence="A" keep-with-next="true" keep-lines-together="true" type="classified">
440
+ <p id='_'>XYZ</p>
441
+ </note>
406
442
  <clause id="_" inline-header="false" obligation="normative">
407
443
  <title>Clause 1</title>
408
444
  <note id="ABC">
@@ -420,7 +456,7 @@ RSpec.describe Asciidoctor::Standoc do
420
456
  #{ASCIIDOC_BLANK_HDR}
421
457
 
422
458
  [[ABC]]
423
- [alt=Literal]
459
+ [alt=Literal,keep-with-next=true,keep-lines-together=true]
424
460
  ....
425
461
  <LITERAL>
426
462
  FIGURATIVE
@@ -428,7 +464,7 @@ RSpec.describe Asciidoctor::Standoc do
428
464
  INPUT
429
465
  #{BLANK_HDR}
430
466
  <sections>
431
- <figure id="ABC">
467
+ <figure id="ABC" keep-with-next="true" keep-lines-together="true">
432
468
  <pre alt="Literal" id="_">&lt;LITERAL&gt;
433
469
  FIGURATIVE
434
470
  </pre>
@@ -461,7 +497,7 @@ RSpec.describe Asciidoctor::Standoc do
461
497
  #{ASCIIDOC_BLANK_HDR}
462
498
 
463
499
  [[ABC]]
464
- [CAUTION,type=Safety Precautions]
500
+ [CAUTION,type=Safety Precautions,keep-with-next="true",keep-lines-together="true"]
465
501
  .Precautions
466
502
  ====
467
503
  While werewolves are hardy community members, keep in mind the following dietary concerns:
@@ -473,7 +509,8 @@ RSpec.describe Asciidoctor::Standoc do
473
509
  INPUT
474
510
  #{BLANK_HDR}
475
511
  <sections>
476
- <admonition id="ABC" type="safety precautions"><name>Precautions</name><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
512
+ <admonition id="ABC" type="safety precautions" keep-with-next="true" keep-lines-together="true">
513
+ <name>Precautions</name><p id="_">While werewolves are hardy community members, keep in mind the following dietary concerns:</p>
477
514
  <ol id="_" type="arabic">
478
515
  <li>
479
516
  <p id="_">They are allergic to cinnamon.</p>
@@ -582,7 +619,7 @@ RSpec.describe Asciidoctor::Standoc do
582
619
  #{ASCIIDOC_BLANK_HDR}
583
620
 
584
621
  [[ABC]]
585
- [example,subsequence=A]
622
+ [example,subsequence=A,keep-with-next=true,keep-lines-together=next]
586
623
  .Title
587
624
  ====
588
625
  This is an example
@@ -594,14 +631,20 @@ RSpec.describe Asciidoctor::Standoc do
594
631
  ====
595
632
  This is another example
596
633
  ====
634
+
635
+ [example,number=3]
636
+ ====
637
+ This is yet another example
638
+ ====
597
639
  INPUT
598
640
  #{BLANK_HDR}
599
641
  <sections>
600
- <example id="ABC" subsequence="A">
642
+ <example id="ABC" subsequence="A" keep-with-next='true' keep-lines-together='next'>
601
643
  <name>Title</name>
602
644
  <p id="_">This is an example</p>
603
645
  <p id="_">Amen</p></example>
604
646
  <example id="_" unnumbered="true"><p id="_">This is another example</p></example>
647
+ <example id="_" number="3"><p id="_">This is yet another example</p></example>
605
648
  </sections>
606
649
  </standard-document>
607
650
  OUTPUT
@@ -725,14 +768,14 @@ RSpec.describe Asciidoctor::Standoc do
725
768
  #{ASCIIDOC_BLANK_HDR}
726
769
 
727
770
  [[ABC]]
728
- [%unnumbered]
771
+ [%unnumbered,number=3]
729
772
  .Split-it-right sample divider
730
773
  image::spec/examples/rice_images/rice_image1.png[alttext]
731
774
 
732
775
  INPUT
733
776
  #{BLANK_HDR}
734
777
  <sections>
735
- <figure id="ABC" unnumbered="true">
778
+ <figure id="ABC" unnumbered="true" number="3">
736
779
  <name>Split-it-right sample divider</name>
737
780
  <image src="spec/examples/rice_images/rice_image1.png" id="_" mimetype="image/png" height="auto" width="auto" alt="alttext"/>
738
781
  </figure>
@@ -824,15 +867,15 @@ RSpec.describe Asciidoctor::Standoc do
824
867
  INPUT
825
868
  end
826
869
 
827
- it "accepts alignment attribute on paragraphs" do
870
+ it "accepts attributes on paragraphs" do
828
871
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
829
872
  #{ASCIIDOC_BLANK_HDR}
830
- [align=right]
873
+ [align=right,keep-with-next=true,keep-lines-together=true]
831
874
  This para is right-aligned.
832
875
  INPUT
833
876
  #{BLANK_HDR}
834
877
  <sections>
835
- <p align="right" id="_">This para is right-aligned.</p>
878
+ <p align="right" id="_" keep-with-next="true" keep-lines-together="true">This para is right-aligned.</p>
836
879
  </sections>
837
880
  </standard-document>
838
881
  OUTPUT
@@ -843,14 +886,14 @@ RSpec.describe Asciidoctor::Standoc do
843
886
  #{ASCIIDOC_BLANK_HDR}
844
887
 
845
888
  [[ABC]]
846
- [quote, ISO, "ISO7301,section 1"]
889
+ [quote, ISO, "ISO7301,section 1",align="right",keep-with-next=true,keep-lines-together=true]
847
890
  ____
848
891
  Block quotation
849
892
  ____
850
893
  INPUT
851
894
  #{BLANK_HDR}
852
895
  <sections>
853
- <quote id="ABC">
896
+ <quote id="ABC" align="right" keep-with-next="true" keep-lines-together="true">
854
897
  <source type="inline" bibitemid="ISO7301" citeas="">
855
898
  <localityStack>
856
899
  <locality type="section"><referenceFrom>1</referenceFrom></locality>
@@ -870,7 +913,7 @@ RSpec.describe Asciidoctor::Standoc do
870
913
 
871
914
  [[ABC]]
872
915
  .Caption
873
- [source%unnumbered,ruby,filename=sourcecode1.rb]
916
+ [source%unnumbered,ruby,number=3,filename=sourcecode1.rb,keep-with-next=true,keep-lines-together=true]
874
917
  --
875
918
  puts "Hello, world."
876
919
  %w{a b c}.each do |x|
@@ -880,7 +923,8 @@ RSpec.describe Asciidoctor::Standoc do
880
923
  INPUT
881
924
  #{BLANK_HDR}
882
925
  <sections>
883
- <sourcecode id="ABC" lang="ruby" filename="sourcecode1.rb" unnumbered="true"><name>Caption</name>puts "Hello, world."
926
+ <sourcecode id="ABC" lang="ruby" filename="sourcecode1.rb" unnumbered="true" number="3" keep-with-next="true" keep-lines-together="true">
927
+ <name>Caption</name>puts "Hello, world."
884
928
  %w{a b c}.each do |x|
885
929
  puts x
886
930
  end</sourcecode>
@@ -1066,7 +1110,7 @@ RSpec.describe Asciidoctor::Standoc do
1066
1110
  input = <<~"INPUT"
1067
1111
  #{ASCIIDOC_BLANK_HDR}
1068
1112
  [[ABC]]
1069
- [.requirement,subsequence="A",inherit="/ss/584/2015/level/1 &amp; /ss/584/2015/level/2"]
1113
+ [.requirement,subsequence="A",inherit="/ss/584/2015/level/1 &amp; /ss/584/2015/level/2",number=3,keep-with-next=true,keep-lines-together=true]
1070
1114
  .Title
1071
1115
  ====
1072
1116
  I recommend this
@@ -1075,7 +1119,8 @@ RSpec.describe Asciidoctor::Standoc do
1075
1119
  output = <<~"OUTPUT"
1076
1120
  #{BLANK_HDR}
1077
1121
  <sections>
1078
- <requirement id="ABC" subsequence="A"><title>Title</title>
1122
+ <requirement id="ABC" subsequence="A" number="3" keep-with-next="true" keep-lines-together="true">
1123
+ <title>Title</title>
1079
1124
  <inherit>/ss/584/2015/level/1 &amp; /ss/584/2015/level/2</inherit>
1080
1125
  <description><p id="_">I recommend this</p></description>
1081
1126
  </requirement>
@@ -1153,7 +1198,7 @@ RSpec.describe Asciidoctor::Standoc do
1153
1198
  ====
1154
1199
  I recommend _this_.
1155
1200
 
1156
- [.specification,type="tabular"]
1201
+ [.specification,type="tabular",keep-with-next=true,keep-lines-together=true]
1157
1202
  --
1158
1203
  This is the object of the recommendation:
1159
1204
  |===
@@ -1201,7 +1246,7 @@ RSpec.describe Asciidoctor::Standoc do
1201
1246
  <recommendation id="ABC" obligation="permission,recommendation" filename="reqt1.rq"><label>/ogc/recommendation/wfs/2</label><subject>user</subject>
1202
1247
  <classification><tag>control-class</tag><value>Technical</value></classification><classification><tag>priority</tag><value>P0</value></classification><classification><tag>family</tag><value>System &amp; Communications Protection</value></classification><classification><tag>family</tag><value>System and Communications Protocols</value></classification>
1203
1248
  <description><p id="_">I recommend <em>this</em>.</p>
1204
- </description><specification exclude="false" type="tabular"><p id="_">This is the object of the recommendation:</p><table id="_"> <tbody> <tr> <td align="left">Object</td> <td align="left">Value</td> </tr> <tr> <td align="left">Mission</td> <td align="left">Accomplished</td> </tr> </tbody></table></specification><description>
1249
+ </description><specification exclude="false" type="tabular" keep-with-next="true" keep-lines-together="true"><p id="_">This is the object of the recommendation:</p><table id="_"> <tbody> <tr> <td align="left">Object</td> <td align="left">Value</td> </tr> <tr> <td align="left">Mission</td> <td align="left">Accomplished</td> </tr> </tbody></table></specification><description>
1205
1250
  <p id="_">As for the measurement targets,</p>
1206
1251
  </description><measurement-target exclude="false"><p id="_">The measurement target shall be measured as:</p><formula id="_"> <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfrac><mi>r</mi><mn>1</mn></mfrac><mo>=</mo><mn>0</mn></math></stem></formula></measurement-target>
1207
1252
  <verification exclude="false"><p id="_">The following code will be run for verification:</p><sourcecode lang="CoreRoot" id="_">CoreRoot(success): HttpResponse
@@ -293,6 +293,35 @@ RSpec.describe Asciidoctor::Standoc do
293
293
  OUTPUT
294
294
  end
295
295
 
296
+ it "does not move notes inside preceding blocks, if they are marked as keep-separate" do
297
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
298
+ #{ASCIIDOC_BLANK_HDR}
299
+
300
+ [stem]
301
+ ++++
302
+ r = 1 %
303
+ r = 1 %
304
+ ++++
305
+
306
+ [NOTE,keep-separate=true]
307
+ ====
308
+ That formula does not do much
309
+ ====
310
+
311
+ Indeed.
312
+ INPUT
313
+ #{BLANK_HDR}
314
+ <sections><formula id="_">
315
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi><mi>r</mi><mo>=</mo><mn>1</mn><mi>%</mi></math></stem></formula>
316
+ <note id="_">
317
+ <p id="_">That formula does not do much</p>
318
+ </note>
319
+
320
+ <p id="_">Indeed.</p></sections>
321
+ </standard-document>
322
+ OUTPUT
323
+ end
324
+
296
325
  it "does not move notes inside preceding blocks, if they are at clause end" do
297
326
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
298
327
  #{ASCIIDOC_BLANK_HDR}
@@ -797,7 +826,7 @@ end
797
826
  INPUT
798
827
  #{BLANK_HDR}
799
828
  <sections><formula id="_">
800
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi><mtext>or</mtext><mi>μ</mi><mi>l</mi><mi>a</mi></math></stem>
829
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi><mi>or</mi><mi>μ</mi><mi>l</mi><mi>a</mi></math></stem>
801
830
  <dl id="_">
802
831
  <dt>a</dt>
803
832
  <dd>
@@ -953,7 +982,7 @@ end
953
982
  <name>ISO</name>
954
983
  </organization>
955
984
  </contributor>
956
- <note format="text/plain">ISO DATE: The standard is in press</note>
985
+ <note format="text/plain" type="ISO DATE">The standard is in press</note>
957
986
  </bibitem>
958
987
  </references>
959
988
  </bibliography>
@@ -1175,7 +1204,7 @@ end
1175
1204
  <fetched>#{Date.today}</fetched>
1176
1205
  <title type="title-main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)</title>
1177
1206
  <title type="title-part" format="text/plain" language="en" script="Latn">Part 102: Mathematics — General concepts and linear algebra</title>
1178
- <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)Part 102: Mathematics — General concepts and linear algebra</title>
1207
+ <title type='main' format='text/plain' language='en' script='Latn'>International Electrotechnical Vocabulary (IEV) — Part 102: Mathematics — General concepts and linear algebra</title>
1179
1208
  <uri type="src">https://webstore.iec.ch/publication/160</uri>
1180
1209
  <uri type="obp">/preview/info_iec60050-102%7Bed1.0%7Db.pdf</uri>
1181
1210
  <docidentifier type="IEC">IEC 60050-102:2007</docidentifier>
@@ -1193,7 +1222,7 @@ end
1193
1222
  <edition>1.0</edition>
1194
1223
  <language>en</language>
1195
1224
  <script>Latn</script>
1196
- <abstract format="text/plain" language="en" script="Latn">This part of IEC 60050 gives the general mathematical terminology used in the fields of electricity, electronics and telecommunications, together with basic concepts in linear algebra. It maintains a clear distinction between mathematical concepts and physical concepts, even if some terms are used in both cases. Another part will deal with functions. It has the status of a horizontal standard in accordance with IEC Guide 108.</abstract>
1225
+ <abstract format="text/plain" language="en" script="Latn">This part of IEC 60050 gives the general mathematical terminology used in the fields of electricity, electronics and telecommunications, together with basic concepts in linear algebra. It maintains a clear distinction between mathematical concepts and physical concepts, even if some terms are used in both cases. Another part will deal with functions.&#13; It has the status of a horizontal standard in accordance with IEC Guide 108.</abstract>
1197
1226
  <status>
1198
1227
  <stage>60</stage>
1199
1228
  <substage>60</substage>
@@ -1213,7 +1242,7 @@ end
1213
1242
  <fetched>#{Date.today}</fetched>
1214
1243
  <title type="title-main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)</title>
1215
1244
  <title type="title-part" format="text/plain" language="en" script="Latn">Part 103: Mathematics — Functions</title>
1216
- <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV)Part 103: Mathematics — Functions</title>
1245
+ <title type="main" format="text/plain" language="en" script="Latn">International Electrotechnical Vocabulary (IEV) — Part 103: Mathematics — Functions</title>
1217
1246
  <uri type="src">https://webstore.iec.ch/publication/161</uri>
1218
1247
  <uri type="obp">/preview/info_iec60050-103%7Bed1.0%7Db.pdf</uri>
1219
1248
  <docidentifier type="IEC">IEC 60050-103:2009</docidentifier>
@@ -1815,6 +1844,57 @@ it "moves inherit macros to correct location" do
1815
1844
  </clause>
1816
1845
  </sections>
1817
1846
  </standard-document>
1847
+ OUTPUT
1848
+ end
1849
+
1850
+ it "moves %beforeclause admonitions to right position" do
1851
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1852
+ #{ASCIIDOC_BLANK_HDR}
1853
+
1854
+ .Foreword
1855
+ Foreword
1856
+
1857
+ [NOTE,beforeclauses=true]
1858
+ ====
1859
+ Note which is very important
1860
+ ====
1861
+
1862
+ == Introduction
1863
+ Introduction
1864
+
1865
+ == Scope
1866
+ Scope statement
1867
+
1868
+ [IMPORTANT,beforeclauses=true]
1869
+ ====
1870
+ Notice which is very important
1871
+ ====
1872
+ INPUT
1873
+ #{BLANK_HDR}
1874
+ <preface>
1875
+ <foreword id='_' obligation='informative'>
1876
+ <title>Foreword</title>
1877
+ <p id='_'>Foreword</p>
1878
+ </foreword>
1879
+ <introduction id='_' obligation='informative'>
1880
+ <title>Introduction</title>
1881
+ <p id='_'>Introduction</p>
1882
+ </introduction>
1883
+ </preface>
1884
+ <sections>
1885
+ <note id='_'>
1886
+ <p id='_'>Note which is very important</p>
1887
+ </note>
1888
+ <admonition id='_' type='important'>
1889
+ <p id='_'>Notice which is very important</p>
1890
+ </admonition>
1891
+ <clause id='_' inline-header='false' obligation='normative'>
1892
+ <title>Scope</title>
1893
+ <p id='_'>Scope statement</p>
1894
+ </clause>
1895
+ </sections>
1896
+ </standard-document>
1897
+
1818
1898
  OUTPUT
1819
1899
  end
1820
1900
 
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Asciidoctor::Standoc::Datamodel::AttributesTablePreprocessor do
6
+ describe '#process' do
7
+ context 'when simple models without relations' do
8
+ let(:datamodel_file) do
9
+ examples_path('datamodel/address_class_profile.adoc')
10
+ end
11
+ let(:result_file) do
12
+ examples_path('datamodel/address_class_profile.xml')
13
+ end
14
+ let(:output) do
15
+ [
16
+ BLANK_HDR,
17
+ File.read(fixtures_path('macros_datamodel/address_class_profile.xml'))
18
+ ]
19
+ .join
20
+ end
21
+
22
+ after do
23
+ %w[doc html xml err].each do |extention|
24
+ path = examples_path("datamodel/address_class_profile.#{extention}")
25
+ FileUtils.rm_f(path)
26
+ FileUtils.rm_f("address_class_profile.#{extention}")
27
+ end
28
+ end
29
+
30
+ it 'correctly renders input' do
31
+ Asciidoctor.convert_file(datamodel_file,
32
+ backend: :standoc,
33
+ safe: :safe,
34
+ header_footer: true)
35
+ expect(xmlpp(strip_guid(File.read(result_file))))
36
+ .to(be_equivalent_to(xmlpp(output)))
37
+ end
38
+ end
39
+
40
+ context 'when complex relations' do
41
+ let(:datamodel_file) do
42
+ examples_path('datamodel/address_component_profile.adoc')
43
+ end
44
+ let(:result_file) do
45
+ examples_path('datamodel/address_component_profile.xml')
46
+ end
47
+ let(:output) do
48
+ path = fixtures_path('macros_datamodel/address_component_profile.xml')
49
+ [
50
+ BLANK_HDR,
51
+ File.read(path)
52
+ ]
53
+ .join("\n")
54
+ end
55
+
56
+ after do
57
+ %w[doc html xml err].each do |extention|
58
+ path = examples_path(
59
+ "datamodel/address_component_profile.#{extention}"
60
+ )
61
+ FileUtils.rm_f(path)
62
+ FileUtils.rm_f("address_component_profile.#{extention}")
63
+ end
64
+ end
65
+
66
+ it 'correctly renders input' do
67
+ Asciidoctor.convert_file(datamodel_file,
68
+ backend: :standoc,
69
+ safe: :safe,
70
+ header_footer: true)
71
+ expect(xmlpp(strip_guid(File.read(result_file))))
72
+ .to(be_equivalent_to(xmlpp(output)))
73
+ end
74
+ end
75
+
76
+ context 'when missing definition' do
77
+ let(:datamodel_file) do
78
+ examples_path('datamodel/blank_definition_profile.adoc')
79
+ end
80
+ let(:result_file) do
81
+ examples_path('datamodel/blank_definition_profile.xml')
82
+ end
83
+ let(:output) do
84
+ path = fixtures_path('macros_datamodel/blank_definition_profile.xml')
85
+ [
86
+ BLANK_HDR,
87
+ File.read(path)
88
+ ].join("\n")
89
+ end
90
+
91
+ after do
92
+ %w[doc html xml err].each do |extention|
93
+ path = examples_path(
94
+ "datamodel/blank_definition_profile.#{extention}"
95
+ )
96
+ FileUtils.rm_f(path)
97
+ FileUtils.rm_f("blank_definition_profile.#{extention}")
98
+ end
99
+ end
100
+
101
+ it 'correctly renders input' do
102
+ Asciidoctor.convert_file(datamodel_file,
103
+ backend: :standoc,
104
+ safe: :safe,
105
+ header_footer: true)
106
+ expect(xmlpp(strip_guid(File.read(result_file))))
107
+ .to(be_equivalent_to(xmlpp(output)))
108
+ end
109
+ end
110
+ end
111
+ end