metanorma-standoc 1.10.7 → 1.10.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +19 -23
  3. data/lib/asciidoctor/standoc/base.rb +2 -0
  4. data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
  5. data/lib/asciidoctor/standoc/blocks.rb +23 -23
  6. data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
  7. data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
  8. data/lib/asciidoctor/standoc/cleanup_inline.rb +25 -0
  9. data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
  10. data/lib/asciidoctor/standoc/isodoc.rng +192 -50
  11. data/lib/asciidoctor/standoc/lists.rb +15 -15
  12. data/lib/asciidoctor/standoc/macros_terms.rb +6 -3
  13. data/lib/asciidoctor/standoc/reqt.rng +23 -2
  14. data/lib/asciidoctor/standoc/validate.rb +23 -14
  15. data/lib/asciidoctor/standoc/validate_section.rb +5 -2
  16. data/lib/metanorma/standoc/version.rb +1 -1
  17. data/spec/asciidoctor/blocks_spec.rb +28 -28
  18. data/spec/asciidoctor/cleanup_spec.rb +83 -90
  19. data/spec/asciidoctor/lists_spec.rb +6 -6
  20. data/spec/asciidoctor/macros_spec.rb +1 -1
  21. data/spec/asciidoctor/refs_spec.rb +2 -2
  22. data/spec/asciidoctor/validate_spec.rb +28 -0
  23. data/spec/spec_helper.rb +5 -7
  24. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +41 -41
  25. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
  26. data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
  27. data/spec/vcr_cassettes/isobib_get_123_1.yml +21 -21
  28. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +29 -29
  29. data/spec/vcr_cassettes/isobib_get_123_2001.yml +11 -11
  30. data/spec/vcr_cassettes/isobib_get_124.yml +10 -10
  31. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
  32. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +64 -44
  33. metadata +2 -2
@@ -62,7 +62,9 @@
62
62
  <data type="boolean"/>
63
63
  </attribute>
64
64
  </optional>
65
- <text/>
65
+ <oneOrMore>
66
+ <ref name="PureTextElement"/>
67
+ </oneOrMore>
66
68
  </element>
67
69
  </define>
68
70
  <define name="xref">
@@ -100,7 +102,9 @@
100
102
  <data type="boolean"/>
101
103
  </attribute>
102
104
  </optional>
103
- <text/>
105
+ <oneOrMore>
106
+ <ref name="PureTextElement"/>
107
+ </oneOrMore>
104
108
  </element>
105
109
  </define>
106
110
  <define name="erefType">
@@ -130,7 +134,9 @@
130
134
  </attribute>
131
135
  </optional>
132
136
  <ref name="CitationType"/>
133
- <text/>
137
+ <oneOrMore>
138
+ <ref name="PureTextElement"/>
139
+ </oneOrMore>
134
140
  </define>
135
141
  <define name="ul">
136
142
  <element name="ul">
@@ -147,6 +153,14 @@
147
153
  <data type="boolean"/>
148
154
  </attribute>
149
155
  </optional>
156
+ <optional>
157
+ <attribute name="tag"/>
158
+ </optional>
159
+ <optional>
160
+ <attribute name="multilingual-rendering">
161
+ <ref name="MultilingualRenderingType"/>
162
+ </attribute>
163
+ </optional>
150
164
  <oneOrMore>
151
165
  <ref name="ul_li"/>
152
166
  </oneOrMore>
@@ -170,6 +184,14 @@
170
184
  <data type="boolean"/>
171
185
  </attribute>
172
186
  </optional>
187
+ <optional>
188
+ <attribute name="tag"/>
189
+ </optional>
190
+ <optional>
191
+ <attribute name="multilingual-rendering">
192
+ <ref name="MultilingualRenderingType"/>
193
+ </attribute>
194
+ </optional>
173
195
  <optional>
174
196
  <attribute name="type">
175
197
  <choice>
@@ -209,6 +231,14 @@
209
231
  <data type="boolean"/>
210
232
  </attribute>
211
233
  </optional>
