metanorma-standoc 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +66 -0
  3. data/README.adoc +1 -3
  4. data/lib/asciidoctor/standoc/base.rb +8 -16
  5. data/lib/asciidoctor/standoc/basicdoc.rng +50 -3
  6. data/lib/asciidoctor/standoc/cleanup.rb +52 -4
  7. data/lib/asciidoctor/standoc/cleanup_block.rb +41 -4
  8. data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +47 -20
  9. data/lib/asciidoctor/standoc/cleanup_footnotes.rb +14 -0
  10. data/lib/asciidoctor/standoc/cleanup_inline.rb +9 -3
  11. data/lib/asciidoctor/standoc/cleanup_ref.rb +17 -24
  12. data/lib/asciidoctor/standoc/cleanup_terms.rb +4 -6
  13. data/lib/asciidoctor/standoc/converter.rb +71 -1
  14. data/lib/asciidoctor/standoc/front.rb +6 -0
  15. data/lib/asciidoctor/standoc/front_contributor.rb +8 -4
  16. data/lib/asciidoctor/standoc/inline.rb +6 -5
  17. data/lib/asciidoctor/standoc/isodoc.rng +36 -43
  18. data/lib/asciidoctor/standoc/lists.rb +4 -2
  19. data/lib/asciidoctor/standoc/macros.rb +55 -59
  20. data/lib/asciidoctor/standoc/macros_terms.rb +82 -0
  21. data/lib/asciidoctor/standoc/ref.rb +19 -25
  22. data/lib/asciidoctor/standoc/ref_sect.rb +4 -3
  23. data/lib/asciidoctor/standoc/section.rb +21 -20
  24. data/lib/asciidoctor/standoc/table.rb +12 -0
  25. data/lib/asciidoctor/standoc/term_lookup_cleanup.rb +86 -0
  26. data/lib/asciidoctor/standoc/utils.rb +2 -0
  27. data/lib/metanorma/standoc/version.rb +1 -1
  28. data/metanorma-standoc.gemspec +5 -3
  29. data/spec/asciidoctor-standoc/base_spec.rb +14 -4
  30. data/spec/asciidoctor-standoc/blocks_spec.rb +14 -9
  31. data/spec/asciidoctor-standoc/cleanup_sections_spec.rb +1519 -0
  32. data/spec/asciidoctor-standoc/cleanup_spec.rb +416 -1554
  33. data/spec/asciidoctor-standoc/converter_spec.rb +8 -0
  34. data/spec/asciidoctor-standoc/inline_spec.rb +2 -5
  35. data/spec/asciidoctor-standoc/isobib_cache_spec.rb +16 -9
  36. data/spec/asciidoctor-standoc/lists_spec.rb +10 -1
  37. data/spec/asciidoctor-standoc/macros_lutaml_spec.rb +80 -0
  38. data/spec/asciidoctor-standoc/macros_plantuml_spec.rb +307 -0
  39. data/spec/asciidoctor-standoc/macros_spec.rb +408 -169
  40. data/spec/asciidoctor-standoc/refs_dl_spec.rb +6 -6
  41. data/spec/asciidoctor-standoc/refs_spec.rb +112 -65
  42. data/spec/asciidoctor-standoc/section_spec.rb +17 -12
  43. data/spec/asciidoctor-standoc/table_spec.rb +86 -0
  44. data/spec/asciidoctor-standoc/validate_spec.rb +26 -0
  45. data/spec/fixtures/diagram_definitions.lutaml +22 -0
  46. data/spec/fixtures/test.exp +121 -0
  47. data/spec/spec_helper.rb +33 -0
  48. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +59 -243
  49. data/spec/vcr_cassettes/isobib_get_123.yml +12 -12
  50. data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -119
  51. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +35 -35
  52. data/spec/vcr_cassettes/isobib_get_123_2001.yml +14 -60
  53. data/spec/vcr_cassettes/isobib_get_124.yml +11 -57
  54. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +8 -8
  55. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +281 -157
  56. metadata +45 -11
  57. data/.github/workflows/macos.yml +0 -41
  58. data/.github/workflows/ubuntu.yml +0 -45
  59. data/.github/workflows/windows.yml +0 -43
@@ -17,6 +17,7 @@ module Asciidoctor
17
17
  @table_fn_number = "a"
18
18
  noko do |xml|
19
19
  xml.table **attr_code(table_attrs(node)) do |xml_table|
20
+ colgroup(node, xml_table)
20
21
  table_name(node, xml_table)
21
22
  %i(head body foot).reject do |tblsec|
22
23
  node.rows[tblsec].empty?
@@ -28,6 +29,17 @@ module Asciidoctor
28
29
 
29
30
  private
30
31
 
32
+ def colgroup(node, xml_table)
33
+ return if node.option? "autowidth"
34
+ cols = node&.attr("cols")&.split(/,/) or return
35
+ return unless cols.size > 1 and cols.all? { |c| /\d/.match(c) }
36
+ xml_table.colgroup do |cg|
37
+ node.columns.each do |col|
38
+ cg.col **{ width: "#{col.attr 'colpcwidth'}%" }
39
+ end
40
+ end
41
+ end
42
+
31
43
  def table_name(node, xml_table)
32
44
  if node.title?
33
45
  xml_table.name do |n|
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true.
2
+
3
+ module Asciidoctor
4
+ module Standoc
5
+ # Intelligent term lookup xml modifier
6
+ # Lookup all `term` and `calause` tags and replace `termxref` tags with
7
+ # `xref`:target tag
8
+ class TermLookupCleanup
9
+ AUTOMATIC_GENERATED_ID_REGEXP = /\A_/
10
+ EXISTING_TERM_REGEXP = /\Aterm-/
11
+
12
+ attr_reader :xmldoc, :termlookup, :log
13
+
14
+ def initialize(xmldoc, log)
15
+ @xmldoc = xmldoc
16
+ @log = log
17
+ @termlookup = {}
18
+ end
19
+
20
+ def call
21
+ @termlookup = replace_automatic_generated_ids_terms
22
+ set_termxref_tags_target
23
+ end
24
+
25
+ private
26
+
27
+ def set_termxref_tags_target
28
+ xmldoc.xpath('//termxref').each do |node|
29
+ target = normalize_ref_id(node.text)
30
+ if termlookup[target].nil?
31
+ remove_missing_ref(node, target)
32
+ next
33
+ end
34
+ modify_ref_node(node, target)
35
+ end
36
+ end
37
+
38
+ def remove_missing_ref(node, target)
39
+ log.add('AsciiDoc Input', node,
40
+ %(Error: Term reference in `term[#{target}]` missing: \
41
+ "#{target}" is not defined in document))
42
+ term_name_node = node.previous.previous
43
+ term_name_node.remove
44
+ term_name_node.name = "strong"
45
+ term_name_node.children.first.content =
46
+ %(term "#{term_name_node.text}" not resolved)
47
+ node.add_previous_sibling(term_name_node)
48
+ node.remove
49
+ end
50
+
51
+ def modify_ref_node(node, target)
52
+ node.name = 'xref'
53
+ node['target'] = termlookup[target]
54
+ node.children.remove
55
+ node.remove_attribute('defaultref')
56
+ end
57
+
58
+ def replace_automatic_generated_ids_terms
59
+ xmldoc.xpath('//term').each.with_object({}) do |term_node, res|
60
+ normalize_id_and_memorize(term_node, res, './preferred')
61
+ end
62
+ end
63
+
64
+ def normalize_id_and_memorize(term_node, res_table, text_selector)
65
+ term_text = normalize_ref_id(term_node.at(text_selector).text)
66
+ unless AUTOMATIC_GENERATED_ID_REGEXP.match(term_node['id']).nil?
67
+ term_node['id'] = unique_text_id(term_text)
68
+ end
69
+ res_table[term_text] = term_node['id']
70
+ end
71
+
72
+ def normalize_ref_id(text)
73
+ text.downcase.gsub(/[[:space:]]/, '-')
74
+ end
75
+
76
+ def unique_text_id(text)
77
+ return "term-#{text}" if xmldoc.at("//*[@id = 'term-#{text}']").nil?
78
+ (1..Float::INFINITY).lazy.each do |index|
79
+ if xmldoc.at("//*[@id = 'term-#{text}-#{index}']").nil?
80
+ break("term-#{text}-#{index}")
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
@@ -31,8 +31,10 @@ module Asciidoctor
31
31
  docfile.nil? ? './' : Pathname.new(docfile).parent.to_s + '/'
32
32
  end
33
33
 
34
+ # TODO needs internationalisation
34
35
  def smartformat(n)
