metanorma-document 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +321 -45
  3. data/Gemfile +2 -0
  4. data/lib/metanorma/basic_document/ancillary_blocks/figure_block.rb +3 -1
  5. data/lib/metanorma/basic_document/blocks/basic_block.rb +5 -1
  6. data/lib/metanorma/basic_document/blocks/note_block.rb +5 -0
  7. data/lib/metanorma/basic_document/blocks.rb +3 -24
  8. data/lib/metanorma/basic_document/lists/list.rb +2 -1
  9. data/lib/metanorma/basic_document/lists/list_item.rb +17 -0
  10. data/lib/metanorma/basic_document/lists.rb +1 -0
  11. data/lib/metanorma/basic_document/paragraphs/paragraph_with_footnote.rb +3 -1
  12. data/lib/metanorma/basic_document/reference_elements/callout.rb +1 -1
  13. data/lib/metanorma/basic_document/reference_elements/footnote.rb +1 -1
  14. data/lib/metanorma/basic_document/text_elements/mathml.rb +1 -1
  15. data/lib/metanorma/bipm_document/root.rb +10 -50
  16. data/lib/metanorma/bipm_document.rb +0 -2
  17. data/lib/metanorma/bsi_document/metadata/bsi_bib_data_extension_type.rb +10 -0
  18. data/lib/metanorma/bsi_document/metadata/bsi_bibliographic_item.rb +15 -0
  19. data/lib/metanorma/bsi_document/metadata.rb +12 -0
  20. data/lib/metanorma/bsi_document/root.rb +29 -0
  21. data/lib/metanorma/bsi_document/sections/bsi_annex_section.rb +25 -0
  22. data/lib/metanorma/bsi_document/sections/bsi_clause_section.rb +25 -0
  23. data/lib/metanorma/bsi_document/sections/bsi_sections.rb +27 -0
  24. data/lib/metanorma/bsi_document/sections.rb +11 -0
  25. data/lib/metanorma/bsi_document.rb +11 -0
  26. data/lib/metanorma/cc_document/root.rb +10 -50
  27. data/lib/metanorma/cc_document.rb +0 -2
  28. data/lib/metanorma/collection.rb +0 -2
  29. data/lib/metanorma/document/components/ancillary_blocks/example_block.rb +3 -3
  30. data/lib/metanorma/document/components/ancillary_blocks/figure_block.rb +2 -0
  31. data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +2 -0
  32. data/lib/metanorma/document/components/blocks/passthrough.rb +21 -0
  33. data/lib/metanorma/document/components/blocks/requirement_model.rb +159 -0
  34. data/lib/metanorma/document/components/blocks.rb +10 -0
  35. data/lib/metanorma/document/components/contrib_metadata/contribution_element_metadata.rb +3 -1
  36. data/lib/metanorma/document/components/id_elements/image.rb +2 -0
  37. data/lib/metanorma/document/components/inline/xref_element.rb +8 -0
  38. data/lib/metanorma/document/components/lists/definition_list.rb +6 -0
  39. data/lib/metanorma/document/components/lists/list_item.rb +1 -1
  40. data/lib/metanorma/document/components/lists/ordered_list.rb +6 -0
  41. data/lib/metanorma/document/components/lists/unordered_list.rb +8 -0
  42. data/lib/metanorma/document/components/multi_paragraph/admonition_block.rb +8 -0
  43. data/lib/metanorma/document/components/multi_paragraph/review_block.rb +3 -0
  44. data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +6 -2
  45. data/lib/metanorma/document/components/reference_elements/source_element.rb +57 -0
  46. data/lib/metanorma/document/components/reference_elements.rb +6 -0
  47. data/lib/metanorma/document/components/sections/references_section.rb +1 -1
  48. data/lib/metanorma/document/components/tables/table_block.rb +10 -0
  49. data/lib/metanorma/document/components/tables/table_cell.rb +2 -1
  50. data/lib/metanorma/document/data_types.rb +0 -4
  51. data/lib/metanorma/document/elements/add.rb +18 -0
  52. data/lib/metanorma/document/elements/del.rb +18 -0
  53. data/lib/metanorma/document/elements.rb +10 -0
  54. data/lib/metanorma/document/relaton/address.rb +16 -0
  55. data/lib/metanorma/document/root.rb +1 -3
  56. data/lib/metanorma/document/version.rb +1 -1
  57. data/lib/metanorma/document.rb +11 -2
  58. data/lib/metanorma/gb_document/metadata/gb_bib_data_extension_type.rb +10 -0
  59. data/lib/metanorma/gb_document/metadata/gb_bibliographic_item.rb +15 -0
  60. data/lib/metanorma/gb_document/metadata.rb +12 -0
  61. data/lib/metanorma/gb_document/root.rb +29 -0
  62. data/lib/metanorma/gb_document.rb +10 -0
  63. data/lib/metanorma/generic_document/root.rb +31 -0
  64. data/lib/metanorma/generic_document.rb +7 -0
  65. data/lib/metanorma/html/base_renderer.rb +198 -111
  66. data/lib/metanorma/html/bipm_renderer.rb +16 -8
  67. data/lib/metanorma/html/cc_renderer.rb +0 -1
  68. data/lib/metanorma/html/component/base.rb +5 -1
  69. data/lib/metanorma/html/component/footnote_collector.rb +3 -3
  70. data/lib/metanorma/html/component/index_section.rb +27 -9
  71. data/lib/metanorma/html/component/index_term_collector.rb +8 -3
  72. data/lib/metanorma/html/component.rb +2 -1
  73. data/lib/metanorma/html/drops/figure_drop.rb +14 -5
  74. data/lib/metanorma/html/drops/formula_drop.rb +7 -2
  75. data/lib/metanorma/html/drops/sourcecode_drop.rb +6 -2
  76. data/lib/metanorma/html/drops.rb +2 -1
  77. data/lib/metanorma/html/generator.rb +33 -16
  78. data/lib/metanorma/html/iec_renderer.rb +0 -1
  79. data/lib/metanorma/html/ieee_renderer.rb +0 -1
  80. data/lib/metanorma/html/ietf_renderer.rb +0 -1
  81. data/lib/metanorma/html/iho_renderer.rb +1 -2
  82. data/lib/metanorma/html/iso_renderer.rb +68 -23
  83. data/lib/metanorma/html/itu_renderer.rb +0 -1
  84. data/lib/metanorma/html/ogc_renderer.rb +0 -1
  85. data/lib/metanorma/html/oiml_renderer.rb +0 -1
  86. data/lib/metanorma/html/pdfa_renderer.rb +0 -1
  87. data/lib/metanorma/html/ribose_renderer.rb +0 -1
  88. data/lib/metanorma/html/standard_renderer.rb +61 -28
  89. data/lib/metanorma/html/theme.rb +2 -2
  90. data/lib/metanorma/html.rb +48 -1
  91. data/lib/metanorma/iec_document/root.rb +8 -47
  92. data/lib/metanorma/iec_document.rb +2 -3
  93. data/lib/metanorma/ieee_document/root.rb +14 -50
  94. data/lib/metanorma/ieee_document/sections/ieee_sections.rb +31 -0
  95. data/lib/metanorma/ieee_document/sections.rb +9 -0
  96. data/lib/metanorma/ieee_document.rb +3 -3
  97. data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -2
  98. data/lib/metanorma/ietf_document/metadata/ietf_bibliographic_item.rb +0 -2
  99. data/lib/metanorma/ietf_document/root.rb +14 -50
  100. data/lib/metanorma/ietf_document/sections/ietf_annex_section.rb +26 -0
  101. data/lib/metanorma/ietf_document/sections/ietf_clause_section.rb +26 -0
  102. data/lib/metanorma/ietf_document/sections/ietf_content_section.rb +25 -0
  103. data/lib/metanorma/ietf_document/sections/ietf_sections.rb +35 -0
  104. data/lib/metanorma/ietf_document/sections.rb +4 -23
  105. data/lib/metanorma/ietf_document.rb +4 -3
  106. data/lib/metanorma/iho_document/metadata/iho_bib_data_extension_type.rb +0 -2
  107. data/lib/metanorma/iho_document/root.rb +10 -50
  108. data/lib/metanorma/iho_document.rb +0 -3
  109. data/lib/metanorma/iso_document/annotation_container.rb +1 -10
  110. data/lib/metanorma/iso_document/boilerplate.rb +1 -11
  111. data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +2 -2
  112. data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +4 -3
  113. data/lib/metanorma/iso_document/metadata/metanorma_extension.rb +1 -12
  114. data/lib/metanorma/iso_document/root.rb +7 -73
  115. data/lib/metanorma/iso_document/sections/colophon.rb +1 -16
  116. data/lib/metanorma/iso_document/sections/iso_annex_section.rb +11 -133
  117. data/lib/metanorma/iso_document/sections/iso_clause_section.rb +9 -166
  118. data/lib/metanorma/iso_document/sections/iso_foreword_section.rb +15 -89
  119. data/lib/metanorma/iso_document/sections/iso_preface.rb +15 -21
  120. data/lib/metanorma/iso_document/sections/iso_sections.rb +19 -29
  121. data/lib/metanorma/iso_document/sections/iso_terms_section.rb +6 -9
  122. data/lib/metanorma/iso_document/terms/term_expression.rb +2 -47
  123. data/lib/metanorma/iso_document/terms/term_origin.rb +2 -24
  124. data/lib/metanorma/iso_document/terms/term_source.rb +4 -32
  125. data/lib/metanorma/iso_document.rb +2 -2
  126. data/lib/metanorma/itu_document/root.rb +10 -50
  127. data/lib/metanorma/itu_document.rb +0 -2
  128. data/lib/metanorma/jis_document/metadata/jis_bib_data_extension_type.rb +10 -0
  129. data/lib/metanorma/jis_document/metadata/jis_bibliographic_item.rb +15 -0
  130. data/lib/metanorma/jis_document/metadata.rb +12 -0
  131. data/lib/metanorma/jis_document/root.rb +29 -0
  132. data/lib/metanorma/jis_document/sections/jis_annex_section.rb +20 -0
  133. data/lib/metanorma/jis_document/sections.rb +9 -0
  134. data/lib/metanorma/jis_document.rb +11 -0
  135. data/lib/metanorma/m3d_document/metadata/m3d_bib_data_extension_type.rb +10 -0
  136. data/lib/metanorma/m3d_document/metadata/m3d_bibliographic_item.rb +15 -0
  137. data/lib/metanorma/m3d_document/metadata.rb +12 -0
  138. data/lib/metanorma/m3d_document/root.rb +29 -0
  139. data/lib/metanorma/m3d_document.rb +10 -0
  140. data/lib/metanorma/nist_document/metadata/nist_bib_data_extension_type.rb +10 -0
  141. data/lib/metanorma/nist_document/metadata/nist_bibliographic_item.rb +15 -0
  142. data/lib/metanorma/nist_document/metadata.rb +12 -0
  143. data/lib/metanorma/nist_document/root.rb +29 -0
  144. data/lib/metanorma/nist_document/sections/errata.rb +16 -0
  145. data/lib/metanorma/nist_document/sections/errata_clause.rb +20 -0
  146. data/lib/metanorma/nist_document/sections/errata_row.rb +22 -0
  147. data/lib/metanorma/nist_document/sections/nist_preface.rb +30 -0
  148. data/lib/metanorma/nist_document/sections.rb +12 -0
  149. data/lib/metanorma/nist_document.rb +11 -0
  150. data/lib/metanorma/ogc_document/root.rb +10 -50
  151. data/lib/metanorma/ogc_document.rb +0 -2
  152. data/lib/metanorma/oiml_document/root.rb +8 -47
  153. data/lib/metanorma/oiml_document.rb +2 -3
  154. data/lib/metanorma/plateau_document/metadata/plateau_bibliographic_item.rb +13 -0
  155. data/lib/metanorma/plateau_document/metadata.rb +10 -0
  156. data/lib/metanorma/plateau_document/root.rb +29 -0
  157. data/lib/metanorma/plateau_document.rb +10 -0
  158. data/lib/metanorma/registers/setup.rb +162 -0
  159. data/lib/metanorma/registers.rb +7 -0
  160. data/lib/metanorma/ribose_document/root.rb +10 -52
  161. data/lib/metanorma/ribose_document.rb +0 -2
  162. data/lib/metanorma/standard_document/annotation_container.rb +14 -0
  163. data/lib/metanorma/standard_document/block_attributes.rb +226 -0
  164. data/lib/metanorma/standard_document/blocks/passthrough.rb +1 -18
  165. data/lib/metanorma/standard_document/blocks/requirement_model.rb +18 -163
  166. data/lib/metanorma/standard_document/boilerplate.rb +14 -0
  167. data/lib/metanorma/standard_document/elements/add.rb +1 -17
  168. data/lib/metanorma/standard_document/elements/del.rb +1 -17
  169. data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +16 -0
  170. data/lib/metanorma/standard_document/metadata.rb +2 -0
  171. data/lib/metanorma/standard_document/refs/reference_to_term.rb +2 -1
  172. data/lib/metanorma/standard_document/root_attributes.rb +78 -0
  173. data/lib/metanorma/standard_document/sections/abstract.rb +1 -3
  174. data/lib/metanorma/standard_document/sections/acknowledgements.rb +1 -3
  175. data/lib/metanorma/standard_document/sections/annex_section.rb +81 -16
  176. data/lib/metanorma/standard_document/sections/bibliography_section.rb +1 -2
  177. data/lib/metanorma/standard_document/sections/clause_section.rb +102 -10
  178. data/lib/metanorma/standard_document/sections/colophon.rb +16 -0
  179. data/lib/metanorma/standard_document/sections/definition_section.rb +45 -42
  180. data/lib/metanorma/standard_document/sections/floating_section_title.rb +23 -0
  181. data/lib/metanorma/standard_document/sections/foreword.rb +1 -3
  182. data/lib/metanorma/standard_document/sections/introduction.rb +1 -4
  183. data/lib/metanorma/standard_document/sections/misc_container.rb +5 -2
  184. data/lib/metanorma/standard_document/sections/preface.rb +36 -0
  185. data/lib/metanorma/standard_document/sections/sections.rb +40 -0
  186. data/lib/metanorma/standard_document/sections/standard_content_section.rb +42 -9
  187. data/lib/metanorma/standard_document/sections/terms_section.rb +52 -10
  188. data/lib/metanorma/standard_document/sections.rb +6 -2
  189. data/lib/metanorma/standard_document/terms/designation.rb +1 -1
  190. data/lib/metanorma/standard_document/terms/term_expression.rb +51 -0
  191. data/lib/metanorma/standard_document/terms.rb +1 -0
  192. data/lib/metanorma/standard_document.rb +7 -2
  193. data/lib/metanorma/un_document/metadata/un_bib_data_extension_type.rb +10 -0
  194. data/lib/metanorma/un_document/metadata/un_bibliographic_item.rb +15 -0
  195. data/lib/metanorma/un_document/metadata.rb +12 -0
  196. data/lib/metanorma/un_document/root.rb +29 -0
  197. data/lib/metanorma/un_document/sections/un_preface.rb +23 -0
  198. data/lib/metanorma/un_document/sections/un_sections.rb +24 -0
  199. data/lib/metanorma/un_document/sections.rb +10 -0
  200. data/lib/metanorma/un_document.rb +11 -0
  201. metadata +77 -3
  202. data/lib/metanorma/html/whitespace_patch.rb +0 -47