234
+ <optional>
235
+ <attribute name="tag"/>
236
+ </optional>
237
+ <optional>
238
+ <attribute name="multilingual-rendering">
239
+ <ref name="MultilingualRenderingType"/>
240
+ </attribute>
241
+ </optional>
212
242
  <oneOrMore>
213
243
  <ref name="dt"/>
214
244
  <ref name="dd"/>
@@ -256,6 +286,14 @@
256
286
  <data type="boolean"/>
257
287
  </attribute>
258
288
  </optional>
289
+ <optional>
290
+ <attribute name="tag"/>
291
+ </optional>
292
+ <optional>
293
+ <attribute name="multilingual-rendering">
294
+ <ref name="MultilingualRenderingType"/>
295
+ </attribute>
296
+ </optional>
259
297
  <optional>
260
298
  <ref name="tname"/>
261
299
  </optional>
@@ -316,6 +354,14 @@
316
354
  <optional>
317
355
  <attribute name="width"/>
318
356
  </optional>
357
+ <optional>
358
+ <attribute name="tag"/>
359
+ </optional>
360
+ <optional>
361
+ <attribute name="multilingual-rendering">
362
+ <ref name="MultilingualRenderingType"/>
363
+ </attribute>
364
+ </optional>
319
365
  <optional>
320
366
  <ref name="colgroup"/>
321
367
  </optional>
@@ -366,6 +412,14 @@
366
412
  <optional>
367
413
  <attribute name="class"/>
368
414
  </optional>
415
+ <optional>
416
+ <attribute name="tag"/>
417
+ </optional>
418
+ <optional>
419
+ <attribute name="multilingual-rendering">
420
+ <ref name="MultilingualRenderingType"/>
421
+ </attribute>
422
+ </optional>
369
423
  <optional>
370
424
  <ref name="source"/>
371
425
  </optional>
@@ -424,6 +478,14 @@
424
478
  <optional>
425
479
  <attribute name="lang"/>
426
480
  </optional>
481
+ <optional>
482
+ <attribute name="tag"/>
483
+ </optional>
484
+ <optional>
485
+ <attribute name="multilingual-rendering">
486
+ <ref name="MultilingualRenderingType"/>
487
+ </attribute>
488
+ </optional>
427
489
  <optional>
428
490
  <ref name="tname"/>
429
491
  </optional>
@@ -472,6 +534,14 @@
472
534
  <data type="boolean"/>
473
535
  </attribute>
474
536
  </optional>
537
+ <optional>
538
+ <attribute name="tag"/>
539
+ </optional>
540
+ <optional>
541
+ <attribute name="multilingual-rendering">
542
+ <ref name="MultilingualRenderingType"/>
543
+ </attribute>
544
+ </optional>
475
545
  <ref name="stem"/>
476
546
  <optional>
477
547
  <ref name="dl"/>
@@ -500,6 +570,14 @@
500
570
  <data type="boolean"/>
501
571
  </attribute>
502
572
  </optional>
573
+ <optional>
574
+ <attribute name="tag"/>
575
+ </optional>
576
+ <optional>
577
+ <attribute name="multilingual-rendering">
578
+ <ref name="MultilingualRenderingType"/>
579
+ </attribute>
580
+ </optional>
503
581
  <zeroOrMore>
504
582
  <ref name="TextElement"/>
505
583
  </zeroOrMore>
@@ -527,6 +605,14 @@
527
605
  <data type="boolean"/>
528
606
  </attribute>
529
607
  </optional>
608
+ <optional>
609
+ <attribute name="tag"/>
610
+ </optional>
611
+ <optional>
612
+ <attribute name="multilingual-rendering">
613
+ <ref name="MultilingualRenderingType"/>
614
+ </attribute>
615
+ </optional>
530
616
  <zeroOrMore>
531
617
  <choice>
532
618
  <ref name="TextElement"/>
@@ -558,6 +644,14 @@
558
644
  <data type="boolean"/>
559
645
  </attribute>
560
646
  </optional>