35
36
  n.gsub(/ --? /, " — ").
37
+ gsub(/\'(\d\d)(?=[^\u2019\'\s<]+[’\'][\p{P}\p{Z}])([\p{P}\p{Z}])/, "\u2018\\1\\2").
36
38
  gsub(/--/, "&#8212;").smart_format.gsub(/</, "&lt;").gsub(/>/, "&gt;")
37
39
  end
38
40
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "1.6.1".freeze
22
+ VERSION = "1.7.0".freeze
23
23
  end
24
24
  end
@@ -28,18 +28,20 @@ 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.2.0"
31
+ spec.add_dependency "isodoc", "~> 1.4.0"
32
32
  spec.add_dependency "iev", "~> 0.2.1"
33
33
  spec.add_dependency "metanorma-plugin-datastruct"
34
+ spec.add_dependency "metanorma-plugin-lutaml", "~> 0.2.1"
34
35
  # relaton-cli not just relaton, to avoid circular reference in metanorma
35
- spec.add_dependency "relaton-cli", "~> 1.5.0"
36
- spec.add_dependency "relaton-iev", "~> 1.0.0"
36
+ spec.add_dependency "relaton-cli", "~> 1.7.0"
37
+ spec.add_dependency "relaton-iev", "~> 1.1.0"
37
38
  spec.add_dependency "sterile", "~> 1.0.14"
38
39
  spec.add_dependency "concurrent-ruby"
39
40
  spec.add_dependency "unicode2latex", "~> 0.0.1"
40
41
  spec.add_dependency "mimemagic"
41
42
  spec.add_dependency "mathml2asciimath"
42
43
  spec.add_dependency "latexmath"
44
+ spec.add_dependency "fontist", "~> 1.7.3"
43
45
 
44
46
  spec.add_development_dependency "byebug"
45
47
  spec.add_development_dependency "sassc", "2.4.0"
@@ -40,7 +40,7 @@ RSpec.describe Asciidoctor::Standoc do
40
40
  :docfile: test.adoc
41
41
  :nodoc:
42
42
  :novalid:
43
- :publisher: International Electrotechnical Commission,IETF,ISO
43
+ :publisher: International Electrotechnical Commission;IETF;ISO
44
44
  INPUT
45
45
  <standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
46
46
  <bibdata type='standard'>
@@ -181,6 +181,7 @@ OUTPUT
181
181
  :role: author
182
182
  :affiliation: Slate Rock and Gravel Company
183
183
  :affiliation_abbrev: SRG
184
+ :affiliation_subdiv: Hermeneutics Unit; Exegetical Subunit
184
185
  :address: 6 Rubble Way, Bedrock
185
186
  :contributor-uri: http://slate.example.com
186
187
  :phone: 123
@@ -191,13 +192,14 @@ OUTPUT
191
192
  :role_2: editor
192
193
  :affiliation_2: Rockhead and Quarry Cave Construction Company
193
194
  :affiliation_abbrev_2: RQCCC
195
+ :affiliation_subdiv_2: Hermeneutics Unit; Exegetical Subunit
194
196
  :address_2: 6A Rubble Way, + \\
195
197
  Bedrock
196
198
  :email_2: barney@rockhead.example.com
197
199
  :phone_2: 789
198
200
  :fax_2: 012
199
- :publisher: "Hanna Barbera", "Cartoon Network", "Ribose, Inc."
200
- :copyright-holder: "Ribose, Inc.", Hanna Barbera
201
+ :publisher: "Hanna Barbera"; "Cartoon Network"; "Ribose, Inc."
202
+ :copyright-holder: "Ribose, Inc."; Hanna Barbera
201
203
  :part-of: ABC
202
204
  :translated-from: DEF,GHI;JKL MNO,PQR
203
205
  :keywords: a, b, c
@@ -207,12 +209,16 @@ OUTPUT
207
209
  :pub-fax: 4444444
208
210
  :pub-email: x@example.com
209
211
  :pub-uri: http://www.example.com
212
+ :isbn: ISBN-13
213
+ :isbn10: ISBN-10
210
214
  INPUT
211
215
  <?xml version="1.0" encoding="UTF-8"?>
212
216
  <standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
213
217
  <bibdata type="standard">
214
218
  <title language="en" format="text/plain">Main Title — Title</title>
215
219
  <docidentifier>1000-1</docidentifier>
220
+ <docidentifier type='ISBN'>ISBN-13</docidentifier>
221
+ <docidentifier type='ISBN10'>ISBN-10</docidentifier>
216
222
  <docnumber>1000</docnumber>
217
223
  <date type="published">
218
224
  <on>1000-01-01</on>
@@ -284,6 +290,8 @@ OUTPUT
284
290
  <organization>
285
291
  <name>Slate Rock and Gravel Company</name>
286
292
  <abbreviation>SRG</abbreviation>
293
+ <subdivision>Hermeneutics Unit</subdivision>
294
+ <subdivision>Exegetical Subunit</subdivision>
287
295
  <address>
288
296
  <formattedAddress>
289
297
  6 Rubble Way, Bedrock
@@ -308,6 +316,8 @@ OUTPUT
308
316
  <organization>
309
317
  <name>Rockhead and Quarry Cave Construction Company</name>
310
318
  <abbreviation>RQCCC</abbreviation>
319
+ <subdivision>Hermeneutics Unit</subdivision>
320
+ <subdivision>Exegetical Subunit</subdivision>
311
321
  <address>
312
322
  <formattedAddress>6A Rubble Way, <br/>Bedrock</formattedAddress>
313
323
  </address>
@@ -421,7 +431,7 @@ OUTPUT
421
431
  :tc-docnumber: 2000
422
432
  :language: el
423
433
  :script: Grek
424
- :publisher: IEC,IETF,ISO
434
+ :publisher: IEC;IETF;ISO
425
435
  :uri: A
426
436
  :xml-uri: B
427
437
  :html-uri: C
@@ -318,7 +318,7 @@ RSpec.describe Asciidoctor::Standoc do
318
318
  <terms id="_" obligation="normative">
319
319
  <title>Terms and definitions</title>
320
320
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
321
- <term id="_">
321
+ <term id="term-term1">
322
322
  <preferred>Term1</preferred>
323
323
  <termnote id="_">
324
324
  <p id="_">This is a note</p>
@@ -340,7 +340,9 @@ RSpec.describe Asciidoctor::Standoc do
340
340
 
341
341
  NOTE: This is not a termnote
342
342
 
343
- EXAMPLE: This is not a termexample
343
+ ====
344
+ This is not a termexample
345
+ ====
344
346
 
345
347
  [.nonterm]
346
348
  === Term1
@@ -355,6 +357,9 @@ RSpec.describe Asciidoctor::Standoc do
355
357
  <note id='_'>
356
358
  <p id='_'>This is not a termnote</p>
357
359
  </note>
360
+ <example id='_'>
361
+ <p id='_'>This is not a termexample</p>
362
+ </example>
358
363
  <clause id="_" inline-header="false" obligation="normative">
359
364
  <title>Term1</title>
360
365
  <note id="_">
@@ -383,7 +388,7 @@ RSpec.describe Asciidoctor::Standoc do
383
388
  <sections>
384
389
  <terms id="_" obligation="normative"><title>Terms, definitions and symbols</title>
385
390
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
386
- <term id="_">
391
+ <term id="term-term1">
387
392
  <preferred>Term1</preferred>
388
393
  </term>
389
394
  <definitions id="_" obligation="normative" type="symbols">
@@ -528,7 +533,7 @@ RSpec.describe Asciidoctor::Standoc do
528
533
  <terms id="_" obligation="normative">
529
534
  <title>Terms and definitions</title>
530
535
  <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
531
- <term id="_">
536
+ <term id="term-term1">
532
537
  <preferred>Term1</preferred>
533
538
 
534
539
  <termexample id="ABC">
@@ -583,7 +588,7 @@ RSpec.describe Asciidoctor::Standoc do
583
588
  #{BLANK_HDR}
584
589
  <sections>
585
590
  <terms id="_" obligation="normative"><title>Terms, definitions and symbols</title>
586
- <p id="_">For the purposes of this document, the following terms and definitions apply.</p><term id="_">
591
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p><term id="term-term1">
587
592
  <preferred>Term1</preferred>
588
593
  </term>
589
594
  <definitions id="_" obligation="normative" type="symbols">
@@ -972,7 +977,7 @@ RSpec.describe Asciidoctor::Standoc do
972
977
  <terms id="_" obligation="normative">
973
978
  <title>Terms and definitions</title><p id="_">For the purposes of this document,
974
979
  the following terms and definitions apply.</p>
975
- <term id="_">
980
+ <term id="term-term1">
976
981
  <preferred>Term1</preferred>
977
982
  <termsource status="identical">
978
983
  <origin bibitemid="ISO2191" type="inline" citeas="">
@@ -982,7 +987,7 @@ RSpec.describe Asciidoctor::Standoc do
982
987
  </origin>
983
988
  </termsource>
984
989
  </term>
985
- <term id='_'>
990
+ <term id='term-term2'>
986
991
  <preferred>Term2</preferred>
987
992
  <definition>
988
993
  <p id='_'>Definition</p>
@@ -1032,7 +1037,7 @@ RSpec.describe Asciidoctor::Standoc do
1032
1037
  <title>Terms and definitions</title>
1033
1038
  <p id="_">For the purposes of this document,
1034
1039
  the following terms and definitions apply.</p>
1035
- <term id="_">
1040
+ <term id="term-term1">
1036
1041
  <preferred>Term1</preferred>
1037
1042
  <termsource status="modified">
1038
1043
  <origin bibitemid="ISO2191" type="inline" citeas="">
@@ -1045,7 +1050,7 @@ RSpec.describe Asciidoctor::Standoc do
1045
1050
  </modification>
1046
1051
  </termsource>
1047
1052
  </term>
1048
- <term id='_'>
1053
+ <term id='term-term2'>
1049
1054
  <preferred>Term2</preferred>
1050
1055
  <definition>
1051
1056
  <p id='_'>Definition</p>
@@ -0,0 +1,1519 @@
1
+ require "spec_helper"
2
+ require "relaton_iec"
3
+ require "fileutils"
4
+
5
+ RSpec.describe Asciidoctor::Standoc do
6
+ it "appends any initial user-supplied text to boilerplate in terms and definitions" do
7
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
8
+ #{ASCIIDOC_BLANK_HDR}
9
+ == Terms and Definitions
10
+
11
+ I am boilerplate
12
+
13
+ * So am I
14
+
15
+ === Time
16
+
17
+ This paragraph is extraneous
18
+ INPUT
19
+ #{BLANK_HDR}
20
+ <sections>
21
+ <terms id="_" obligation="normative"><title>Terms and definitions</title>
22
+ <p id="_">For the purposes of this document, the following terms and definitions apply.</p>
23
+ <p id='_'>I am boilerplate</p>
24
+ <ul id='_'>
25
+ <li>
26
+ <p id='_'>So am I</p>
27
+ </li>
28
+ </ul>
29
+ <term id="term-time">
30
+ <preferred>Time</preferred>
31
+ <definition><p id="_">This paragraph is extraneous</p></definition>
32
+ </term></terms>
33
+ </sections>
34
+ </standard-document>
35
+ OUTPUT
36
+ end
37
+
38
+ it "removes initial extraneous material from Normative References" do
39
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
40
+ #{ASCIIDOC_BLANK_HDR}
41
+ [bibliography]
42
+ == Normative References
43
+
44
+ This is extraneous information
45
+
46
+ * [[[iso216,ISO 216]]], _Reference_
47
+
48
+ This is also extraneous information
49
+ INPUT
50
+ #{BLANK_HDR}
51
+ <sections></sections>
52
+ <bibliography><references id="_" obligation="informative" normative="true"><title>Normative references</title>
53
+ #{NORM_REF_BOILERPLATE}
54
+ <bibitem id="iso216" type="standard">
55
+ <title format="text/plain">Reference</title>
56
+ <docidentifier>ISO 216</docidentifier>
57
+ <docnumber>216</docnumber>
58
+ <contributor>
59
+ <role type="publisher"/>
60
+ <organization>
61
+ <name>ISO</name>
62
+ </organization>
63
+ </contributor>
64
+ </bibitem>
65
+ <p id='_'>This is also extraneous information</p>
66
+ </references>
67
+ </bibliography>
68
+ </standard-document>
69
+ OUTPUT
70
+ end
71
+
72
+ it "sorts references with their notes in Bibliography" do
73
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
74
+ #{ASCIIDOC_BLANK_HDR}
75
+ [bibliography]
76
+ == Bibliography
77
+
78
+ This is extraneous information
79
+
80
+ * [[[iso216,ISO 216]]], _Reference_
81
+
82
+ NOTE: ABC
83
+
84
+ NOTE: DEF
85
+
86
+ This is further extraneous information
87
+
88
+ NOTE: GHI
89
+
90
+ * [[[iso216,ISO 215]]], _Reference_
91
+
92
+ NOTE: JKL
93
+
94
+ This is also extraneous information
95
+ INPUT
96
+ #{BLANK_HDR}
97
+ <sections> </sections>
98
+ <bibliography>
99
+ <references id='_' obligation='informative' normative="false">
100
+ <title>Bibliography</title>
101
+ <p id='_'>This is extraneous information</p>
102
+ <bibitem id='iso216' type='standard'>
103
+ <title format='text/plain'>Reference</title>
104
+ <docidentifier>ISO 216</docidentifier>
105
+ <docnumber>216</docnumber>
106
+ <contributor>
107
+ <role type='publisher'/>
108
+ <organization>
109
+ <name>ISO</name>
110
+ </organization>
111
+ </contributor>
112
+ </bibitem>
113
+ <note id='_'>
114
+ <p id='_'>ABC</p>
115
+ </note>
116
+ <note id='_'>
117
+ <p id='_'>DEF</p>
118
+ </note>
119
+ <bibitem id='iso216' type='standard'>
120
+ <title format='text/plain'>Reference</title>
121
+ <docidentifier>ISO 215</docidentifier>
122
+ <docnumber>215</docnumber>
123
+ <contributor>
124
+ <role type='publisher'/>
125
+ <organization>
126
+ <name>ISO</name>
127
+ </organization>
128
+ </contributor>
129
+ </bibitem>
130
+ <note id='_'>
131
+ <p id='_'>JKL</p>
132
+ </note>
133
+ <p id='_'>
134
+ This is further extraneous information
135
+ <note id='_'>
136
+ <p id='_'>GHI</p>
137
+ </note>
138
+ </p>
139
+ <p id='_'>This is also extraneous information</p>
140
+ </references>
141
+ </bibliography>
142
+ </standard-document>
143
+ OUTPUT
144
+ end
145
+
146
+ it "defaults section obligations" do
147
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
148
+ #{ASCIIDOC_BLANK_HDR}
149
+
150
+ == Clause
151
+ Text
152
+
153
+ [appendix]
154
+ == Clause
155
+
156
+ Text
157
+ INPUT
158
+ #{BLANK_HDR}
159
+ <sections><clause id="_" inline-header="false" obligation="normative">
160
+ <title>Clause</title>
161
+ <p id="_">Text</p>
162
+ </clause>
163
+ </sections><annex id="_" inline-header="false" obligation="normative">
164
+ <title>Clause</title>
165
+ <p id="_">Text</p>
166
+ </annex>
167
+ </standard-document>
168
+ OUTPUT
169
+ end
170
+
171
+ it "extends clause levels past 5" do
172
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
173
+ #{ASCIIDOC_BLANK_HDR}
174
+
175
+ == Clause1
176
+
177
+ === Clause2
178
+
179
+ ==== Clause3
180
+
181
+ ===== Clause4
182
+
183
+ ====== Clause 5
184
+
185
+ [level=6]
186
+ ====== Clause 6
187
+
188
+ [level=7]
189
+ ====== Clause 7A
190
+
191
+ [level=7]
192
+ ====== Clause 7B
193
+
194
+ [level=6]
195
+ ====== Clause 6B
196
+
197
+ ====== Clause 5B
198
+
199
+ INPUT
200
+ #{BLANK_HDR}
201
+ <sections>
202
+ <clause id="_" inline-header="false" obligation="normative">
203
+ <title>Clause1</title>
204
+ <clause id="_" inline-header="false" obligation="normative">
205
+ <title>Clause2</title>
206
+ <clause id="_" inline-header="false" obligation="normative">
207
+ <title>Clause3</title>
208
+ <clause id="_" inline-header="false" obligation="normative"><title>Clause4</title><clause id="_" inline-header="false" obligation="normative">
209
+ <title>Clause 5</title>
210
+ <clause id="_" inline-header="false" obligation="normative">
211
+ <title>Clause 6</title>
212
+ <clause id="_" inline-header="false" obligation="normative">
213
+ <title>Clause 7A</title>
214
+ </clause><clause id="_" inline-header="false" obligation="normative">
215
+ <title>Clause 7B</title>
216
+ </clause></clause><clause id="_" inline-header="false" obligation="normative">
217
+ <title>Clause 6B</title>
218
+ </clause></clause>
219
+
220
+
221
+
222
+
223
+ <clause id="_" inline-header="false" obligation="normative">
224
+ <title>Clause 5B</title>
225
+ </clause></clause>
226
+ </clause>
227
+ </clause>
228
+ </clause>
229
+ </sections>
230
+ </standard-document>
231
+ OUTPUT
232
+ end
233
+
234
+ it "inserts boilerplate before empty Normative References" do
235
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
236
+ #{ASCIIDOC_BLANK_HDR}
237
+
238
+ [bibliography]
239
+ == Normative References
240
+
241
+ INPUT
242
+ #{BLANK_HDR}
243
+ <sections>
244
+
245
+ </sections><bibliography><references id="_" obligation="informative" normative="true">
246
+ <title>Normative references</title><p id="_">There are no normative references in this document.</p>
247
+ </references></bibliography>
248
+ </standard-document>
249
+ OUTPUT
250
+ end
251
+
252
+ it "inserts boilerplate before non-empty Normative References" do
253
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
254
+ #{ASCIIDOC_BLANK_HDR}
255
+
256
+ [bibliography]
257
+ == Normative References
258
+ * [[[a,b]]] A
259
+
260
+ INPUT
261
+ #{BLANK_HDR}
262
+ <sections>
263
+
264
+ </sections><bibliography><references id="_" obligation="informative" normative="true">
265
+ <title>Normative references</title><p id="_">The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
266
+ <bibitem id="a">
267
+ <formattedref format="application/x-isodoc+xml">A</formattedref>
268
+ <docidentifier>b</docidentifier>
269
+ </bibitem>
270
+ </references></bibliography>
271
+ </standard-document>
272
+
273
+ OUTPUT
274
+ end
275
+
276
+ it "inserts boilerplate before empty Normative References in French" do
277
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
278
+ = Document title
279
+ Author
280
+ :docfile: test.adoc
281
+ :nodoc:
282
+ :novalid:
283
+ :no-isobib:
284
+ :language: fr
285
+
286
+ [bibliography]
287
+ == Normative References
288
+
289
+ INPUT
290
+ #{BLANK_HDR.sub(/<language>en/, "<language>fr")}
291
+ <sections>
292
+
293
+ </sections><bibliography><references id="_" obligation="informative" normative="true">
294
+ <title>Références normatives</title><p id="_">Le présent document ne contient aucune référence normative.</p>
295
+ </references></bibliography>
296
+ </standard-document>
297
+ OUTPUT
298
+ end
299
+
300
+ it "processes section names, with footnotes" do
301
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
302
+ #{ASCIIDOC_BLANK_HDR}
303
+ .Foreword.footnote:[A]
304
+
305
+ Text
306
+
307
+ [abstract]
308
+ == Abstract.footnote:[A]
309
+
310
+ Text
311
+
312
+ [heading=introduction]
313
+ == Introduction.footnote:[A]
314
+
315
+ === Introduction Subsection
316
+
317
+ [heading=acknowledgements]
318
+ == Acknowledgements.footnote:[A]
319
+
320
+ [.preface]
321
+ == Dedication
322
+
323
+ [heading=scope]
324
+ == Scope.footnote:[A]
325
+
326
+ Text
327
+
328
+ [bibliography,heading=normative references]
329
+ == Normative References.footnote:[A]
330
+
331
+ [bibliography,normative=true]
332
+ == Normative References 2.footnote:[A]
333
+
334
+ [heading=terms and definitions]
335
+ == Terms and Definitions.footnote:[A]
336
+
337
+ === Term1
338
+
339
+ [heading="terms and definitions"]
340
+ == Terms, Definitions, Symbols and Abbreviated Terms.footnote:[A]
341
+
342
+ [.nonterm]
343
+ === Introduction
344
+
345
+ ==== Intro 1
346
+
347
+ === Intro 2
348
+
349
+ [.nonterm]
350
+ ==== Intro 3
351
+
352
+ === Intro 4
353
+
354
+ ==== Intro 5
355
+
356
+ ===== Term1
357
+
358
+ === Normal Terms
359
+
360
+ ==== Term2
361
+
362
+ [heading=symbols and abbreviated terms]
363
+ === Symbols and Abbreviated Terms.footnote:[A]
364
+
365
+ [.nonterm]
366
+ ==== General
367
+
368
+ [heading=symbols]
369
+ ==== Symbols 1.footnote:[A]
370
+
371
+ [heading=abbreviated terms]
372
+ == Abbreviated Terms.footnote:[A]
373
+
374
+ == Clause 4
375
+
376
+ === Introduction
377
+
378
+ === Clause 4.2
379
+
380
+ == Terms and Definitions
381
+
382
+ [appendix]
383
+ == Annex.footnote:[A]
384
+
385
+ === Annex A.1
386
+
387
+ [bibliography,heading=bibliography]
388
+ == Bibliography.footnote:[A]
389
+
390
+ [bibliography,normative=false]
391
+ == Bibliography 2.footnote:[A]
392
+
393
+ === Bibliography Subsection
394
+
395
+ INPUT
396
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
397
+ <bibdata type='standard'>
398
+ <title language='en' format='text/plain'>Document title</title>
399
+ <language>en</language>
400
+ <script>Latn</script>
401
+ <abstract>
402
+ <p>Text</p>
403
+ </abstract>
404
+ <status>
405
+ <stage>published</stage>
406
+ </status>
407
+ <copyright>
408
+ <from>2020</from>
409
+ </copyright>
410
+ <ext>
411
+ <doctype>article</doctype>
412
+ </ext>
413
+ </bibdata>
414
+ <preface>
415
+ <abstract id='_'>
416
+ <title>Abstract</title>
417
+ <p id='_'>Text</p>
418
+ </abstract>
419
+ <foreword id='_' obligation='informative'>
420
+ <title>
421
+ Foreword
422
+ <fn reference='1'>
423
+ <p id='_'>A</p>
424
+ </fn>
425
+ </title>
426
+ <p id='_'>Text</p>
427
+ </foreword>
428
+ <introduction id='_' obligation='informative'>
429
+ <title>Introduction</title>
430
+ <clause id='_' inline-header='false' obligation='informative'>
431
+ <title>Introduction Subsection</title>
432
+ </clause>
433
+ </introduction>
434
+ <clause id='_' inline-header='false' obligation='informative'>
435
+ <title>Dedication</title>
436
+ </clause>
437
+ <acknowledgements id='_' obligation='informative'>
438
+ <title>
439
+ Acknowledgements
440
+ <fn reference='1'>
441
+ <p id='_'>A</p>
442
+ </fn>
443
+ </title>
444
+ </acknowledgements>
445
+ </preface>
446
+ <sections>
447
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
448
+ <title>
449
+ Scope
450
+ <fn reference='1'>
451
+ <p id='_'>A</p>
452
+ </fn>
453
+ </title>
454
+ <p id='_'>Text</p>
455
+ </clause>
456
+ <terms id='_' obligation='normative'>
457
+ <title>
458
+ Terms and definitions
459
+ <fn reference='1'>
460
+ <p id='_'>A</p>
461
+ </fn>
462
+ </title>
463
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
464
+ <term id='term-term1'>
465
+ <preferred>Term1</preferred>
466
+ </term>
467
+ </terms>
468
+ <clause id='_' inline-header='false' obligation='normative'>
469
+ <title>
470
+ Terms, Definitions, Symbols and Abbreviated Terms.
471
+ <fn reference='1'>
472
+ <p id='_'>A</p>
473
+ </fn>
474
+ </title>
475
+ <clause id='_' inline-header='false' obligation='normative'>
476
+ <title>Introduction</title>
477
+ <clause id='_' inline-header='false' obligation='normative'>
478
+ <title>Intro 1</title>
479
+ </clause>
480
+ </clause>
481
+ <clause id='_' inline-header='false' obligation='normative'>
482
+ <title>Intro 2</title>
483
+ <clause id='_' inline-header='false' obligation='normative'>
484
+ <title>Intro 3</title>
485
+ </clause>
486
+ </clause>
487
+ <clause id='_' inline-header='false' obligation='normative'>
488
+ <title>Intro 4</title>
489
+ <clause id='_' inline-header='false' obligation='normative'>
490
+ <title>Intro 5</title>
491
+ <clause id='_' inline-header='false' obligation='normative'>
492
+ <title>Term1</title>
493
+ </clause>
494
+ </clause>
495
+ </clause>
496
+ <clause id='_' inline-header='false' obligation='normative'>
497
+ <title>Normal Terms</title>
498
+ <clause id='_' inline-header='false' obligation='normative'>
499
+ <title>Term2</title>
500
+ </clause>
501
+ </clause>
502
+ <definitions id='_' obligation='normative'>
503
+ <title>
504
+ Symbols and abbreviated terms
505
+ <fn reference='1'>
506
+ <p id='_'>A</p>
507
+ </fn>
508
+ </title>
509
+ <clause id='_' inline-header='false' obligation='normative'>
510
+ <title>General</title>
511
+ </clause>
512
+ <definitions id='_' type='symbols' obligation='normative'>
513
+ <title>
514
+ Symbols
515
+ <fn reference='1'>
516
+ <p id='_'>A</p>
517
+ </fn>
518
+ </title>
519
+ </definitions>
520
+ </definitions>
521
+ </clause>
522
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
523
+ <title>
524
+ Abbreviated terms
525
+ <fn reference='1'>
526
+ <p id='_'>A</p>
527
+ </fn>
528
+ </title>
529
+ </definitions>
530
+ <clause id='_' inline-header='false' obligation='normative'>
531
+ <title>Clause 4</title>
532
+ <clause id='_' inline-header='false' obligation='normative'>
533
+ <title>Introduction</title>
534
+ </clause>
535
+ <clause id='_' inline-header='false' obligation='normative'>
536
+ <title>Clause 4.2</title>
537
+ </clause>
538
+ </clause>
539
+ <clause id='_' inline-header='false' obligation='normative'>
540
+ <title>Terms and Definitions</title>
541
+ </clause>
542
+ </sections>
543
+ <annex id='_' inline-header='false' obligation='normative'>
544
+ <title>
545
+ Annex.
546
+ <fn reference='1'>
547
+ <p id='_'>A</p>
548
+ </fn>
549
+ </title>
550
+ <clause id='_' inline-header='false' obligation='normative'>
551
+ <title>Annex A.1</title>
552
+ </clause>
553
+ </annex>
554
+ <bibliography>
555
+ <references id='_' normative='true' obligation='informative'>
556
+ <title>Normative references
557
+ <fn reference='1'>
558
+ <p id='_'>A</p>
559
+ </fn>
560
+ </title>
561
+ <p id='_'>There are no normative references in this document.</p>
562
+ </references>
563
+ <references id='_' normative='false' obligation='informative'>
564
+ <title>Bibliography
565
+ <fn reference='1'>
566
+ <p id='_'>A</p>
567
+ </fn>
568
+ </title>
569
+ </references>
570
+ <references id='_' normative='false' obligation='informative'>
571
+ <title>Bibliography.
572
+ <fn reference='1'>
573
+ <p id='_'>A</p>
574
+ </fn>
575
+ </title>
576
+ </references>
577
+ <clause id='_' obligation='informative'>
578
+ <title>Bibliography 2.
579
+ <fn reference='1'>
580
+ <p id='_'>A</p>
581
+ </fn>
582
+ </title>
583
+ <references id='_' normative='false' obligation='informative'>
584
+ <title>Bibliography Subsection</title>
585
+ </references>
586
+ </clause>
587
+ </bibliography>
588
+ </standard-document>
589
+ OUTPUT
590
+ end
591
+
592
+ it "processes section names, default to English" do
593
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
594
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":language: tlh\n:script: Latn\n:nodoc:")}
595
+ .Foreword
596
+
597
+ Text
598
+
599
+ [abstract]
600
+ == Abstract
601
+
602
+ Text
603
+
604
+ [heading=introduction]
605
+ == Introduction
606
+
607
+ === Introduction Subsection
608
+
609
+ [heading=acknowledgements]
610
+ == Acknowledgements
611
+
612
+ [.preface]
613
+ == Dedication
614
+
615
+ [heading=scope]
616
+ == Scope
617
+
618
+ Text
619
+
620
+ [bibliography,heading=normative references]
621
+ == Normative References
622
+
623
+ [bibliography,normative=true]
624
+ == Normative References 2
625
+
626
+ [heading=terms and definitions]
627
+ == Terms and Definitions
628
+
629
+ === Term1
630
+
631
+ [heading="terms and definitions"]
632
+ == Terms, Definitions, Symbols and Abbreviated Terms
633
+
634
+ [.nonterm]
635
+ === Introduction
636
+
637
+ ==== Intro 1
638
+
639
+ === Intro 2
640
+
641
+ [.nonterm]
642
+ ==== Intro 3
643
+
644
+ === Intro 4
645
+
646
+ ==== Intro 5
647
+
648
+ ===== Term1
649
+
650
+ === Normal Terms
651
+
652
+ ==== Term2
653
+
654
+ [heading=symbols and abbreviated terms]
655
+ === Symbols and Abbreviated Terms
656
+
657
+ [.nonterm]
658
+ ==== General
659
+
660
+ [heading=symbols]
661
+ ==== Symbols 1
662
+
663
+ [heading=abbreviated terms]
664
+ == Abbreviated Terms
665
+
666
+ == Clause 4
667
+
668
+ === Introduction
669
+
670
+ === Clause 4.2
671
+
672
+ == Terms and Definitions
673
+
674
+ [appendix]
675
+ == Annex
676
+
677
+ === Annex A.1
678
+
679
+ [bibliography,heading=bibliography]
680
+ == Bibliography
681
+
682
+ [bibliography,normative=false]
683
+ == Bibliography 2
684
+
685
+ === Bibliography Subsection
686
+
687
+ INPUT
688
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
689
+ <bibdata type='standard'>
690
+ <title language='en' format='text/plain'>Document title</title>
691
+ <language>tlh</language>
692
+ <script>Latn</script>
693
+ <abstract>
694
+ <p>Text</p>
695
+ </abstract>
696
+ <status>
697
+ <stage>published</stage>
698
+ </status>
699
+ <copyright>
700
+ <from>2020</from>
701
+ </copyright>
702
+ <ext>
703
+ <doctype>article</doctype>
704
+ </ext>
705
+ </bibdata>
706
+ <preface>
707
+ <abstract id='_'>
708
+ <title>Abstract</title>
709
+ <p id='_'>Text</p>
710
+ </abstract>
711
+ <foreword id='_' obligation='informative'>
712
+ <title>Foreword</title>
713
+ <p id='_'>Text</p>
714
+ </foreword>
715
+ <introduction id='_' obligation='informative'>
716
+ <title>Introduction</title>
717
+ <clause id='_' inline-header='false' obligation='informative'>
718
+ <title>Introduction Subsection</title>
719
+ </clause>
720
+ </introduction>
721
+ <clause id='_' inline-header='false' obligation='informative'>
722
+ <title>Dedication</title>
723
+ </clause>
724
+ <acknowledgements id='_' obligation='informative'>
725
+ <title>Acknowledgements</title>
726
+ </acknowledgements>
727
+ </preface>
728
+ <sections>
729
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
730
+ <title>Scope</title>
731
+ <p id='_'>Text</p>
732
+ </clause>
733
+ <terms id='_' obligation='normative'>
734
+ <title>Terms and definitions</title>
735
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
736
+ <term id='term-term1'>
737
+ <preferred>Term1</preferred>
738
+ </term>
739
+ </terms>
740
+ <clause id='_' inline-header='false' obligation='normative'>
741
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
742
+ <clause id='_' inline-header='false' obligation='normative'>
743
+ <title>Introduction</title>
744
+ <clause id='_' inline-header='false' obligation='normative'>
745
+ <title>Intro 1</title>
746
+ </clause>
747
+ </clause>
748
+ <clause id='_' inline-header='false' obligation='normative'>
749
+ <title>Intro 2</title>
750
+ <clause id='_' inline-header='false' obligation='normative'>
751
+ <title>Intro 3</title>
752
+ </clause>
753
+ </clause>
754
+ <clause id='_' inline-header='false' obligation='normative'>
755
+ <title>Intro 4</title>
756
+ <clause id='_' inline-header='false' obligation='normative'>
757
+ <title>Intro 5</title>
758
+ <clause id='_' inline-header='false' obligation='normative'>
759
+ <title>Term1</title>
760
+ </clause>
761
+ </clause>
762
+ </clause>
763
+ <clause id='_' inline-header='false' obligation='normative'>
764
+ <title>Normal Terms</title>
765
+ <clause id='_' inline-header='false' obligation='normative'>
766
+ <title>Term2</title>
767
+ </clause>
768
+ </clause>
769
+ <definitions id='_' obligation='normative'>
770
+ <title>Symbols and abbreviated terms</title>
771
+ <clause id='_' inline-header='false' obligation='normative'>
772
+ <title>General</title>
773
+ </clause>
774
+ <definitions id='_' type='symbols' obligation='normative'>
775
+ <title>Symbols</title>
776
+ </definitions>
777
+ </definitions>
778
+ </clause>
779
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
780
+ <title>Abbreviated terms</title>
781
+ </definitions>
782
+ <clause id='_' inline-header='false' obligation='normative'>
783
+ <title>Clause 4</title>
784
+ <clause id='_' inline-header='false' obligation='normative'>
785
+ <title>Introduction</title>
786
+ </clause>
787
+ <clause id='_' inline-header='false' obligation='normative'>
788
+ <title>Clause 4.2</title>
789
+ </clause>
790
+ </clause>
791
+ <clause id='_' inline-header='false' obligation='normative'>
792
+ <title>Terms and Definitions</title>
793
+ </clause>
794
+ </sections>
795
+ <annex id='_' inline-header='false' obligation='normative'>
796
+ <title>Annex</title>
797
+ <clause id='_' inline-header='false' obligation='normative'>
798
+ <title>Annex A.1</title>
799
+ </clause>
800
+ </annex>
801
+ <bibliography>
802
+ <references id='_' normative='true' obligation='informative'>
803
+ <title>Normative references</title>
804
+ <p id='_'>There are no normative references in this document.</p>
805
+ </references>
806
+ <references id='_' normative='false' obligation='informative'>
807
+ <title>Bibliography</title>
808
+ </references>
809
+ <references id='_' normative='false' obligation='informative'>
810
+ <title>Bibliography</title>
811
+ </references>
812
+ <clause id='_' obligation='informative'>
813
+ <title>Bibliography 2</title>
814
+ <references id='_' normative='false' obligation='informative'>
815
+ <title>Bibliography Subsection</title>
816
+ </references>
817
+ </clause>
818
+ </bibliography>
819
+ </standard-document>
820
+ OUTPUT
821
+ end
822
+
823
+ it "processes section names, French" do
824
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
825
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":language: fr\n:script: Latn\n:nodoc:")}
826
+ .Foreword
827
+
828
+ Text
829
+
830
+ [abstract]
831
+ == Abstract
832
+
833
+ Text
834
+
835
+ [heading=introduction]
836
+ == Introduction
837
+
838
+ === Introduction Subsection
839
+
840
+ [heading=acknowledgements]
841
+ == Acknowledgements
842
+
843
+ [.preface]
844
+ == Dedication
845
+
846
+ [heading=scope]
847
+ == Scope
848
+
849
+ Text
850
+
851
+ [bibliography,heading=normative references]
852
+ == Normative References
853
+
854
+ [bibliography,normative=true]
855
+ == Normative References 2
856
+
857
+ [heading=terms and definitions]
858
+ == Terms and Definitions
859
+
860
+ === Term1
861
+
862
+ [heading="terms and definitions"]
863
+ == Terms, Definitions, Symbols and Abbreviated Terms
864
+
865
+ [.nonterm]
866
+ === Introduction
867
+
868
+ ==== Intro 1
869
+
870
+ === Intro 2
871
+
872
+ [.nonterm]
873
+ ==== Intro 3
874
+
875
+ === Intro 4
876
+
877
+ ==== Intro 5
878
+
879
+ ===== Term1
880
+
881
+ === Normal Terms
882
+
883
+ ==== Term2
884
+
885
+ [heading=symbols and abbreviated terms]
886
+ === Symbols and Abbreviated Terms
887
+
888
+ [.nonterm]
889
+ ==== General
890
+
891
+ [heading=symbols]
892
+ ==== Symbols 1
893
+
894
+ [heading=abbreviated terms]
895
+ == Abbreviated Terms
896
+
897
+ == Clause 4
898
+
899
+ === Introduction
900
+
901
+ === Clause 4.2
902
+
903
+ == Terms and Definitions
904
+
905
+ [appendix]
906
+ == Annex
907
+
908
+ === Annex A.1
909
+
910
+ [bibliography,heading=bibliography]
911
+ == Bibliography
912
+
913
+ [bibliography,normative=false]
914
+ == Bibliography 2
915
+
916
+ === Bibliography Subsection
917
+
918
+ INPUT
919
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
920
+ <bibdata type='standard'>
921
+ <title language='en' format='text/plain'>Document title</title>
922
+ <language>fr</language>
923
+ <script>Latn</script>
924
+ <abstract>
925
+ <p>Text</p>
926
+ </abstract>
927
+ <status>
928
+ <stage>published</stage>
929
+ </status>
930
+ <copyright>
931
+ <from>2020</from>
932
+ </copyright>
933
+ <ext>
934
+ <doctype>article</doctype>
935
+ </ext>
936
+ </bibdata>
937
+ <preface>
938
+ <abstract id='_'>
939
+ <title>Résumé</title>
940
+ <p id='_'>Text</p>
941
+ </abstract>
942
+ <foreword id='_' obligation='informative'>
943
+ <title>Avant-propos</title>
944
+ <p id='_'>Text</p>
945
+ </foreword>
946
+ <introduction id='_' obligation='informative'>
947
+ <title>Introduction</title>
948
+ <clause id='_' inline-header='false' obligation='informative'>
949
+ <title>Introduction Subsection</title>
950
+ </clause>
951
+ </introduction>
952
+ <clause id='_' inline-header='false' obligation='informative'>
953
+ <title>Dedication</title>
954
+ </clause>
955
+ <acknowledgements id='_' obligation='informative'>
956
+ <title>Remerciements</title>
957
+ </acknowledgements>
958
+ </preface>
959
+ <sections>
960
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
961
+ <title>Domaine d’application</title>
962
+ <p id='_'>Text</p>
963
+ </clause>
964
+ <terms id='_' obligation='normative'>
965
+ <title>Terms et définitions</title>
966
+ <p id='_'>
967
+ Pour les besoins du présent document, les termes et définitions suivants
968
+ s’appliquent.
969
+ </p>
970
+ <term id='term-term1'>
971
+ <preferred>Term1</preferred>
972
+ </term>
973
+ </terms>
974
+ <clause id='_' inline-header='false' obligation='normative'>
975
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
976
+ <clause id='_' inline-header='false' obligation='normative'>
977
+ <title>Introduction</title>
978
+ <clause id='_' inline-header='false' obligation='normative'>
979
+ <title>Intro 1</title>
980
+ </clause>
981
+ </clause>
982
+ <clause id='_' inline-header='false' obligation='normative'>
983
+ <title>Intro 2</title>
984
+ <clause id='_' inline-header='false' obligation='normative'>
985
+ <title>Intro 3</title>
986
+ </clause>
987
+ </clause>
988
+ <clause id='_' inline-header='false' obligation='normative'>
989
+ <title>Intro 4</title>
990
+ <clause id='_' inline-header='false' obligation='normative'>
991
+ <title>Intro 5</title>
992
+ <clause id='_' inline-header='false' obligation='normative'>
993
+ <title>Term1</title>
994
+ </clause>
995
+ </clause>
996
+ </clause>
997
+ <clause id='_' inline-header='false' obligation='normative'>
998
+ <title>Normal Terms</title>
999
+ <clause id='_' inline-header='false' obligation='normative'>
1000
+ <title>Term2</title>
1001
+ </clause>
1002
+ </clause>
1003
+ <definitions id='_' obligation='normative'>
1004
+ <title>Symboles et termes abrégés</title>
1005
+ <clause id='_' inline-header='false' obligation='normative'>
1006
+ <title>General</title>
1007
+ </clause>
1008
+ <definitions id='_' type='symbols' obligation='normative'>
1009
+ <title>Symboles</title>
1010
+ </definitions>
1011
+ </definitions>
1012
+ </clause>
1013
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
1014
+ <title>Termes abrégés</title>
1015
+ </definitions>
1016
+ <clause id='_' inline-header='false' obligation='normative'>
1017
+ <title>Clause 4</title>
1018
+ <clause id='_' inline-header='false' obligation='normative'>
1019
+ <title>Introduction</title>
1020
+ </clause>
1021
+ <clause id='_' inline-header='false' obligation='normative'>
1022
+ <title>Clause 4.2</title>
1023
+ </clause>
1024
+ </clause>
1025
+ <clause id='_' inline-header='false' obligation='normative'>
1026
+ <title>Terms and Definitions</title>
1027
+ </clause>
1028
+ </sections>
1029
+ <annex id='_' inline-header='false' obligation='normative'>
1030
+ <title>Annex</title>
1031
+ <clause id='_' inline-header='false' obligation='normative'>
1032
+ <title>Annex A.1</title>
1033
+ </clause>
1034
+ </annex>
1035
+ <bibliography>
1036
+ <references id='_' normative='true' obligation='informative'>
1037
+ <title>Références normatives</title>
1038
+ <p id='_'>Le présent document ne contient aucune référence normative.</p>
1039
+ </references>
1040
+ <references id='_' normative='false' obligation='informative'>
1041
+ <title>Bibliographie</title>
1042
+ </references>
1043
+ <references id='_' normative='false' obligation='informative'>
1044
+ <title>Bibliography</title>
1045
+ </references>
1046
+ <clause id='_' obligation='informative'>
1047
+ <title>Bibliography 2</title>
1048
+ <references id='_' normative='false' obligation='informative'>
1049
+ <title>Bibliography Subsection</title>
1050
+ </references>
1051
+ </clause>
1052
+ </bibliography>
1053
+ </standard-document>
1054
+ OUTPUT
1055
+ end
1056
+
1057
+ it "processes section names, Simplified Chinese" do
1058
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1059
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":language: zh\n:script: Hans\n:nodoc:")}
1060
+ .Foreword
1061
+
1062
+ Text
1063
+
1064
+ [abstract]
1065
+ == Abstract
1066
+
1067
+ Text
1068
+
1069
+ [heading=introduction]
1070
+ == Introduction
1071
+
1072
+ === Introduction Subsection
1073
+
1074
+ [heading=acknowledgements]
1075
+ == Acknowledgements
1076
+
1077
+ [.preface]
1078
+ == Dedication
1079
+
1080
+ [heading=scope]
1081
+ == Scope
1082
+
1083
+ Text
1084
+
1085
+ [bibliography,heading=normative references]
1086
+ == Normative References
1087
+
1088
+ [bibliography,normative=true]
1089
+ == Normative References 2
1090
+
1091
+ [heading=terms and definitions]
1092
+ == Terms and Definitions
1093
+
1094
+ === Term1
1095
+
1096
+ [heading="terms and definitions"]
1097
+ == Terms, Definitions, Symbols and Abbreviated Terms
1098
+
1099
+ [.nonterm]
1100
+ === Introduction
1101
+
1102
+ ==== Intro 1
1103
+
1104
+ === Intro 2
1105
+
1106
+ [.nonterm]
1107
+ ==== Intro 3
1108
+
1109
+ === Intro 4
1110
+
1111
+ ==== Intro 5
1112
+
1113
+ ===== Term1
1114
+
1115
+ === Normal Terms
1116
+
1117
+ ==== Term2
1118
+
1119
+ [heading=symbols and abbreviated terms]
1120
+ === Symbols and Abbreviated Terms
1121
+
1122
+ [.nonterm]
1123
+ ==== General
1124
+
1125
+ [heading=symbols]
1126
+ ==== Symbols 1
1127
+
1128
+ [heading=abbreviated terms]
1129
+ == Abbreviated Terms
1130
+
1131
+ == Clause 4
1132
+
1133
+ === Introduction
1134
+
1135
+ === Clause 4.2
1136
+
1137
+ == Terms and Definitions
1138
+
1139
+ [appendix]
1140
+ == Annex
1141
+
1142
+ === Annex A.1
1143
+
1144
+ [bibliography,heading=bibliography]
1145
+ == Bibliography
1146
+
1147
+ [bibliography,normative=false]
1148
+ == Bibliography 2
1149
+
1150
+ === Bibliography Subsection
1151
+
1152
+ INPUT
1153
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
1154
+ <bibdata type='standard'>
1155
+ <title language='en' format='text/plain'>Document title</title>
1156
+ <language>zh</language>
1157
+ <script>Hans</script>
1158
+ <abstract>
1159
+ <p>Text</p>
1160
+ </abstract>
1161
+ <status>
1162
+ <stage>published</stage>
1163
+ </status>
1164
+ <copyright>
1165
+ <from>2020</from>
1166
+ </copyright>
1167
+ <ext>
1168
+ <doctype>article</doctype>
1169
+ </ext>
1170
+ </bibdata>
1171
+ <preface>
1172
+ <abstract id='_'>
1173
+ <title>摘要</title>
1174
+ <p id='_'>Text</p>
1175
+ </abstract>
1176
+ <foreword id='_' obligation='informative'>
1177
+ <title>前言</title>
1178
+ <p id='_'>Text</p>
1179
+ </foreword>
1180
+ <introduction id='_' obligation='informative'>
1181
+ <title>引言</title>
1182
+ <clause id='_' inline-header='false' obligation='informative'>
1183
+ <title>Introduction Subsection</title>
1184
+ </clause>
1185
+ </introduction>
1186
+ <clause id='_' inline-header='false' obligation='informative'>
1187
+ <title>Dedication</title>
1188
+ </clause>
1189
+ <acknowledgements id='_' obligation='informative'>
1190
+ <title>致謝</title>
1191
+ </acknowledgements>
1192
+ </preface>
1193
+ <sections>
1194
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
1195
+ <title>范围</title>
1196
+ <p id='_'>Text</p>
1197
+ </clause>
1198
+ <terms id='_' obligation='normative'>
1199
+ <title>术语和定义</title>
1200
+ <p id='_'>下列术语和定义适用于本文件。</p>
1201
+ <term id='term-term1'>
1202
+ <preferred>Term1</preferred>
1203
+ </term>
1204
+ </terms>
1205
+ <clause id='_' inline-header='false' obligation='normative'>
1206
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
1207
+ <clause id='_' inline-header='false' obligation='normative'>
1208
+ <title>Introduction</title>
1209
+ <clause id='_' inline-header='false' obligation='normative'>
1210
+ <title>Intro 1</title>
1211
+ </clause>
1212
+ </clause>
1213
+ <clause id='_' inline-header='false' obligation='normative'>
1214
+ <title>Intro 2</title>
1215
+ <clause id='_' inline-header='false' obligation='normative'>
1216
+ <title>Intro 3</title>
1217
+ </clause>
1218
+ </clause>
1219
+ <clause id='_' inline-header='false' obligation='normative'>
1220
+ <title>Intro 4</title>
1221
+ <clause id='_' inline-header='false' obligation='normative'>
1222
+ <title>Intro 5</title>
1223
+ <clause id='_' inline-header='false' obligation='normative'>
1224
+ <title>Term1</title>
1225
+ </clause>
1226
+ </clause>
1227
+ </clause>
1228
+ <clause id='_' inline-header='false' obligation='normative'>
1229
+ <title>Normal Terms</title>
1230
+ <clause id='_' inline-header='false' obligation='normative'>
1231
+ <title>Term2</title>
1232
+ </clause>
1233
+ </clause>
1234
+ <definitions id='_' obligation='normative'>
1235
+ <title>符号、代号和缩略语</title>
1236
+ <clause id='_' inline-header='false' obligation='normative'>
1237
+ <title>General</title>
1238
+ </clause>
1239
+ <definitions id='_' type='symbols' obligation='normative'>
1240
+ <title>符号</title>
1241
+ </definitions>
1242
+ </definitions>
1243
+ </clause>
1244
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
1245
+ <title>代号和缩略语</title>
1246
+ </definitions>
1247
+ <clause id='_' inline-header='false' obligation='normative'>
1248
+ <title>Clause 4</title>
1249
+ <clause id='_' inline-header='false' obligation='normative'>
1250
+ <title>Introduction</title>
1251
+ </clause>
1252
+ <clause id='_' inline-header='false' obligation='normative'>
1253
+ <title>Clause 4.2</title>
1254
+ </clause>
1255
+ </clause>
1256
+ <clause id='_' inline-header='false' obligation='normative'>
1257
+ <title>Terms and Definitions</title>
1258
+ </clause>
1259
+ </sections>
1260
+ <annex id='_' inline-header='false' obligation='normative'>
1261
+ <title>Annex</title>
1262
+ <clause id='_' inline-header='false' obligation='normative'>
1263
+ <title>Annex A.1</title>
1264
+ </clause>
1265
+ </annex>
1266
+ <bibliography>
1267
+ <references id='_' normative='true' obligation='informative'>
1268
+ <title>规范性引用文件</title>
1269
+ <p id='_'>本文件并没有规范性引用文件。</p>
1270
+ </references>
1271
+ <references id='_' normative='false' obligation='informative'>
1272
+ <title>参考文献</title>
1273
+ </references>
1274
+ <references id='_' normative='false' obligation='informative'>
1275
+ <title>Bibliography</title>
1276
+ </references>
1277
+ <clause id='_' obligation='informative'>
1278
+ <title>Bibliography 2</title>
1279
+ <references id='_' normative='false' obligation='informative'>
1280
+ <title>Bibliography Subsection</title>
1281
+ </references>
1282
+ </clause>
1283
+ </bibliography>
1284
+ </standard-document>
1285
+ OUTPUT
1286
+ end
1287
+
1288
+ it "processes section names, internationalisation file" do
1289
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
1290
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":i18nyaml: spec/assets/i18n.yaml")}
1291
+ .Foreword
1292
+
1293
+ Text
1294
+
1295
+ [abstract]
1296
+ == Abstract
1297
+
1298
+ Text
1299
+
1300
+ [heading=introduction]
1301
+ == Introduction
1302
+
1303
+ === Introduction Subsection
1304
+
1305
+ [heading=acknowledgements]
1306
+ == Acknowledgements
1307
+
1308
+ [.preface]
1309
+ == Dedication
1310
+
1311
+ [heading=scope]
1312
+ == Scope
1313
+
1314
+ Text
1315
+
1316
+ [bibliography,heading=normative references]
1317
+ == Normative References
1318
+
1319
+ [bibliography,normative=true]
1320
+ == Normative References 2
1321
+
1322
+ [heading=terms and definitions]
1323
+ == Terms and Definitions
1324
+
1325
+ === Term1
1326
+
1327
+ [heading="terms and definitions"]
1328
+ == Terms, Definitions, Symbols and Abbreviated Terms
1329
+
1330
+ [.nonterm]
1331
+ === Introduction
1332
+
1333
+ ==== Intro 1
1334
+
1335
+ === Intro 2
1336
+
1337
+ [.nonterm]
1338
+ ==== Intro 3
1339
+
1340
+ === Intro 4
1341
+
1342
+ ==== Intro 5
1343
+
1344
+ ===== Term1
1345
+
1346
+ === Normal Terms
1347
+
1348
+ ==== Term2
1349
+
1350
+ [heading=symbols and abbreviated terms]
1351
+ === Symbols and Abbreviated Terms
1352
+
1353
+ [.nonterm]
1354
+ ==== General
1355
+
1356
+ [heading=symbols]
1357
+ ==== Symbols 1
1358
+
1359
+ [heading=abbreviated terms]
1360
+ == Abbreviated Terms
1361
+
1362
+ == Clause 4
1363
+
1364
+ === Introduction
1365
+
1366
+ === Clause 4.2
1367
+
1368
+ == Terms and Definitions
1369
+
1370
+ [appendix]
1371
+ == Annex
1372
+
1373
+ === Annex A.1
1374
+
1375
+ [bibliography,heading=bibliography]
1376
+ == Bibliography
1377
+
1378
+ [bibliography,normative=false]
1379
+ == Bibliography 2
1380
+
1381
+ === Bibliography Subsection
1382
+
1383
+ INPUT
1384
+ <standard-document xmlns='https://www.metanorma.org/ns/standoc' type="semantic" version="#{Metanorma::Standoc::VERSION}">
1385
+ <bibdata type='standard'>
1386
+ <title language='en' format='text/plain'>Document title</title>
1387
+ <language>en</language>
1388
+ <script>Latn</script>
1389
+ <abstract>
1390
+ <p>Text</p>
1391
+ </abstract>
1392
+ <status>
1393
+ <stage>published</stage>
1394
+ </status>
1395
+ <copyright>
1396
+ <from>2020</from>
1397
+ </copyright>
1398
+ <ext>
1399
+ <doctype>article</doctype>
1400
+ </ext>
1401
+ </bibdata>
1402
+ <preface>
1403
+ <abstract id='_'>
1404
+ <title>Abstract</title>
1405
+ <p id='_'>Text</p>
1406
+ </abstract>
1407
+ <foreword id='_' obligation='informative'>
1408
+ <title>Antaŭparolo</title>
1409
+ <p id='_'>Text</p>
1410
+ </foreword>
1411
+ <introduction id='_' obligation='informative'>
1412
+ <title>Enkonduko</title>
1413
+ <clause id='_' inline-header='false' obligation='informative'>
1414
+ <title>Introduction Subsection</title>
1415
+ </clause>
1416
+ </introduction>
1417
+ <clause id='_' inline-header='false' obligation='informative'>
1418
+ <title>Dedication</title>
1419
+ </clause>
1420
+ <acknowledgements id='_' obligation='informative'>
1421
+ <title>Acknowledgements</title>
1422
+ </acknowledgements>
1423
+ </preface>
1424
+ <sections>
1425
+ <clause id='_' type='scope' inline-header='false' obligation='normative'>
1426
+ <title>Amplekso</title>
1427
+ <p id='_'>Text</p>
1428
+ </clause>
1429
+ <terms id='_' obligation='normative'>
1430
+ <title>Terms and definitions</title>
1431
+ <p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
1432
+ <term id='term-term1'>
1433
+ <preferred>Term1</preferred>
1434
+ </term>
1435
+ </terms>
1436
+ <clause id='_' inline-header='false' obligation='normative'>
1437
+ <title>Terms, Definitions, Symbols and Abbreviated Terms</title>
1438
+ <clause id='_' inline-header='false' obligation='normative'>
1439
+ <title>Introduction</title>
1440
+ <clause id='_' inline-header='false' obligation='normative'>
1441
+ <title>Intro 1</title>
1442
+ </clause>
1443
+ </clause>
1444
+ <clause id='_' inline-header='false' obligation='normative'>
1445
+ <title>Intro 2</title>
1446
+ <clause id='_' inline-header='false' obligation='normative'>
1447
+ <title>Intro 3</title>
1448
+ </clause>
1449
+ </clause>
1450
+ <clause id='_' inline-header='false' obligation='normative'>
1451
+ <title>Intro 4</title>
1452
+ <clause id='_' inline-header='false' obligation='normative'>
1453
+ <title>Intro 5</title>
1454
+ <clause id='_' inline-header='false' obligation='normative'>
1455
+ <title>Term1</title>
1456
+ </clause>
1457
+ </clause>
1458
+ </clause>
1459
+ <clause id='_' inline-header='false' obligation='normative'>
1460
+ <title>Normal Terms</title>
1461
+ <clause id='_' inline-header='false' obligation='normative'>
1462
+ <title>Term2</title>
1463
+ </clause>
1464
+ </clause>
1465
+ <definitions id='_' obligation='normative'>
1466
+ <title>Symbols and abbreviated terms</title>
1467
+ <clause id='_' inline-header='false' obligation='normative'>
1468
+ <title>General</title>
1469
+ </clause>
1470
+ <definitions id='_' type='symbols' obligation='normative'>
1471
+ <title>Simboloj kai mallongigitaj terminoj</title>
1472
+ </definitions>
1473
+ </definitions>
1474
+ </clause>
1475
+ <definitions id='_' type='abbreviated_terms' obligation='normative'>
1476
+ <title>Abbreviated terms</title>
1477
+ </definitions>
1478
+ <clause id='_' inline-header='false' obligation='normative'>
1479
+ <title>Clause 4</title>
1480
+ <clause id='_' inline-header='false' obligation='normative'>
1481
+ <title>Introduction</title>
1482
+ </clause>
1483
+ <clause id='_' inline-header='false' obligation='normative'>
1484
+ <title>Clause 4.2</title>
1485
+ </clause>
1486
+ </clause>
1487
+ <clause id='_' inline-header='false' obligation='normative'>
1488
+ <title>Terms and Definitions</title>
1489
+ </clause>
1490
+ </sections>
1491
+ <annex id='_' inline-header='false' obligation='normative'>
1492
+ <title>Annex</title>
1493
+ <clause id='_' inline-header='false' obligation='normative'>
1494
+ <title>Annex A.1</title>
1495
+ </clause>
1496
+ </annex>
1497
+ <bibliography>
1498
+ <references id='_' normative='true' obligation='informative'>
1499
+ <title>Normaj citaĵoj</title>
1500
+ <p id='_'>There are no normative references in this document.</p>
1501
+ </references>
1502
+ <references id='_' normative='false' obligation='informative'>
1503
+ <title>Bibliografio</title>
1504
+ </references>
1505
+ <references id='_' normative='false' obligation='informative'>
1506
+ <title>Bibliography</title>
1507
+ </references>
1508
+ <clause id='_' obligation='informative'>
1509
+ <title>Bibliography 2</title>
1510
+ <references id='_' normative='false' obligation='informative'>
1511
+ <title>Bibliography Subsection</title>
1512
+ </references>
1513
+ </clause>
1514
+ </bibliography>
1515
+ </standard-document>
1516
+ OUTPUT
1517
+ end
1518
+
1519
+ end