@@ -0,0 +1,226 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ # Mixin that declares individually-typed block collection attributes
6
+ # for section-level models (ClauseSection, AnnexSection, ContentSection, etc.).
7
+ #
8
+ # Include this module in any Serializable class that represents a section
9
+ # body containing heterogeneous block-level content (paragraphs, tables,
10
+ # figures, etc.).
11
+ module BlockAttributes
12
+ def self.included(base)
13
+ base.class_eval do
14
+ attribute :paragraphs,
15
+ Metanorma::Document::Components::Paragraphs::ParagraphBlock,
16
+ collection: true
17
+ attribute :unordered_lists,
18
+ Metanorma::Document::Components::Lists::UnorderedList,
19
+ collection: true
20
+ attribute :ordered_lists,
21
+ Metanorma::Document::Components::Lists::OrderedList,
22
+ collection: true
23
+ attribute :tables,
24
+ Metanorma::Document::Components::Tables::TableBlock,
25
+ collection: true
26
+ attribute :figures,
27
+ Metanorma::Document::Components::AncillaryBlocks::FigureBlock,
28
+ collection: true
29
+ attribute :formulas,
30
+ Metanorma::Document::Components::AncillaryBlocks::FormulaBlock,
31
+ collection: true
32
+ attribute :examples,
33
+ Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
34
+ collection: true
35
+ attribute :notes,
36
+ Metanorma::Document::Components::Blocks::NoteBlock,
37
+ collection: true
38
+ attribute :admonitions,
39
+ Metanorma::Document::Components::MultiParagraph::AdmonitionBlock,
40
+ collection: true
41
+ attribute :sourcecode_blocks,
42
+ Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock,
43
+ collection: true
44
+ attribute :quote_blocks,
45
+ Metanorma::Document::Components::MultiParagraph::QuoteBlock,
46
+ collection: true
47
+ attribute :definition_lists,
48
+ Metanorma::Document::Components::Lists::DefinitionList,
49
+ collection: true
50
+ end
51
+ end
52
+ end
53
+
54
+ # Adds XML element mappings for block-level content to a mapping builder.
55
+ # Call inside an `xml do` block:
56
+ #
57
+ # xml do
58
+ # element "clause"
59
+ # ordered
60
+ # BlockXmlMapping.apply_block_mappings(self)
61
+ # # ... additional mappings
62
+ # end
63
+ module BlockXmlMapping
64
+ BLOCK_MAPPINGS = {
65
+ "p" => :paragraphs,
66
+ "ul" => :unordered_lists,
67
+ "ol" => :ordered_lists,
68
+ "table" => :tables,
69
+ "figure" => :figures,
70
+ "formula" => :formulas,
71
+ "example" => :examples,
72
+ "note" => :notes,
73
+ "admonition" => :admonitions,
74
+ "sourcecode" => :sourcecode_blocks,
75
+ "quote" => :quote_blocks,
76
+ "dl" => :definition_lists,
77
+ }.freeze
78
+
79
+ def self.apply_block_mappings(mapping)
80
+ BLOCK_MAPPINGS.each do |element_name, attr_name|
81
+ mapping.map_element(element_name, to: attr_name)
82
+ end
83
+ end
84
+ end
85
+
86
+ # Shared XML mapping helpers for section-level elements.
87
+ # Extracts the common attribute/element mappings duplicated across
88
+ # ClauseSection, AnnexSection, and their flavor-specific subclasses.
89
+ module SectionXmlMapping
90
+ # Common XML attribute mappings for clause sections.
91
+ def self.apply_clause_attributes(mapping)
92
+ mapping.map_attribute "id", to: :id
93
+ mapping.map_attribute "anchor", to: :anchor
94
+ mapping.map_attribute "type", to: :type
95
+ mapping.map_attribute "number", to: :number
96
+ mapping.map_attribute "obligation", to: :obligation
97
+ mapping.map_attribute "inline-header", to: :inline_header
98
+ mapping.map_attribute "unnumbered", to: :unnumbered
99
+ mapping.map_attribute "toc", to: :toc
100
+ mapping.map_attribute "class", to: :class_attr
101
+ mapping.map_attribute "semx-id", to: :semx_id
102
+ mapping.map_attribute "autonum", to: :autonum
103
+ mapping.map_attribute "displayorder", to: :displayorder
104
+ end
105
+
106
+ # Common XML element mappings for clause sections.
107
+ def self.apply_clause_elements(mapping)
108
+ mapping.map_element "title", to: :title
109
+ mapping.map_element "variant-title", to: :variant_title
110
+ mapping.map_element "fmt-title", to: :fmt_title
111
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
112
+
113
+ BlockXmlMapping.apply_block_mappings(mapping)
114
+
115
+ mapping.map_element "amend", to: :amend
116
+ mapping.map_element "clause", to: :clause
117
+ mapping.map_element "terms", to: :terms
118
+ mapping.map_element "definitions", to: :definitions
119
+ mapping.map_element "references", to: :references
120
+ mapping.map_element "floating-title", to: :floating_title
121
+ mapping.map_element "form", to: :form
122
+ mapping.map_element "requirement", to: :requirement
123
+ mapping.map_element "recommendation", to: :recommendation
124
+ mapping.map_element "permission", to: :permission
125
+ mapping.map_element "pagebreak", to: :pagebreak
126
+ mapping.map_element "bookmark", to: :bookmark
127
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
128
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
129
+ end
130
+
131
+ # Common XML attribute mappings for annex sections.
132
+ def self.apply_annex_attributes(mapping)
133
+ mapping.map_attribute "id", to: :id
134
+ mapping.map_attribute "number", to: :number
135
+ mapping.map_attribute "obligation", to: :obligation,
136
+ render_empty: true
137
+ mapping.map_attribute "unnumbered", to: :unnumbered
138
+ mapping.map_attribute "toc", to: :toc
139
+ mapping.map_attribute "anchor", to: :anchor
140
+ mapping.map_attribute "semx-id", to: :semx_id
141
+ mapping.map_attribute "autonum", to: :autonum
142
+ mapping.map_attribute "displayorder", to: :displayorder
143
+ mapping.map_attribute "inline-header", to: :inline_header
144
+ mapping.map_attribute "language", to: :language, render_empty: true
145
+ mapping.map_attribute "script", to: :script, render_empty: true
146
+ end
147
+
148
+ # Common XML element mappings for annex sections.
149
+ def self.apply_annex_elements(mapping)
150
+ mapping.map_element "title", to: :title
151
+ mapping.map_element "variant-title", to: :variant_title
152
+ mapping.map_element "fmt-title", to: :fmt_title
153
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
154
+
155
+ BlockXmlMapping.apply_block_mappings(mapping)
156
+
157
+ mapping.map_element "clause", to: :clause
158
+ mapping.map_element "appendix", to: :appendix
159
+ mapping.map_element "terms", to: :terms
160
+ mapping.map_element "definitions", to: :definitions
161
+ mapping.map_element "references", to: :references
162
+ mapping.map_element "floating-title", to: :floating_title
163
+ mapping.map_element "pagebreak", to: :pagebreak
164
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
165
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
166
+ end
167
+
168
+ # Common XML element/attribute mappings for the sections container.
169
+ def self.apply_sections_elements(mapping)
170
+ mapping.map_element "clause", to: :clause
171
+ mapping.map_element "terms", to: :terms
172
+ mapping.map_element "definitions", to: :definitions
173
+ mapping.map_element "floating-title", to: :floating_title
174
+ mapping.map_element "references", to: :references
175
+ end
176
+
177
+ def self.apply_sections_attributes(mapping)
178
+ mapping.map_attribute "semx-id", to: :semx_id
179
+ mapping.map_attribute "displayorder", to: :displayorder
180
+ end
181
+
182
+ # Common XML element/attribute mappings for preface containers.
183
+ def self.apply_preface_elements(mapping)
184
+ mapping.map_element "abstract", to: :abstract
185
+ mapping.map_element "foreword", to: :foreword
186
+ mapping.map_element "introduction", to: :introduction
187
+ mapping.map_element "acknowledgements", to: :acknowledgements
188
+ mapping.map_element "executivesummary", to: :executivesummary
189
+ end
190
+
191
+ def self.apply_preface_attributes(mapping)
192
+ mapping.map_attribute "semx-id", to: :semx_id
193
+ mapping.map_attribute "displayorder", to: :displayorder
194
+ end
195
+
196
+ # Common XML attribute/element mappings for ContentSection subclasses.
197
+ def self.apply_content_section_attributes(mapping)
198
+ mapping.map_attribute "id", to: :id
199
+ mapping.map_attribute "anchor", to: :anchor
200
+ mapping.map_attribute "type", to: :type
201
+ mapping.map_attribute "number", to: :number
202
+ mapping.map_attribute "obligation", to: :obligation
203
+ mapping.map_attribute "inline-header", to: :inline_header
204
+ mapping.map_attribute "unnumbered", to: :unnumbered
205
+ mapping.map_attribute "toc", to: :toc
206
+ mapping.map_attribute "class", to: :class_attr
207
+ mapping.map_attribute "semx-id", to: :semx_id
208
+ mapping.map_attribute "autonum", to: :autonum
209
+ mapping.map_attribute "displayorder", to: :displayorder
210
+ end
211
+
212
+ def self.apply_content_section_elements(mapping)
213
+ mapping.map_element "title", to: :title
214
+ mapping.map_element "variant-title", to: :variant_title
215
+ mapping.map_element "fmt-title", to: :fmt_title
216
+ mapping.map_element "fmt-xref-label", to: :fmt_xref_label
217
+
218
+ BlockXmlMapping.apply_block_mappings(mapping)
219
+
220
+ mapping.map_element "clause", to: :subsection
221
+ mapping.map_element "fmt-annotation-start", to: :fmt_annotation_start
222
+ mapping.map_element "fmt-annotation-end", to: :fmt_annotation_end
223
+ end
224
+ end
225
+ end
226
+ end
@@ -1,20 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Metanorma
4
- module StandardDocument
5
- module Blocks
6
- # Wrapper around raw markup to be transferred into one or more nominated output formats
7
- # during processing.
8
- class Passthrough < Metanorma::StandardDocument::Blocks::StandardBlockNoNotes
9
- attribute :formats, :string
10
- attribute :content, :string
11
-
12
- xml do
13
- element "passthrough"
14
- map_attribute "formats", to: :formats
15
- map_content to: :content
16
- end
17
- end
18
- end
19
- end
20
- end
3
+ Metanorma::StandardDocument::Blocks::Passthrough = Metanorma::Document::Components::Blocks::Passthrough
@@ -1,165 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Metanorma
4
- module StandardDocument
5
- module Blocks
6
- # Value element inside classification — mixed content with link.
7
- class ClassificationValue < Lutaml::Model::Serializable
8
- attribute :text, :string, collection: true
9
- attribute :link, Metanorma::Document::Components::Inline::LinkElement,
10
- collection: true
11
-
12
- xml do
13
- mixed_content
14
- map_content to: :text
15
- map_element "link", to: :link
16
- end
17
- end
18
-
19
- # Classification element inside requirement with tag/value children.
20
- class RequirementClassification < Lutaml::Model::Serializable
21
- attribute :tag, :string
22
- attribute :value, ClassificationValue
23
-
24
- xml do
25
- element "classification"
26
- map_element "tag", to: :tag
27
- map_element "value", to: :value
28
- end
29
- end
30
-
31
- # Description wrapper inside requirements containing paragraphs and other blocks.
32
- class RequirementDescription < Lutaml::Model::Serializable
33
- attribute :p, Metanorma::Document::Components::Paragraphs::ParagraphBlock,
34
- collection: true
35
- attribute :ul, Metanorma::Document::Components::Lists::UnorderedList,
36
- collection: true
37
- attribute :ol, Metanorma::Document::Components::Lists::OrderedList,
38
- collection: true
39
- attribute :sourcecode,
40
- Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock,
41
- collection: true
42
- attribute :table, Metanorma::Document::Components::Tables::TableBlock,
43
- collection: true
44
- attribute :example,
45
- Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
46
- collection: true
47
- attribute :note, Metanorma::Document::Components::Blocks::NoteBlock,
48
- collection: true
49
- attribute :figure,
50
- Metanorma::Document::Components::AncillaryBlocks::FigureBlock,
51
- collection: true
52
-
53
- xml do
54
- element "description"
55
- map_element "p", to: :p
56
- map_element "ul", to: :ul
57
- map_element "ol", to: :ol
58
- map_element "sourcecode", to: :sourcecode
59
- map_element "table", to: :table
60
- map_element "example", to: :example
61
- map_element "note", to: :note
62
- map_element "figure", to: :figure
63
- end
64
- end
65
-
66
- # Inherit element — mixed content, can contain text, eref, or xref.
67
- class RequirementInherit < Lutaml::Model::Serializable
68
- attribute :text, :string, collection: true
69
- attribute :eref, Metanorma::Document::Components::Inline::ErefElement,
70
- collection: true
71
- attribute :xref, Metanorma::Document::Components::Inline::XrefElement,
72
- collection: true
73
-
74
- xml do
75
- mixed_content
76
- map_content to: :text
77
- map_element "eref", to: :eref
78
- map_element "xref", to: :xref
79
- end
80
- end
81
-
82
- # Base class for requirement/recommendation/permission with shared structure.
83
- class RequirementBase < Lutaml::Model::Serializable
84
- attribute :id, :string
85
- attribute :model, :string
86
- attribute :obligation, :string
87
- attribute :type, :string
88
- attribute :anchor, :string
89
- attribute :subject, :string
90
- attribute :classification, RequirementClassification, collection: true
91
- attribute :description, RequirementDescription, collection: true
92
- attribute :inherit, RequirementInherit, collection: true
93
- attribute :requirement, "Metanorma::StandardDocument::Blocks::RequirementModel",
94
- collection: true
95
- attribute :recommendation, "Metanorma::StandardDocument::Blocks::RecommendationModel",
96
- collection: true
97
- attribute :permission, "Metanorma::StandardDocument::Blocks::PermissionModel",
98
- collection: true
99
- attribute :example,
100
- Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
101
- collection: true
102
- end
103
-
104
- # Requirement element — prescriptive statement using "shall".
105
- class RequirementModel < RequirementBase
106
- xml do
107
- element "requirement"
108
- map_attribute "id", to: :id
109
- map_attribute "model", to: :model
110
- map_attribute "obligation", to: :obligation
111
- map_attribute "type", to: :type
112
- map_attribute "anchor", to: :anchor
113
- map_element "subject", to: :subject
114
- map_element "classification", to: :classification
115
- map_element "description", to: :description
116
- map_element "inherit", to: :inherit
117
- map_element "requirement", to: :requirement
118
- map_element "recommendation", to: :recommendation
119
- map_element "permission", to: :permission
120
- map_element "example", to: :example
121
- end
122
- end
123
-
124
- # Recommendation element — prescriptive statement using "should".
125
- class RecommendationModel < RequirementBase
126
- xml do
127
- element "recommendation"
128
- map_attribute "id", to: :id
129
- map_attribute "model", to: :model
130
- map_attribute "obligation", to: :obligation
131
- map_attribute "type", to: :type
132
- map_attribute "anchor", to: :anchor
133
- map_element "subject", to: :subject
134
- map_element "classification", to: :classification
135
- map_element "description", to: :description
136
- map_element "inherit", to: :inherit
137
- map_element "requirement", to: :requirement
138
- map_element "recommendation", to: :recommendation
139
- map_element "permission", to: :permission
140
- map_element "example", to: :example
141
- end
142
- end
143
-
144
- # Permission element — prescriptive statement using "may".
145
- class PermissionModel < RequirementBase
146
- xml do
147
- element "permission"
148
- map_attribute "id", to: :id
149
- map_attribute "model", to: :model
150
- map_attribute "obligation", to: :obligation
151
- map_attribute "type", to: :type
152
- map_attribute "anchor", to: :anchor
153
- map_element "subject", to: :subject
154
- map_element "classification", to: :classification
155
- map_element "description", to: :description
156
- map_element "inherit", to: :inherit
157
- map_element "requirement", to: :requirement
158
- map_element "recommendation", to: :recommendation
159
- map_element "permission", to: :permission
160
- map_element "example", to: :example
161
- end
162
- end
163
- end
164
- end
165
- end
3
+ DOC = Metanorma::Document::Components::Blocks
4
+
5
+ Metanorma::StandardDocument::Blocks::ClassificationValue =
6
+ DOC::ClassificationValue
7
+ Metanorma::StandardDocument::Blocks::RequirementClassification =
8
+ DOC::RequirementClassification
9
+ Metanorma::StandardDocument::Blocks::RequirementDescription =
10
+ DOC::RequirementDescription
11
+ Metanorma::StandardDocument::Blocks::RequirementInherit =
12
+ DOC::RequirementInherit
13
+ Metanorma::StandardDocument::Blocks::RequirementBase =
14
+ DOC::RequirementBase
15
+ Metanorma::StandardDocument::Blocks::RequirementModel =
16
+ DOC::RequirementModel
17
+ Metanorma::StandardDocument::Blocks::RecommendationModel =
18
+ DOC::RecommendationModel
19
+ Metanorma::StandardDocument::Blocks::PermissionModel =
20
+ DOC::PermissionModel
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ class Boilerplate < Lutaml::Model::Serializable
6
+ attribute :content, :string
7
+
8
+ xml do
9
+ element "boilerplate"
10
+ map_all_content to: :content
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,19 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Metanorma
4
- module StandardDocument
5
- module Elements
6
- # Indication of text added through editorial intervention.
7
- class Add < Metanorma::Document::Components::TextElements::TextElement
8
- attribute :semx_id, :string
9
- attribute :original_id, :string
10
- xml do
11
- element "add"
12
-
13
- map_attribute "semx-id", to: :semx_id
14
- map_attribute "original-id", to: :original_id
15
- end
16
- end
17
- end
18
- end
19
- end
3
+ Metanorma::StandardDocument::Elements::Add = Metanorma::Document::Elements::Add
@@ -1,19 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Metanorma
4
- module StandardDocument
5
- module Elements
6
- # Indication of text deleted through editorial intervention.
7
- class Del < Metanorma::Document::Components::TextElements::TextElement
8
- attribute :semx_id, :string
9
- attribute :original_id, :string
10
- xml do
11
- element "del"
12
-
13
- map_attribute "semx-id", to: :semx_id
14
- map_attribute "original-id", to: :original_id
15
- end
16
- end
17
- end
18
- end
19
- end
3
+ Metanorma::StandardDocument::Elements::Del = Metanorma::Document::Elements::Del
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ class MetanormaExtension < Lutaml::Model::Serializable
7
+ attribute :content, :string
8
+
9
+ xml do
10
+ element "metanorma-extension"
11
+ map_all_content to: :content
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -5,6 +5,8 @@ module Metanorma
5
5
  module Metadata