647
+ <optional>
648
+ <attribute name="tag"/>
649
+ </optional>
650
+ <optional>
651
+ <attribute name="multilingual-rendering">
652
+ <ref name="MultilingualRenderingType"/>
653
+ </attribute>
654
+ </optional>
561
655
  <optional>
562
656
  <ref name="quote-source"/>
563
657
  </optional>
@@ -624,9 +718,6 @@
624
718
  <zeroOrMore>
625
719
  <ref name="BasicBlock"/>
626
720
  </zeroOrMore>
627
- <zeroOrMore>
628
- <ref name="note"/>
629
- </zeroOrMore>
630
721
  <zeroOrMore>
631
722
  <ref name="bibitem"/>
632
723
  <zeroOrMore>
@@ -667,6 +758,14 @@
667
758
  <optional>
668
759
  <attribute name="type"/>
669
760
  </optional>
761
+ <optional>
762
+ <attribute name="tag"/>
763
+ </optional>
764
+ <optional>
765
+ <attribute name="multilingual-rendering">
766
+ <ref name="MultilingualRenderingType"/>
767
+ </attribute>
768
+ </optional>
670
769
  <oneOrMore>
671
770
  <choice>
672
771
  <ref name="paragraph"/>
@@ -703,14 +802,9 @@
703
802
  <optional>
704
803
  <ref name="section-title"/>
705
804
  </optional>
706
- <group>
707
- <oneOrMore>
708
- <ref name="BasicBlock"/>
709
- </oneOrMore>
710
- <zeroOrMore>
711
- <ref name="note"/>
712
- </zeroOrMore>
713
- </group>
805
+ <oneOrMore>
806
+ <ref name="BasicBlock"/>
807
+ </oneOrMore>
714
808
  </define>
715
809
  <define name="li">
716
810
  <element name="li">
@@ -845,6 +939,9 @@
845
939
  <ref name="PureTextElement"/>
846
940
  <ref name="stem"/>
847
941
  <ref name="index"/>
942
+ <ref name="eref"/>
943
+ <ref name="xref"/>
944
+ <ref name="hyperlink"/>
848
945
  </choice>
849
946
  </zeroOrMore>
850
947
  </element>
@@ -856,6 +953,9 @@
856
953
  <ref name="PureTextElement"/>
857
954
  <ref name="stem"/>
858
955
  <ref name="index"/>
956
+ <ref name="eref"/>
957
+ <ref name="xref"/>
958
+ <ref name="hyperlink"/>
859
959
  </choice>
860
960
  </zeroOrMore>
861
961
  </element>
@@ -866,6 +966,9 @@
866
966
  <choice>
867
967
  <ref name="PureTextElement"/>
868
968
  <ref name="index"/>
969
+ <ref name="eref"/>
970
+ <ref name="xref"/>
971
+ <ref name="hyperlink"/>
869
972
  </choice>
870
973
  </zeroOrMore>
871
974
  </element>
@@ -924,6 +1027,14 @@
924
1027
  </define>
925
1028
  </include>
926
1029
  <!-- end overrides -->
1030
+ <define name="MultilingualRenderingType">
1031
+ <choice>
1032
+ <value>common</value>
1033
+ <value>all-columns</value>
1034
+ <value>parallel</value>
1035
+ <value>tag</value>
1036
+ </choice>
1037
+ </define>
927
1038
  <define name="docsubtype">
928
1039
  <element name="subdoctype">
929
1040
  <ref name="DocumentSubtype"/>
@@ -1062,6 +1173,14 @@
1062
1173
  <optional>
1063
1174
  <attribute name="class"/>
1064
1175
  </optional>
1176
+ <optional>
1177
+ <attribute name="tag"/>
1178
+ </optional>
1179
+ <optional>
1180
+ <attribute name="multilingual-rendering">
1181
+ <ref name="MultilingualRenderingType"/>
1182
+ </attribute>
1183
+ </optional>
1065
1184
  <zeroOrMore>
1066
1185
  <choice>
1067
1186
  <ref name="TextElement"/>
@@ -1261,9 +1380,6 @@
1261
1380
  <zeroOrMore>
1262
1381
  <ref name="BasicBlock"/>
