metanorma-standoc 2.2.5 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/html/htmlstyle.css +1 -1
  3. data/lib/metanorma/standoc/base.rb +4 -5
  4. data/lib/metanorma/standoc/basicdoc.rng +0 -27
  5. data/lib/metanorma/standoc/biblio-standoc.rng +164 -0
  6. data/lib/metanorma/standoc/biblio.rng +50 -18
  7. data/lib/metanorma/standoc/cleanup.rb +18 -17
  8. data/lib/metanorma/standoc/cleanup_amend.rb +2 -2
  9. data/lib/metanorma/standoc/cleanup_asciibib.rb +110 -0
  10. data/lib/metanorma/standoc/cleanup_biblio.rb +7 -112
  11. data/lib/metanorma/standoc/cleanup_block.rb +7 -6
  12. data/lib/metanorma/standoc/cleanup_boilerplate.rb +6 -6
  13. data/lib/metanorma/standoc/cleanup_inline.rb +2 -2
  14. data/lib/metanorma/standoc/cleanup_maths.rb +12 -4
  15. data/lib/metanorma/standoc/cleanup_section.rb +19 -9
  16. data/lib/metanorma/standoc/cleanup_symbols.rb +14 -7
  17. data/lib/metanorma/standoc/cleanup_text.rb +19 -6
  18. data/lib/metanorma/standoc/cleanup_toc.rb +1 -2
  19. data/lib/metanorma/standoc/cleanup_xref.rb +55 -14
  20. data/lib/metanorma/standoc/inline.rb +29 -12
  21. data/lib/metanorma/standoc/isodoc-compile.rng +7 -0
  22. data/lib/metanorma/standoc/isodoc.rng +69 -207
  23. data/lib/metanorma/standoc/ref_utility.rb +1 -0
  24. data/lib/metanorma/standoc/render.rb +10 -1
  25. data/lib/metanorma/standoc/section.rb +10 -3
  26. data/lib/metanorma/standoc/utils.rb +6 -1
  27. data/lib/metanorma/standoc/validate.rb +9 -9
  28. data/lib/metanorma/standoc/version.rb +1 -1
  29. data/metanorma-standoc.gemspec +5 -3
  30. metadata +7 -141
  31. data/.github/workflows/rake.yml +0 -15
  32. data/.github/workflows/release.yml +0 -24
  33. data/Rakefile +0 -8
  34. data/bin/rspec +0 -18
  35. data/spec/assets/a1.adoc +0 -8
  36. data/spec/assets/a2.adoc +0 -10
  37. data/spec/assets/a3.adoc +0 -9
  38. data/spec/assets/a3a.adoc +0 -7
  39. data/spec/assets/a4.adoc +0 -4
  40. data/spec/assets/boilerplate.xml +0 -4
  41. data/spec/assets/codes.yml +0 -695
  42. data/spec/assets/correct.png +0 -0
  43. data/spec/assets/corrupt.png +0 -0
  44. data/spec/assets/header.html +0 -7
  45. data/spec/assets/html-override.css +0 -1
  46. data/spec/assets/html.scss +0 -13
  47. data/spec/assets/htmlcover.html +0 -4
  48. data/spec/assets/htmlintro.html +0 -5
  49. data/spec/assets/i18n.yaml +0 -17
  50. data/spec/assets/iso.adoc +0 -10
  51. data/spec/assets/iso.headless.html +0 -33
  52. data/spec/assets/iso.xml +0 -8
  53. data/spec/assets/iso123.rxl +0 -107
  54. data/spec/assets/rice_image1.png +0 -0
  55. data/spec/assets/scripts.html +0 -3
  56. data/spec/assets/std.css +0 -2
  57. data/spec/assets/word-override.css +0 -1
  58. data/spec/assets/word.scss +0 -13
  59. data/spec/assets/wordcover.html +0 -3
  60. data/spec/assets/wordintro.html +0 -4
  61. data/spec/assets/xref_error.adoc +0 -8
  62. data/spec/examples/103_01_02.html +0 -247
  63. data/spec/examples/codes_table.html +0 -3174
  64. data/spec/examples/datamodel/address_class_profile.adoc +0 -5
  65. data/spec/examples/datamodel/address_class_profile.presentation.xml +0 -14
  66. data/spec/examples/datamodel/address_component_profile.adoc +0 -5
  67. data/spec/examples/datamodel/blank_definition_profile.adoc +0 -5
  68. data/spec/examples/datamodel/common_models_diagram.adoc +0 -5
  69. data/spec/examples/datamodel/models/models/AddressClassProfile.yml +0 -90
  70. data/spec/examples/datamodel/models/models/AddressComponentProfile.yml +0 -63
  71. data/spec/examples/datamodel/models/models/AddressComponentSpecification.yml +0 -15
  72. data/spec/examples/datamodel/models/models/AddressProfile.yml +0 -36
  73. data/spec/examples/datamodel/models/models/AttributeProfile.yml +0 -32
  74. data/spec/examples/datamodel/models/models/InterchangeAddressClassProfile.yml +0 -79
  75. data/spec/examples/datamodel/models/models/Localization copy.yml +0 -23
  76. data/spec/examples/datamodel/models/models/Localization.yml +0 -23
  77. data/spec/examples/datamodel/models/models/ProfileCompliantAddress.yml +0 -36
  78. data/spec/examples/datamodel/models/models/ProfileCompliantAddressComponent.yml +0 -15
  79. data/spec/examples/datamodel/models/models/Signature.yml +0 -20
  80. data/spec/examples/datamodel/models/models/SignatureBlankDefinition.yml +0 -20
  81. data/spec/examples/datamodel/models/models/TextDirectionCode copy.yml +0 -16
  82. data/spec/examples/datamodel/models/models/TextDirectionCode.yml +0 -16
  83. data/spec/examples/datamodel/models/models/Validity.yml +0 -14
  84. data/spec/examples/datamodel/models/models/iso19160-1/Address.yml +0 -22
  85. data/spec/examples/datamodel/models/models/iso19160-1/AddressComponent.yml +0 -2
  86. data/spec/examples/datamodel/models/style.uml.inc +0 -37
  87. data/spec/examples/datamodel/models/views/CommonModels.yml +0 -9
  88. data/spec/examples/datamodel/models/views/TopDown.yml +0 -62
  89. data/spec/examples/datamodel/top_down_diagram.adoc +0 -5
  90. data/spec/examples/english.yaml +0 -69
  91. data/spec/examples/iso_123_.xml +0 -46
  92. data/spec/examples/iso_123_all_parts.xml +0 -46
  93. data/spec/examples/iso_123_no_year_note.xml +0 -47
  94. data/spec/examples/iso_124_.xml +0 -42
  95. data/spec/examples/iso_216_.xml +0 -48
  96. data/spec/examples/iso_iec_12382_.xml +0 -49
  97. data/spec/examples/rice.adoc +0 -715
  98. data/spec/examples/rice.preview.html +0 -1877
  99. data/spec/examples/rice.sh +0 -4
  100. data/spec/examples/rice_images/rice_image1.png +0 -0
  101. data/spec/examples/rice_images/rice_image2.png +0 -0
  102. data/spec/examples/rice_images/rice_image3_1.png +0 -0
  103. data/spec/examples/rice_images/rice_image3_2.png +0 -0
  104. data/spec/examples/rice_images/rice_image3_3.png +0 -0
  105. data/spec/fixtures/action_schemaexpg1.svg +0 -122
  106. data/spec/fixtures/datamodel_description_sections_tree.xml +0 -327
  107. data/spec/fixtures/diagram_definitions.lutaml +0 -22
  108. data/spec/fixtures/macros_datamodel/address_class_profile.xml +0 -149
  109. data/spec/fixtures/macros_datamodel/address_component_profile.xml +0 -71
  110. data/spec/fixtures/macros_datamodel/blank_definition_profile.xml +0 -51
  111. data/spec/fixtures/macros_datamodel/common_models_diagram.xml +0 -7
  112. data/spec/fixtures/macros_datamodel/top_down_diagram.xml +0 -7
  113. data/spec/fixtures/test.exp +0 -121
  114. data/spec/fixtures/test.xmi +0 -9250
  115. data/spec/metanorma/base_spec.rb +0 -1125
  116. data/spec/metanorma/biblio_spec.rb +0 -1004
  117. data/spec/metanorma/blank_spec.rb +0 -37
  118. data/spec/metanorma/blocks_spec.rb +0 -1784
  119. data/spec/metanorma/cleanup_blocks_spec.rb +0 -1099
  120. data/spec/metanorma/cleanup_sections_spec.rb +0 -1850
  121. data/spec/metanorma/cleanup_spec.rb +0 -1920
  122. data/spec/metanorma/cleanup_terms_spec.rb +0 -1543
  123. data/spec/metanorma/datamodel/attributes_table_preprocessor_spec.rb +0 -111
  124. data/spec/metanorma/datamodel/diagram_preprocessor_spec.rb +0 -72
  125. data/spec/metanorma/inline_spec.rb +0 -724
  126. data/spec/metanorma/isobib_cache_spec.rb +0 -742
  127. data/spec/metanorma/lists_spec.rb +0 -232
  128. data/spec/metanorma/macros_concept_spec.rb +0 -1052
  129. data/spec/metanorma/macros_json2text_spec.rb +0 -10
  130. data/spec/metanorma/macros_plantuml_spec.rb +0 -402
  131. data/spec/metanorma/macros_spec.rb +0 -1183
  132. data/spec/metanorma/macros_yaml2text_spec.rb +0 -10
  133. data/spec/metanorma/processor_spec.rb +0 -96
  134. data/spec/metanorma/refs_spec.rb +0 -2807
  135. data/spec/metanorma/reqt_spec.rb +0 -130
  136. data/spec/metanorma/section_spec.rb +0 -1325
  137. data/spec/metanorma/table_spec.rb +0 -474
  138. data/spec/metanorma/validate_spec.rb +0 -886
  139. data/spec/spec_helper.rb +0 -290
  140. data/spec/support/shared_examples/structured_data_2_text_preprocessor.rb +0 -781
  141. data/spec/vcr_cassettes/bsi16341.yml +0 -488
  142. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +0 -611
  143. data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +0 -149
  144. data/spec/vcr_cassettes/hide_refs.yml +0 -587
  145. data/spec/vcr_cassettes/isobib_get_123.yml +0 -149
  146. data/spec/vcr_cassettes/isobib_get_123_1.yml +0 -295
  147. data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +0 -385
  148. data/spec/vcr_cassettes/isobib_get_123_2.yml +0 -295
  149. data/spec/vcr_cassettes/isobib_get_123_2001.yml +0 -149
  150. data/spec/vcr_cassettes/isobib_get_124.yml +0 -149
  151. data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +0 -351
  152. data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +0 -560
  153. data/spec/vcr_cassettes/std-link.yml +0 -149
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12bb8cacaa61b510652a691e358e62e0e2e4f4ea1ac37dcff09f394b097051a9
4
- data.tar.gz: 714fa0c071097b0817e3b95c5066fbd181634f1b7f09cff04e2c1e5eb45b385a
3
+ metadata.gz: c59c6e517b305ec3559d4948767575ba032d877714800712e883bc2a0a561e6b
4
+ data.tar.gz: eeb0aaf07ac2ea303921b2ed855981b834f9fb8de4e06b708611852fb7465123
5
5
  SHA512:
6
- metadata.gz: 4a45f4013300b1c263e7f99ff50605e3576157afaacb4710c7a1f9b14c2e1ac6a624737be9a87e6a4ca3205756451b9a7cacde8df4bc8491d508121d5e821772
7
- data.tar.gz: 0c5bdb3f7a121998082b101488352bba31cad34abedf1f7fb1845cf25438c671545e3c65d09ec6a5bf06a075c8f311edbe4f61d210f470b1da009c71c8ea7627
6
+ metadata.gz: 7a91ae88a07c545c1c03f0845d94f38db34cc1128d7c7274eb49cbd2dd509ea8ca02da007e1de78b0d91d773c7eec6798206613eacda9e6322ebc3b0ab67f37b
7
+ data.tar.gz: 58af55addb78a590e2389dbce06cc29977bda866924c80e042047b85877f9374407dfb5f2b1679b8766bfd12ed0ce9e4fa7a339b88d333099666e5b169afcf09
@@ -368,7 +368,7 @@ div.figure {
368
368
  font-weight: 700;
369
369
  font-size: 1em;
370
370
  text-align: center; }
371
- div.figure > img {
371
+ div.figure > img, div.figure > svg {
372
372
  margin-left: auto;
373
373
  margin-right: auto;
374
374
  display: block;
@@ -41,6 +41,7 @@ module Metanorma
41
41
  def init_vars
42
42
  @fn_number ||= 0
43
43
  @refids = Set.new
44
+ @anchor_alias = {}
44
45
  @anchors = {}
45
46
  @internal_eref_namespaces = []
46
47
  @seen_headers = []
@@ -56,6 +57,7 @@ module Metanorma
56
57
  @boilerplateauthority = node.attr("boilerplate-authority")
57
58
  @embed_hdr = node.attr("embed_hdr")
58
59
  @document_scheme = node.attr("document-scheme")
60
+ @xrefstyle = node.attr("xrefstyle")
59
61
  end
60
62
 
61
63
  def init_processing(node)
@@ -129,9 +131,7 @@ module Metanorma
129
131
 
130
132
  def document1(node)
131
133
  init(node)
132
- ret = makexml(node)
133
- .to_xml(encoding: "UTF-8", indent: 2,
134
- save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
134
+ ret = to_xml(makexml(node))
135
135
  outputs(node, ret) unless node.attr("nodoc") || !node.attr("docfile")
136
136
  ret
137
137
  end
@@ -162,8 +162,7 @@ module Metanorma
162
162
 
163
163
  def clean_abort(msg, file = nil)
164
164
  if file
165
- doc = file.to_xml(encoding: "UTF-8", indent: 2,
166
- save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
165
+ doc = to_xml(file)
167
166
  File.open("#{@filename}.xml.abort", "w:UTF-8") { |f| f.write(doc) }
168
167
  end
169
168
  clean_exit
@@ -1,10 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <include href="biblio.rng">
4
- <start>
5
- <ref name="document"/>
6
- </start>
7
- </include>
8
3
  <define name="document">
9
4
  <element name="document">
10
5
  <optional>
@@ -1125,26 +1120,4 @@
1125
1120
  </zeroOrMore>
1126
1121
  </element>
1127
1122
  </define>
1128
- <define name="ext">
1129
- <element name="ext">
1130
- <ref name="BibDataExtensionType"/>
1131
- </element>
1132
- </define>
1133
- <define name="BibDataExtensionType">
1134
- <ref name="doctype"/>
1135
- </define>
1136
- <define name="doctype">
1137
- <element name="doctype">
1138
- <ref name="DocumentType"/>
1139
- </element>
1140
- </define>
1141
- <define name="DocumentType">
1142
- <value>document</value>
1143
- </define>
1144
- <define name="BibData">
1145
- <ref name="BibliographicItem"/>
1146
- <optional>
1147
- <ref name="ext"/>
1148
- </optional>
1149
- </define>
1150
1123
  </grammar>
@@ -0,0 +1,164 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <grammar xmlns="http://relaxng.org/ns/structure/1.0">
3
+ <!--
4
+ Add-ons to biblio.rnc for standoc model: defines the extension point BibDataExtensionType
5
+ of relaton
6
+
7
+ Specialisations as for biblio.rnc. Extension point can be redefined completely for a flavour of standoc
8
+ (SDO); but other elements in Bibdata can only be extended (more specialised vocabularies for Bibdata)
9
+ -->
10
+ <include href="biblio.rng">
11
+ <define name="BibData">
12
+ <ref name="BibliographicItem"/>
13
+ <optional>
14
+ <ref name="ext"/>
15
+ </optional>
16
+ </define>
17
+ </include>
18
+ <define name="ext">
19
+ <element name="ext">
20
+ <ref name="BibDataExtensionType"/>
21
+ </element>
22
+ </define>
23
+ <define name="BibDataExtensionType">
24
+ <optional>
25
+ <attribute name="schema-version"/>
26
+ </optional>
27
+ <ref name="doctype"/>
28
+ <optional>
29
+ <ref name="docsubtype"/>
30
+ </optional>
31
+ <optional>
32
+ <ref name="editorialgroup"/>
33
+ </optional>
34
+ <zeroOrMore>
35
+ <ref name="ics"/>
36
+ </zeroOrMore>
37
+ <zeroOrMore>
38
+ <ref name="structuredidentifier"/>
39
+ </zeroOrMore>
40
+ </define>
41
+ <define name="doctype">
42
+ <element name="doctype">
43
+ <optional>
44
+ <attribute name="abbreviation"/>
45
+ </optional>
46
+ <ref name="DocumentType"/>
47
+ </element>
48
+ </define>
49
+ <define name="DocumentType">
50
+ <value>document</value>
51
+ </define>
52
+ <define name="docsubtype">
53
+ <element name="subdoctype">
54
+ <ref name="DocumentSubtype"/>
55
+ </element>
56
+ </define>
57
+ <define name="DocumentSubtype">
58
+ <text/>
59
+ </define>
60
+ <define name="editorialgroup">
61
+ <element name="editorialgroup">
62
+ <oneOrMore>
63
+ <ref name="technical-committee"/>
64
+ </oneOrMore>
65
+ </element>
66
+ </define>
67
+ <define name="technical-committee">
68
+ <element name="technical-committee">
69
+ <ref name="IsoWorkgroup"/>
70
+ </element>
71
+ </define>
72
+ <define name="IsoWorkgroup">
73
+ <optional>
74
+ <attribute name="number"/>
75
+ </optional>
76
+ <optional>
77
+ <attribute name="type"/>
78
+ </optional>
79
+ <optional>
80
+ <attribute name="identifier"/>
81
+ </optional>
82
+ <optional>
83
+ <attribute name="prefix"/>
84
+ </optional>
85
+ <text/>
86
+ </define>
87
+ <define name="ics">
88
+ <element name="ics">
89
+ <element name="code">
90
+ <text/>
91
+ </element>
92
+ <optional>
93
+ <element name="text">
94
+ <text/>
95
+ </element>
96
+ </optional>
97
+ </element>
98
+ </define>
99
+ <define name="structuredidentifier">
100
+ <element name="structuredidentifier">
101
+ <optional>
102
+ <attribute name="type"/>
103
+ </optional>
104
+ <oneOrMore>
105
+ <element name="agency">
106
+ <text/>
107
+ </element>
108
+ </oneOrMore>
109
+ <optional>
110
+ <element name="class">
111
+ <text/>
112
+ </element>
113
+ </optional>
114
+ <element name="docnumber">
115
+ <text/>
116
+ </element>
117
+ <optional>
118
+ <element name="partnumber">
119
+ <text/>
120
+ </element>
121
+ </optional>
122
+ <optional>
123
+ <element name="edition">
124
+ <text/>
125
+ </element>
126
+ </optional>
127
+ <optional>
128
+ <element name="version">
129
+ <text/>
130
+ </element>
131
+ </optional>
132
+ <optional>
133
+ <element name="supplementtype">
134
+ <text/>
135
+ </element>
136
+ </optional>
137
+ <optional>
138
+ <element name="supplementnumber">
139
+ <text/>
140
+ </element>
141
+ </optional>
142
+ <optional>
143
+ <element name="amendment">
144
+ <text/>
145
+ </element>
146
+ </optional>
147
+ <optional>
148
+ <element name="corrigendum">
149
+ <text/>
150
+ </element>
151
+ </optional>
152
+ <optional>
153
+ <element name="language">
154
+ <text/>
155
+ </element>
156
+ </optional>
157
+ <optional>
158
+ <element name="year">
159
+ <text/>
160
+ </element>
161
+ </optional>
162
+ </element>
163
+ </define>
164
+ </grammar>
@@ -33,9 +33,10 @@
33
33
  <param name="pattern">([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?</param>
34
34
  </data>
35
35
  </define>
36
- <start>
37
- <ref name="bibitem"/>
38
- </start>
36
+ <!-- start = bibitem -->
37
+ <define name="BibData">
38
+ <ref name="BibliographicItem"/>
39
+ </define>
39
40
  <define name="status">
40
41
  <element name="status">
41
42
  <ref name="stage"/>
@@ -170,27 +171,30 @@
170
171
  </define>
171
172
  <define name="contributor">
172
173
  <element name="contributor">
173
- <zeroOrMore>
174
+ <oneOrMore>
174
175
  <ref name="role"/>
175
- </zeroOrMore>
176
+ </oneOrMore>
176
177
  <ref name="ContributorInfo"/>
177
178
  </element>
178
179
  </define>
179
180
  <define name="role">
180
181
  <element name="role">
181
- <optional>
182
- <attribute name="type">
183
- <choice>
184
- <value>author</value>
185
- <value>performer</value>
186
- <value>publisher</value>
187
- <value>editor</value>
188
- <value>adapter</value>
189
- <value>translator</value>
190
- <value>distributor</value>
191
- </choice>
192
- </attribute>
193
- </optional>
182
+ <attribute name="type">
183
+ <choice>
184
+ <value>author</value>
185
+ <value>performer</value>
186
+ <value>publisher</value>
187
+ <value>editor</value>
188
+ <value>adapter</value>
189
+ <value>translator</value>
190
+ <value>distributor</value>
191
+ <value>realizer</value>
192
+ <value>owner</value>
193
+ <value>authorizer</value>
194
+ <value>enabler</value>
195
+ <value>subject</value>
196
+ </choice>
197
+ </attribute>
194
198
  <zeroOrMore>
195
199
  <ref name="roledescription"/>
196
200
  </zeroOrMore>
@@ -512,6 +516,17 @@
512
516
  </define>
513
517
  <define name="localityStack">
514
518
  <element name="localityStack">
519
+ <optional>
520
+ <attribute name="connective">
521
+ <choice>
522
+ <value>and</value>
523
+ <value>or</value>
524
+ <value>from</value>
525
+ <value>to</value>
526
+ <value/>
527
+ </choice>
528
+ </attribute>
529
+ </optional>
515
530
  <zeroOrMore>
516
531
  <ref name="locality"/>
517
532
  </zeroOrMore>
@@ -524,6 +539,17 @@
524
539
  </define>
525
540
  <define name="sourceLocalityStack">
526
541
  <element name="sourceLocalityStack">
542
+ <optional>
543
+ <attribute name="connective">
544
+ <choice>
545
+ <value>and</value>
546
+ <value>or</value>
547
+ <value>from</value>
548
+ <value>to</value>
549
+ <value/>
550
+ </choice>
551
+ </attribute>
552
+ </optional>
527
553
  <zeroOrMore>
528
554
  <ref name="sourceLocality"/>
529
555
  </zeroOrMore>
@@ -626,6 +652,9 @@
626
652
  <ref name="BibItemType"/>
627
653
  </attribute>
628
654
  </optional>
655
+ <optional>
656
+ <attribute name="schema-version"/>
657
+ </optional>
629
658
  <optional>
630
659
  <ref name="fetched"/>
631
660
  </optional>
@@ -720,6 +749,9 @@
720
749
  <ref name="BibItemType"/>
721
750
  </attribute>
722
751
  </optional>
752
+ <optional>
753
+ <attribute name="schema-version"/>
754
+ </optional>
723
755
  <optional>
724
756
  <ref name="fetched"/>
725
757
  </optional>
@@ -5,6 +5,7 @@ require_relative "./cleanup_block"
5
5
  require_relative "./cleanup_table"
6
6
  require_relative "./cleanup_footnotes"
7
7
  require_relative "./cleanup_ref"
8
+ require_relative "./cleanup_asciibib"
8
9
  require_relative "./cleanup_biblio"
9
10
  require_relative "./cleanup_boilerplate"
10
11
  require_relative "./cleanup_section"
@@ -26,31 +27,33 @@ module Metanorma
26
27
  def cleanup(xmldoc)
27
28
  element_name_cleanup(xmldoc)
28
29
  passthrough_cleanup(xmldoc)
29
- sections_cleanup(xmldoc)
30
+ sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup
30
31
  obligations_cleanup(xmldoc)
31
32
  para_index_cleanup(xmldoc)
32
33
  block_index_cleanup(xmldoc)
33
34
  table_cleanup(xmldoc)
34
35
  formula_cleanup(xmldoc)
35
36
  form_cleanup(xmldoc)
36
- sourcecode_cleanup(xmldoc)
37
+ sourcecode_cleanup(xmldoc) # feeds: callout_cleanup
37
38
  figure_cleanup(xmldoc)
39
+ requirement_cleanup(xmldoc) # feeds: xref_cleanup
38
40
  element_name_cleanup(xmldoc)
39
- ref_cleanup(xmldoc)
41
+ ref_cleanup(xmldoc) # feeds: bibitem_cleanup
40
42
  note_cleanup(xmldoc)
41
43
  clausebefore_cleanup(xmldoc)
42
44
  floatingtitle_cleanup(xmldoc)
43
- bibitem_cleanup(xmldoc)
45
+ bibitem_cleanup(xmldoc) # feeds: normref_cleanup, biblio_cleanup,
46
+ # reference_names, bpart_cleanup
44
47
  normref_cleanup(xmldoc)
45
48
  biblio_cleanup(xmldoc)
46
49
  reference_names(xmldoc)
47
- symbols_cleanup(xmldoc)
48
- xref_cleanup(xmldoc)
49
- concept_cleanup(xmldoc)
50
- related_cleanup(xmldoc)
51
- origin_cleanup(xmldoc)
50
+ symbols_cleanup(xmldoc) # feeds: termdef_cleanup
51
+ xref_cleanup(xmldoc) # feeds: concept_cleanup, origin_cleanup
52
+ concept_cleanup(xmldoc) # feeds: related_cleanup, termdef_cleanup
53
+ related_cleanup(xmldoc) # feeds: termdef_cleanup
54
+ origin_cleanup(xmldoc) # feeds: termdef_cleanup
52
55
  bookmark_cleanup(xmldoc)
53
- termdef_cleanup(xmldoc)
56
+ termdef_cleanup(xmldoc) # feeds: iev_cleanup, term_index_cleanup
54
57
  RelatonIev::iev_cleanup(xmldoc, @bibdb)
55
58
  element_name_cleanup(xmldoc)
56
59
  term_index_cleanup(xmldoc)
@@ -60,10 +63,9 @@ module Metanorma
60
63
  footnote_cleanup(xmldoc)
61
64
  mathml_cleanup(xmldoc)
62
65
  script_cleanup(xmldoc)
63
- docidentifier_cleanup(xmldoc)
64
- requirement_cleanup(xmldoc)
66
+ docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup
65
67
  bibdata_cleanup(xmldoc)
66
- svgmap_cleanup(xmldoc)
68
+ svgmap_cleanup(xmldoc) # feeds: img_cleanup
67
69
  boilerplate_cleanup(xmldoc)
68
70
  toc_cleanup(xmldoc)
69
71
  metadata_cleanup(xmldoc)
@@ -127,8 +129,8 @@ module Metanorma
127
129
 
128
130
  def variant_cleanup1(elem)
129
131
  elem.xpath("./variant").each do |n|
130
- if n.at_xpath("preceding-sibling::node()"\
131
- "[not(self::text()[not(normalize-space())])][1]"\
132
+ if n.at_xpath("preceding-sibling::node()" \
133
+ "[not(self::text()[not(normalize-space())])][1]" \
132
134
  "[self::variantwrap]")
133
135
  n.previous_element << n
134
136
  else
@@ -151,8 +153,7 @@ module Metanorma
151
153
  def metadata_cleanup(xmldoc)
152
154
  return if @metadata_attrs.nil? || @metadata_attrs.empty?
153
155
 
154
- ins = xmldoc.at("//misc-container") ||
155
- xmldoc.at("//bibdata").after("<misc-container/>").next_element
156
+ ins = add_misc_container(xmldoc)
156
157
  ins << @metadata_attrs
157
158
  end
158
159
  end
@@ -31,8 +31,8 @@ module Metanorma
31
31
  amend.children = "<description>#{amend.children.to_xml}</description>"
32
32
  return
33
33
  end
34
- pre = q&.xpath("./preceding-sibling::*")&.remove
35
- post = q&.xpath("./following-sibling::*")&.remove
34
+ pre = q.xpath("./preceding-sibling::*")&.remove
35
+ post = q.xpath("./following-sibling::*")&.remove
36
36
  pre.empty? or amend << "<description>#{pre.to_xml}</description>"
37
37
  amend << q.remove
38
38
  post.empty? or amend << "<description>#{post.to_xml}</description>"
@@ -0,0 +1,110 @@
1
+ require "set"
2
+ require "relaton_bib"
3
+
4
+ module Metanorma
5
+ module Standoc
6
+ module Cleanup
7
+ def ref_dl_cleanup(xmldoc)
8
+ xmldoc.xpath("//clause[@bibitem = 'true']").each do |c|
9
+ bib = dl_bib_extract(c) or next
10
+ validate_ref_dl(bib, c)
11
+ bibitemxml = RelatonBib::BibliographicItem.from_hash(bib).to_xml or next
12
+ bibitem = Nokogiri::XML(bibitemxml)
13
+ bibitem.root["id"] = c["id"] if c["id"] && !/^_/.match(c["id"])
14
+ c.replace(bibitem.root)
15
+ end
16
+ end
17
+
18
+ # do not accept implicit id
19
+ def validate_ref_dl(bib, clause)
20
+ id = bib["id"]
21
+ id ||= clause["id"] unless /^_/.match?(clause["id"])
22
+ unless id
23
+ @log.add("Anchors", clause,
24
+ "The following reference is missing an anchor:\n" \
25
+ "#{clause.to_xml}")
26
+ return
27
+ end
28
+ @refids << id
29
+ validate_ref_dl1(bib, id, clause)
30
+ end
31
+
32
+ def validate_ref_dl1(bib, id, clause)
33
+ bib["title"] or
34
+ @log.add("Bibliography", clause, "Reference #{id} is missing a title")
35
+ bib["docid"] or
36
+ @log.add("Bibliography", clause,
37
+ "Reference #{id} is missing a document identifier (docid)")
38
+ end
39
+
40
+ def extract_from_p(tag, bib, key)
41
+ return unless bib[tag]
42
+
43
+ "<#{key}>#{bib[tag].at('p').children}</#{key}>"
44
+ end
45
+
46
+ # if the content is a single paragraph, replace it with its children
47
+ # single links replaced with uri
48
+ def p_unwrap(para)
49
+ elems = para.elements
50
+ if elems.size == 1 && elems[0].name == "p"
51
+ link_unwrap(elems[0]).children.to_xml.strip
52
+ else
53
+ para.to_xml.strip
54
+ end
55
+ end
56
+
57
+ def link_unwrap(para)
58
+ elems = para.elements
59
+ if elems.size == 1 && elems[0].name == "link"
60
+ para.at("./link").replace(elems[0]["target"].strip)
61
+ end
62
+ para
63
+ end
64
+
65
+ def dd_bib_extract(dtd)
66
+ return nil if dtd.children.empty?
67
+
68
+ dtd.at("./dl") and return dl_bib_extract(dtd)
69
+ elems = dtd.remove.elements
70
+ return p_unwrap(dtd) unless elems.size == 1 &&
71
+ %w(ol ul).include?(elems[0].name)
72
+
73
+ elems[0].xpath("./li").each_with_object([]) do |li, ret|
74
+ ret << p_unwrap(li)
75
+ end
76
+ end
77
+
78
+ def add_to_hash(bib, key, val)
79
+ Metanorma::Utils::set_nested_value(bib, key.split("."), val)
80
+ end
81
+
82
+ # definition list, with at most one level of unordered lists
83
+ def dl_bib_extract(clause, nested = false)
84
+ dl = clause.at("./dl") or return
85
+ key = ""
86
+ bib = dl.xpath("./dt | ./dd").each_with_object({}) do |dtd, m|
87
+ (dtd.name == "dt" and key = dtd.text.sub(/:+$/, "")) and next
88
+ add_to_hash(m, key, dd_bib_extract(dtd))
89
+ end
90
+ clause.xpath("./clause").each do |c1|
91
+ key = c1&.at("./title")&.text&.downcase&.strip
92
+ next unless %w(contributor relation series).include? key
93
+
94
+ add_to_hash(bib, key, dl_bib_extract(c1, true))
95
+ end
96
+ dl_bib_extract_title(bib, clause, nested)
97
+ end
98
+
99
+ def dl_bib_extract_title(bib, clause, nested)
100
+ (!nested && clause.at("./title")) or return bib
101
+ title = clause.at("./title").remove.children.to_xml
102
+ bib["title"] = [bib["title"]] if bib["title"].is_a?(Hash) ||
103
+ bib["title"].is_a?(String)
104
+ bib["title"] ||= []
105
+ bib["title"] << title if !title.empty?
106
+ bib
107
+ end
108
+ end
109
+ end
110
+ end