6
6
  autoload :EditorialGroupType, "#{__dir__}/metadata/editorial_group_type"
7
7
  autoload :IcsType, "#{__dir__}/metadata/ics_type"
8
+ autoload :MetanormaExtension,
9
+ "#{__dir__}/metadata/metanorma_extension"
8
10
  autoload :StandardBibData, "#{__dir__}/metadata/standard_bib_data"
9
11
  autoload :StandardBibDataExtensionType,
10
12
  "#{__dir__}/metadata/standard_bib_data_extension_type"
@@ -5,7 +5,8 @@ module Metanorma
5
5
  module Refs
6
6
  # Cross-reference to a term.
7
7
  class ReferenceToTerm < Metanorma::Document::Components::ReferenceElements::ReferenceElement
8
- attribute :source, BasicObject
8
+ attribute :source,
9
+ Metanorma::Document::Components::ReferenceElements::SourceElement
9
10
  attribute :term, :string, collection: true
10
11
 
11
12
  attribute :semx_id, :string
@@ -0,0 +1,78 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ # Mixin that declares the common attributes for every <metanorma> Root class.
6
+ #
7
+ # Every flavor Root class includes this module and adds its own
8
+ # flavor-specific attributes (e.g. bibdata type, preface/sections types).
9
+ module RootAttributes
10
+ def self.included(base)
11
+ base.class_eval do
12
+ attribute :version, :string
13
+ attribute :type, :string
14
+ attribute :schema_version, :string
15
+ attribute :flavor, :string
16
+
17
+ attribute :bibliography,
18
+ Metanorma::StandardDocument::Sections::BibliographySection
19
+ attribute :boilerplate,
20
+ Metanorma::StandardDocument::Boilerplate
21
+ attribute :metanorma_extension,
22
+ Metanorma::StandardDocument::Metadata::MetanormaExtension
23
+ attribute :annotation_container,
24
+ Metanorma::StandardDocument::AnnotationContainer
25
+ attribute :localized_strings,
26
+ Metanorma::Document::Components::Inline::LocalizedStringsElement
27
+ attribute :fmt_footnote_container,
28
+ Metanorma::Document::Components::Inline::FmtFootnoteContainerElement
29
+ attribute :colophon,
30
+ Metanorma::StandardDocument::Sections::Colophon
31
+
32
+ attribute :term_sources,
33
+ Metanorma::Document::Components::ReferenceElements::Citation,
34
+ collection: true
35
+ attribute :indexsect,
36
+ Metanorma::Document::Components::Sections::BasicSection
37
+
38
+ attribute :autonum, :string
39
+ attribute :fmt_xref_label, :string
40
+ end
41
+ end
42
+ end
43
+
44
+ # Adds common XML root element mappings for all flavor Root classes.
45
+ # Call inside an `xml do` block:
46
+ #
47
+ # xml do
48
+ # element "metanorma"
49
+ # namespace StandardDocument::Namespace
50
+ # RootXmlMapping.apply(self)
51
+ # # ... flavor-specific mappings (bibdata, preface, sections, annex)
52
+ # end
53
+ module RootXmlMapping
54
+ def self.apply(mapping)
55
+ mapping.map_attribute "type", to: :type
56
+ mapping.map_attribute "version", to: :version
57
+ mapping.map_attribute "schema-version", to: :schema_version
58
+ mapping.map_attribute "flavor", to: :flavor
59
+ mapping.map_attribute "autonum", to: :autonum
60
+ mapping.map_attribute "fmt-xref-label", to: :fmt_xref_label
61
+ mapping.map_element "bibdata", to: :bibdata
62
+ mapping.map_element "preface", to: :preface
63
+ mapping.map_element "sections", to: :sections
64
+ mapping.map_element "annex", to: :annex
65
+ mapping.map_element "bibliography", to: :bibliography
66
+ mapping.map_element "boilerplate", to: :boilerplate
67
+ mapping.map_element "metanorma-extension", to: :metanorma_extension
68
+ mapping.map_element "annotation-container", to: :annotation_container
69
+ mapping.map_element "localized-strings", to: :localized_strings
70
+ mapping.map_element "fmt-footnote-container",
71
+ to: :fmt_footnote_container
72
+ mapping.map_element "colophon", to: :colophon
73
+ mapping.map_element "termdocsource", to: :term_sources
74
+ mapping.map_element "indexsect", to: :indexsect
75
+ end
76
+ end
77
+ end
78
+ end
@@ -4,10 +4,8 @@ module Metanorma
4
4
  module StandardDocument
5
5
  module Sections
6
6
  # Abstract of the document.
7
- class Abstract < Metanorma::StandardDocument::Sections::StandardContentSection
8
- attribute :semx_id, :string
7
+ class Abstract < Metanorma::StandardDocument::Sections::ContentSection
9
8
  attribute :original_id, :string
10
- attribute :displayorder, :integer
11
9
  xml do
12
10
  element "abstract"
13
11
 
@@ -4,10 +4,8 @@ module Metanorma
4
4
  module StandardDocument
5
5
  module Sections
6
6
  # Acknowledgements for the document.
7
- class Acknowledgements < Metanorma::StandardDocument::Sections::StandardContentSection
8
- attribute :semx_id, :string
7
+ class Acknowledgements < Metanorma::StandardDocument::Sections::ContentSection
9
8
  attribute :original_id, :string
10
- attribute :displayorder, :integer
11
9
  xml do
12
10
  element "acknowledgements"
13
11