1263
1382
  </zeroOrMore>
1264
- <zeroOrMore>
1265
- <ref name="note"/>
1266
- </zeroOrMore>
1267
1383
  <choice>
1268
1384
  <oneOrMore>
1269
1385
  <ref name="reference-clause"/>
@@ -1446,9 +1562,6 @@
1446
1562
  <zeroOrMore>
1447
1563
  <ref name="BasicBlock"/>
1448
1564
  </zeroOrMore>
1449
- <zeroOrMore>
1450
- <ref name="note"/>
1451
- </zeroOrMore>
1452
1565
  <ref name="dl"/>
1453
1566
  </oneOrMore>
1454
1567
  </element>
@@ -1508,14 +1621,9 @@
1508
1621
  <ref name="section-title"/>
1509
1622
  </optional>
1510
1623
  <group>
1511
- <group>
1512
- <zeroOrMore>
1513
- <ref name="BasicBlock"/>
1514
- </zeroOrMore>
1515
- <zeroOrMore>
1516
- <ref name="note"/>
1517
- </zeroOrMore>
1518
- </group>
1624
+ <zeroOrMore>
1625
+ <ref name="BasicBlock"/>
1626
+ </zeroOrMore>
1519
1627
  <zeroOrMore>
1520
1628
  <ref name="content-subsection"/>
1521
1629
  </zeroOrMore>
@@ -1562,14 +1670,9 @@
1562
1670
  </optional>
1563
1671
  <choice>
1564
1672
  <choice>
1565
- <group>
1566
- <oneOrMore>
1567
- <ref name="BasicBlock"/>
1568
- </oneOrMore>
1569
- <zeroOrMore>
1570
- <ref name="note"/>
1571
- </zeroOrMore>
1572
- </group>
1673
+ <oneOrMore>
1674
+ <ref name="BasicBlock"/>
1675
+ </oneOrMore>
1573
1676
  <ref name="amend"/>
1574
1677
  </choice>
1575
1678
  <oneOrMore>
@@ -1610,14 +1713,9 @@
1610
1713
  <ref name="section-title"/>
1611
1714
  </optional>
1612
1715
  <group>
1613
- <group>
1614
- <zeroOrMore>
1615
- <ref name="BasicBlock"/>
1616
- </zeroOrMore>
1617
- <zeroOrMore>
1618
- <ref name="note"/>
1619
- </zeroOrMore>
1620
- </group>
1716
+ <zeroOrMore>
1717
+ <ref name="BasicBlock"/>
1718
+ </zeroOrMore>
1621
1719
  <zeroOrMore>
1622
1720
  <choice>
1623
1721
  <ref name="annex-subsection"/>
@@ -1676,9 +1774,6 @@
1676
1774
  <zeroOrMore>
1677
1775
  <ref name="BasicBlock"/>
1678
1776
  </zeroOrMore>
1679
- <zeroOrMore>
1680
- <ref name="note"/>
1681
- </zeroOrMore>
1682
1777
  <choice>
1683
1778
  <oneOrMore>
1684
1779
  <ref name="term"/>
@@ -1824,6 +1919,14 @@
1824
1919
  <data type="boolean"/>
1825
1920
  </attribute>
1826
1921
  </optional>
1922
+ <optional>
1923
+ <attribute name="tag"/>
1924
+ </optional>
1925
+ <optional>
1926
+ <attribute name="multilingual-rendering">
1927
+ <ref name="MultilingualRenderingType"/>
1928
+ </attribute>
1929
+ </optional>
1827
1930
  <oneOrMore>
1828
1931
  <choice>
1829
1932
  <ref name="paragraph"/>
@@ -1840,6 +1943,24 @@
1840
1943
  <attribute name="id">
1841
1944
  <data type="ID"/>
1842
1945
  </attribute>
1946
+ <optional>
1947
+ <attribute name="keep-with-next">
1948
+ <data type="boolean"/>
1949
+ </attribute>
1950
+ </optional>
1951
+ <optional>
1952
+ <attribute name="keep-lines-together">
1953
+ <data type="boolean"/>
1954
+ </attribute>
1955
+ </optional>
1956
+ <optional>
1957
+ <attribute name="tag"/>
1958
+ </optional>
1959
+ <optional>
1960
+ <attribute name="multilingual-rendering">
1961
+ <ref name="MultilingualRenderingType"/>
1962
+ </attribute>
1963
+ </optional>
1843
1964
  <ref name="paragraph"/>
1844
1965
  </element>
1845
1966
  </define>
@@ -1966,9 +2087,6 @@
1966
2087
  <zeroOrMore>
1967
2088
  <ref name="BasicBlock"/>
1968
2089
  </zeroOrMore>
1969
- <zeroOrMore>
1970
- <ref name="note"/>
1971
- </zeroOrMore>
1972
2090
  <zeroOrMore>
1973
2091
  <choice>
1974
2092
  <ref name="term-clause"/>
@@ -2007,6 +2125,14 @@
2007
2125
  <optional>
2008
2126
  <attribute name="title"/>
2009
2127
  </optional>
2128
+ <optional>
2129
+ <attribute name="tag"/>
2130
+ </optional>
2131
+ <optional>
2132
+ <attribute name="multilingual-rendering">
2133
+ <ref name="MultilingualRenderingType"/>
2134
+ </attribute>
2135
+ </optional>
2010
2136
  <optional>
2011
2137
  <element name="location">
2012
2138
  <zeroOrMore>
@@ -2066,6 +2192,14 @@
2066
2192
  </define>
2067
2193
  <define name="imagemap">
2068
2194
  <element name="imagemap">
2195
+ <optional>
2196
+ <attribute name="tag"/>
2197
+ </optional>
2198
+ <optional>
2199
+ <attribute name="multilingual-rendering">
2200
+ <ref name="MultilingualRenderingType"/>
2201
+ </attribute>
2202
+ </optional>
2069
2203
  <ref name="figure"/>
2070
2204
  <zeroOrMore>
2071
2205
  <element name="area">
@@ -2110,6 +2244,14 @@
2110
2244
  </define>
2111
2245
  <define name="svgmap">
2112
2246
  <element name="svgmap">
2247
+ <optional>
2248
+ <attribute name="tag"/>
2249
+ </optional>
2250
+ <optional>
2251
+ <attribute name="multilingual-rendering">
2252
+ <ref name="MultilingualRenderingType"/>
2253
+ </attribute>
2254
+ </optional>
2113
2255
  <ref name="figure"/>
2114
2256
  <zeroOrMore>
2115
2257
  <element name="target">
@@ -4,10 +4,10 @@ module Asciidoctor
4
4
  def li(xml_ul, item)
5
5
  xml_ul.li do |xml_li|
6
6
  if item.blocks?
7
- xml_li.p(**id_attr(item)) { |t| t << item.text }
7
+ xml_li.p(**attr_code(id_attr(item))) { |t| t << item.text }
8
8
  xml_li << item.content
9
9
  else
10
- xml_li.p(**id_attr(item)) { |p| p << item.text }
10
+ xml_li.p(**attr_code(id_attr(item))) { |p| p << item.text }
11
11
  end
12
12
  end
13
13
  end
@@ -15,10 +15,10 @@ module Asciidoctor
15
15
  def ul_li(xml_ul, item)
16
16
  xml_ul.li **ul_li_attrs(item) do |xml_li|
17
17
  if item.blocks?
18
- xml_li.p(**id_attr(item)) { |t| t << item.text }
18
+ xml_li.p(**attr_code(id_attr(item))) { |t| t << item.text }
19
19
  xml_li << item.content
20
20
  else
21
- xml_li.p(**id_attr(item)) { |p| p << item.text }
21
+ xml_li.p(**attr_code(id_attr(item))) { |p| p << item.text }
22
22
  end
23
23
  end
24
24
  end
@@ -57,9 +57,8 @@ module Asciidoctor
57
57
  end
58
58
 
59
59
  def ol_attrs(node)
60
- attr_code(keep_attrs(node)
61
- .merge(id: Metanorma::Utils::anchor_or_uuid(node),
62
- type: olist_style(node.style)))
60
+ attr_code(id_attr(node).merge(keep_attrs(node)
61
+ .merge(type: olist_style(node.style))))
63
62
  end
64
63
 
65
64
  def olist(node)
@@ -79,22 +78,23 @@ module Asciidoctor
79
78
  end
80
79
  end
81
80
 
82
- def dd(dd, xml_dl)
83
- if dd.nil?
81
+ def dd(ddefn, xml_dl)
82
+ if ddefn.nil?
84
83
  xml_dl.dd
85
84
  return
86
85
  end
87
86
  xml_dl.dd do |xml_dd|
88
- xml_dd.p { |t| t << dd.text } if dd.text?
89
- xml_dd << dd.content if dd.blocks?
87
+ xml_dd.p { |t| t << ddefn.text } if ddefn.text?
88
+ xml_dd << ddefn.content if ddefn.blocks?
90
89
  end
91
90
  end
92
91
 
93
92
  def dl_attrs(node)
94
- attr_code(keep_attrs(node)
95
- .merge(id: Metanorma::Utils::anchor_or_uuid(node),
96
- metadata: node.option?("metadata") ? "true" : nil,
97
- key: node.option?("key") ? "true" : nil))
93
+ attr_code(id_attr(node).merge(keep_attrs(node)
94
+ .merge(
95
+ metadata: node.option?("metadata") ? "true" : nil,
96
+ key: node.option?("key") ? "true" : nil,
97
+ )))
98
98
  end
99
99
 
100
100
  def dlist(node)
@@ -116,9 +116,12 @@ module Asciidoctor
116
116
 
117
117
  def process(parent, target, _attrs)
118
118
  attrs = preprocess_attrs(target)
119
- term = Asciidoctor::Inline.new(parent, :quoted, attrs[:term]).convert
120
- word = Asciidoctor::Inline.new(parent, :quoted, attrs[:word]).convert
121
- xref = Asciidoctor::Inline.new(parent, :quoted, attrs[:render]).convert
119
+ term = Asciidoctor::Inline.new(parent, :quoted,
120
+ attrs[:term]).convert
121
+ word = Asciidoctor::Inline.new(parent, :quoted,
122
+ attrs[:word]).convert
123
+ xref = Asciidoctor::Inline.new(parent, :quoted,
124
+ attrs[:render]).convert
122
125
  opt = generate_attrs(attrs[:opt] || [])
123
126
  if attrs[:id] then "<concept#{opt} key='#{attrs[:id]}'><refterm>"\
124
127
  "#{term}</refterm><renderterm>#{word}</renderterm>"\
@@ -58,6 +58,14 @@
58
58
  <optional>
59
59
  <attribute name="type"/>
60
60
  </optional>
61
+ <optional>
62
+ <attribute name="tag"/>
63
+ </optional>
64
+ <optional>
65
+ <attribute name="multilingual-rendering">
66
+ <ref name="MultilingualRenderingType"/>
67
+ </attribute>
68
+ </optional>
61
69
  <optional>
62
70
  <ref name="reqtitle"/>
63
71
  </optional>
@@ -101,7 +109,9 @@
101
109
  </define>
102
110
  <define name="label">
103
111
  <element name="label">
104
- <text/>
112
+ <oneOrMore>
113
+ <ref name="TextElement"/>
114
+ </oneOrMore>
105
115
  </element>
106
116
  </define>
107
117
  <define name="subject">
@@ -175,8 +185,19 @@
175
185
  <data type="boolean"/>
176
186
  </attribute>
177
187
  </optional>
188
+ <optional>
189
+ <attribute name="tag"/>
190
+ </optional>
191
+ <optional>
192
+ <attribute name="multilingual-rendering">
193
+ <ref name="MultilingualRenderingType"/>
194
+ </attribute>
195
+ </optional>
178
196
  <oneOrMore>
179
- <ref name="BasicBlock"/>
197
+ <choice>
198
+ <ref name="BasicBlock"/>
199
+ <ref name="component"/>
200
+ </choice>
180
201
  </oneOrMore>
181
202
  </define>
182
203
  <define name="ObligationType">
@@ -8,7 +8,7 @@ module Asciidoctor
8
8
  module Standoc
9
9
  module Validate
10
10
  SOURCELOCALITY = "./termsource/origin//locality[@type = 'clause']/"\
11
- "referenceFrom".freeze
11
+ "referenceFrom".freeze
12
12
 
13
13
  def init_iev
14
14
  return nil if @no_isobib
@@ -34,11 +34,14 @@ module Asciidoctor
34
34
  end
35
35
 
36
36
  def content_validate(doc)
37
+ @fatalerror = []
38
+ xref_validate(doc)
37
39
  section_validate(doc)
38
40
  norm_ref_validate(doc)
39
41
  repeat_id_validate(doc.root)
40
42
  iev_validate(doc.root)
41
43
  concept_validate(doc)
44
+ @fatalerror.empty? or clean_abort(@fatalerror.join("\n"), doc.to_xml)
42
45
  end
43
46
 
44
47
  def norm_ref_validate(doc)
@@ -51,8 +54,7 @@ module Asciidoctor
51
54
  "Numeric reference in normative references")
52
55
  found = true
53
56
  end
54
- found and
55
- clean_abort("Numeric reference in normative references", doc.to_xml)
57
+ found and @fatalerror << "Numeric reference in normative references"
56
58
  end
57
59
 
58
60
  def concept_validate(doc)
@@ -62,19 +64,19 @@ module Asciidoctor
62
64
  next if doc.at("//definitions//dt[@id = '#{x['target']}']")
63
65
 
64
66
  ref = x&.at("../refterm")&.text
65
- @log.add("Anchors", x, "Concept #{ref} is pointing to "\
67
+ @log.add("Anchors", x,
68
+ "Concept #{ref} is pointing to "\
66
69
  "#{x['target']}, which is not a term or symbol")
67
70
  found = true
68
71
  end
69
- found and clean_abort("Concept not cross-referencing term or symbol",
70
- doc.to_xml)
72
+ found and @fatalerror << "Concept not cross-referencing term or symbol"
71
73
  end
72
74
 
73
75
  def repeat_id_validate1(ids, elem)
74
76
  if ids[elem["id"]]
75
77
  @log.add("Anchors", elem, "Anchor #{elem['id']} has already been "\
76
- "used at line #{ids[elem['id']]}")
77
- raise StandardError.new "Error: multiple instances of same ID"
78
+ "used at line #{ids[elem['id']]}")
79
+ @fatalerror << "Multiple instances of same ID: #{elem['id']}"
78
80
  else
79
81
  ids[elem["id"]] = elem.line
80
82
  end
@@ -83,12 +85,8 @@ module Asciidoctor
83
85
 
84
86
  def repeat_id_validate(doc)
85
87
  ids = {}
86
- begin
87
- doc.xpath("//*[@id]").each do |x|
88
- ids = repeat_id_validate1(ids, x)
89
- end
90
- rescue StandardError => e
91
- clean_abort(e.message, doc.to_xml)
88
+ doc.xpath("//*[@id]").each do |x|
89
+ ids = repeat_id_validate1(ids, x)
92
90
  end
93
91
  end
94
92
 
@@ -130,6 +128,17 @@ module Asciidoctor
130
128
  doc
131
129
  end
132
130
 
131
+ # manually check for xref/@target, xref/@to integrity
132
+ def xref_validate(doc)
133
+ ids = doc.xpath("//*/@id").each_with_object({}) { |x, m| m[x.text] = 1 }
134
+ doc.xpath("//xref/@target | //xref/@to").each do |x|
135
+ next if ids[x.text]
136
+
137
+ @log.add("Anchors", x.parent,
138
+ "Crossreference target #{x.text} is undefined")
139
+ end
140
+ end
141
+
133
142
  def validate(doc)
134
143
  content_validate(doc)
135
144
  schema_validate(formattedstr_strip(doc.dup),