metanorma-document 0.3.0 → 0.5.0

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 (197) hide show
  1. checksums.yaml +4 -4
  2. data/BUGS.sts/08-list-items-duplicate-bullets.md +45 -0
  3. data/CLAUDE.md +3 -2
  4. data/Rakefile +30 -5
  5. data/data/stylesheets/components/header.css +3 -5
  6. data/data/stylesheets/components/lists.css +14 -0
  7. data/frontend/dist/app.css +1 -0
  8. data/frontend/dist/app.iife.js +24 -0
  9. data/frontend/package-lock.json +7 -505
  10. data/frontend/tailwind.config.js +5 -0
  11. data/lib/metanorma/{oiml_document → csa_document}/root.rb +2 -2
  12. data/lib/metanorma/csa_document.rb +9 -0
  13. data/lib/metanorma/document/cli.rb +52 -0
  14. data/lib/metanorma/document/components/ancillary_blocks/sourcecode_body.rb +14 -0
  15. data/lib/metanorma/document/components/inline/comma_element.rb +3 -0
  16. data/lib/metanorma/document/components/inline/enum_comma_element.rb +3 -0
  17. data/lib/metanorma/document/components/inline/eref_element.rb +4 -1
  18. data/lib/metanorma/document/components/inline/fmt_termsource_element.rb +4 -2
  19. data/lib/metanorma/document/components/inline/math_element.rb +13 -7
  20. data/lib/metanorma/document/components/inline/vocabulary.rb +4 -0
  21. data/lib/metanorma/document/components/multi_paragraph/admonition_block.rb +6 -1
  22. data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +3 -0
  23. data/lib/metanorma/document/components/reference_elements/callout.rb +3 -2
  24. data/lib/metanorma/document/components/tables/table_cell.rb +3 -0
  25. data/lib/metanorma/document/elements/input.rb +44 -0
  26. data/lib/metanorma/document/elements.rb +1 -0
  27. data/lib/metanorma/document/relaton/address.rb +5 -0
  28. data/lib/metanorma/document/relaton/affiliation.rb +3 -0
  29. data/lib/metanorma/document/relaton/bib_item_size.rb +8 -9
  30. data/lib/metanorma/document/relaton/bib_item_type.rb +3 -0
  31. data/lib/metanorma/document/relaton/bibliographic_date.rb +5 -0
  32. data/lib/metanorma/document/relaton/contact_method.rb +5 -0
  33. data/lib/metanorma/document/relaton/contribution_info.rb +6 -2
  34. data/lib/metanorma/document/relaton/contributor.rb +4 -0
  35. data/lib/metanorma/document/relaton/contributor_role.rb +3 -0
  36. data/lib/metanorma/document/relaton/copyright_association.rb +3 -0
  37. data/lib/metanorma/document/relaton/copyright_owner.rb +3 -0
  38. data/lib/metanorma/document/relaton/date_time.rb +3 -0
  39. data/lib/metanorma/document/relaton/document_identifier.rb +4 -0
  40. data/lib/metanorma/document/relaton/document_relation.rb +8 -0
  41. data/lib/metanorma/document/relaton/document_status.rb +4 -0
  42. data/lib/metanorma/document/relaton/formatted_address.rb +4 -0
  43. data/lib/metanorma/document/relaton/full_name.rb +14 -3
  44. data/lib/metanorma/document/relaton/keyword_type.rb +3 -0
  45. data/lib/metanorma/document/relaton/locality_stack.rb +6 -9
  46. data/lib/metanorma/document/relaton/localized_name.rb +8 -5
  47. data/lib/metanorma/document/relaton/logo_element.rb +5 -0
  48. data/lib/metanorma/document/relaton/medium_type.rb +5 -16
  49. data/lib/metanorma/document/relaton/org_identifier.rb +2 -0
  50. data/lib/metanorma/document/relaton/org_subdivision.rb +2 -0
  51. data/lib/metanorma/document/relaton/org_subdivision_identifier.rb +2 -0
  52. data/lib/metanorma/document/relaton/organization.rb +3 -0
  53. data/lib/metanorma/document/relaton/person.rb +7 -1
  54. data/lib/metanorma/document/relaton/person_identifier.rb +3 -0
  55. data/lib/metanorma/document/relaton/place_type.rb +5 -0
  56. data/lib/metanorma/document/relaton/region_element.rb +3 -9
  57. data/lib/metanorma/document/relaton/relaton_collection.rb +2 -0
  58. data/lib/metanorma/document/relaton/series_type.rb +7 -0
  59. data/lib/metanorma/document/relaton/typed_note.rb +4 -0
  60. data/lib/metanorma/document/relaton/typed_title_string.rb +4 -0
  61. data/lib/metanorma/document/relaton/typed_uri.rb +3 -8
  62. data/lib/metanorma/document/relaton/validity_type.rb +8 -10
  63. data/lib/metanorma/document/relaton/variant_full_name.rb +3 -0
  64. data/lib/metanorma/document/relaton/variant_org_name.rb +3 -0
  65. data/lib/metanorma/document/relaton/version_info.rb +5 -0
  66. data/lib/metanorma/document/relaton/vocab_id_type.rb +6 -12
  67. data/lib/metanorma/document/relaton.rb +0 -14
  68. data/lib/metanorma/document/version.rb +1 -1
  69. data/lib/metanorma/document.rb +2 -1
  70. data/lib/metanorma/html/asset_pipeline.rb +1 -0
  71. data/lib/metanorma/html/base_renderer.rb +106 -236
  72. data/lib/metanorma/html/concerns/metadata_extraction.rb +61 -0
  73. data/lib/metanorma/html/concerns/presentation_validation.rb +61 -0
  74. data/lib/metanorma/html/concerns/svg_processing.rb +32 -0
  75. data/lib/metanorma/html/concerns/text_extraction.rb +93 -0
  76. data/lib/metanorma/html/concerns/toc_registry.rb +47 -0
  77. data/lib/metanorma/html/csa_renderer.rb +9 -0
  78. data/lib/metanorma/html/drops/figure_drop.rb +33 -10
  79. data/lib/metanorma/html/drops/sourcecode_drop.rb +3 -6
  80. data/lib/metanorma/html/flavor.rb +6 -1
  81. data/lib/metanorma/html/generator.rb +8 -8
  82. data/lib/metanorma/html/iso_renderer.rb +0 -142
  83. data/lib/metanorma/html/renderers/block_renderer.rb +41 -5
  84. data/lib/metanorma/html/renderers/element_order_traversal.rb +15 -1
  85. data/lib/metanorma/html/renderers/inline_renderer.rb +16 -76
  86. data/lib/metanorma/html/standard_renderer.rb +195 -35
  87. data/lib/metanorma/html/templates/_list_item.html.liquid +1 -1
  88. data/lib/metanorma/html/theme.rb +38 -11
  89. data/lib/metanorma/html.rb +1 -52
  90. data/lib/metanorma/iso_document/sections/iso_preface.rb +27 -13
  91. data/lib/metanorma/mirror/default_registry.rb +21 -0
  92. data/lib/metanorma/mirror/handlers/inline/catalog.rb +7 -12
  93. data/lib/metanorma/mirror/handlers/inline/rich_html_renderer.rb +2 -3
  94. data/lib/metanorma/mirror/handlers/sourcecode.rb +1 -1
  95. data/lib/metanorma/mirror/model/guide.rb +3 -2
  96. data/lib/metanorma/mirror/output/formats/inline_format.rb +64 -3
  97. data/lib/metanorma/mirror/output/pipeline.rb +1 -0
  98. data/lib/metanorma/mirror/output.rb +0 -2
  99. data/lib/metanorma/mirror/rewriter.rb +3 -1
  100. data/lib/metanorma/registers/setup.rb +6 -2
  101. data/lib/metanorma/standard_document/annotation_container.rb +2 -0
  102. data/lib/metanorma/standard_document/elements/input.rb +4 -25
  103. data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +12 -2
  104. data/lib/metanorma/standard_document/metadata/presentation_metadata.rb +107 -0
  105. data/lib/metanorma/standard_document/metadata/semantic_metadata.rb +18 -0
  106. data/lib/metanorma/standard_document/metadata/unitsml/amount_of_substance.rb +19 -0
  107. data/lib/metanorma/standard_document/metadata/unitsml/base_quantity.rb +34 -0
  108. data/lib/metanorma/standard_document/metadata/unitsml/dimension.rb +39 -0
  109. data/lib/metanorma/standard_document/metadata/unitsml/dimension_set.rb +19 -0
  110. data/lib/metanorma/standard_document/metadata/unitsml/electric_current.rb +19 -0
  111. data/lib/metanorma/standard_document/metadata/unitsml/enumerated_root_unit.rb +23 -0
  112. data/lib/metanorma/standard_document/metadata/unitsml/length.rb +19 -0
  113. data/lib/metanorma/standard_document/metadata/unitsml/luminous_intensity.rb +19 -0
  114. data/lib/metanorma/standard_document/metadata/unitsml/mass.rb +19 -0
  115. data/lib/metanorma/standard_document/metadata/unitsml/namespace.rb +17 -0
  116. data/lib/metanorma/standard_document/metadata/unitsml/plane_angle.rb +19 -0
  117. data/lib/metanorma/standard_document/metadata/unitsml/prefix.rb +30 -0
  118. data/lib/metanorma/standard_document/metadata/unitsml/prefix_name.rb +21 -0
  119. data/lib/metanorma/standard_document/metadata/unitsml/prefix_set.rb +19 -0
  120. data/lib/metanorma/standard_document/metadata/unitsml/prefix_symbol.rb +21 -0
  121. data/lib/metanorma/standard_document/metadata/unitsml/quantity.rb +28 -0
  122. data/lib/metanorma/standard_document/metadata/unitsml/quantity_name.rb +21 -0
  123. data/lib/metanorma/standard_document/metadata/unitsml/quantity_set.rb +19 -0
  124. data/lib/metanorma/standard_document/metadata/unitsml/root_units.rb +19 -0
  125. data/lib/metanorma/standard_document/metadata/unitsml/thermodynamic_temperature.rb +19 -0
  126. data/lib/metanorma/standard_document/metadata/unitsml/time.rb +19 -0
  127. data/lib/metanorma/standard_document/metadata/unitsml/unit.rb +32 -0
  128. data/lib/metanorma/standard_document/metadata/unitsml/unit_name.rb +21 -0
  129. data/lib/metanorma/standard_document/metadata/unitsml/unit_set.rb +19 -0
  130. data/lib/metanorma/standard_document/metadata/unitsml/unit_symbol.rb +36 -0
  131. data/lib/metanorma/standard_document/metadata/unitsml/unit_system.rb +23 -0
  132. data/lib/metanorma/standard_document/metadata/unitsml/unitsml_root.rb +28 -0
  133. data/lib/metanorma/standard_document/metadata/unitsml.rb +39 -0
  134. data/lib/metanorma/standard_document/metadata.rb +4 -0
  135. data/lib/metanorma/standard_document/sections/misc_container.rb +8 -6
  136. data/lib/metanorma/standard_document/sections/sections.rb +7 -0
  137. data/lib/metanorma/un_document/blocks/un_admonition_block.rb +86 -0
  138. data/lib/metanorma/un_document/blocks.rb +9 -0
  139. data/lib/metanorma/un_document/root.rb +8 -0
  140. data/lib/metanorma/un_document/sections/un_abstract_section.rb +48 -0
  141. data/lib/metanorma/un_document/sections/un_preface.rb +19 -2
  142. data/lib/metanorma/un_document/sections.rb +1 -0
  143. data/lib/metanorma/un_document/un_text_element.rb +116 -0
  144. data/lib/metanorma/un_document.rb +2 -0
  145. data/script/benchmark_render.rb +35 -0
  146. data/tasks/roundtrip_samples.rake +2 -2
  147. metadata +65 -54
  148. data/.rubocop_todo.yml +0 -220
  149. data/TODO.finalize/01-split-multi-class-files.md +0 -8
  150. data/TODO.finalize/02-remove-data-dist-iso-document-frontend.md +0 -6
  151. data/TODO.finalize/03-align-frontend-iife-and-gha-build.md +0 -11
  152. data/TODO.finalize/04-theme-per-flavor-config-driven.md +0 -9
  153. data/TODO.finalize/05-migrate-all-html-to-liquid.md +0 -16
  154. data/TODO.finalize/06-integrate-pubid-library.md +0 -16
  155. data/TODO.finalize/07-replace-relaton-models-with-relaton-bib.md +0 -39
  156. data/TODO.finalize/08-refactor-renderer-architecture.md +0 -25
  157. data/TODO.finalize/09-eliminate-code-smells.md +0 -14
  158. data/TODO.finalize/10-comprehensive-spec-coverage.md +0 -24
  159. data/TODO.finalize/11-config-driven-flavor-metadata.md +0 -20
  160. data/TODO.finalize/12-add-frozen-string-literal.md +0 -6
  161. data/TODO.finalize/13-extract-composition-from-god-class.md +0 -96
  162. data/TODO.finalize/14-config-driven-section-ordering.md +0 -31
  163. data/TODO.finalize/15-theme-directories-per-flavor.md +0 -46
  164. data/TODO.finalize/16-theme-lutaml-model-schema.md +0 -44
  165. data/data/logos/oiml-logo-full-dark.svg +0 -1
  166. data/data/logos/oiml-logo-full-light.svg +0 -1
  167. data/data/logos/oiml-logo-icon-dark.svg +0 -1
  168. data/data/logos/oiml-logo-icon-light.svg +0 -1
  169. data/data/logos/oiml-logo.svg +0 -1
  170. data/data/themes/oiml.yaml +0 -56
  171. data/docs/html-renderer.adoc +0 -261
  172. data/lib/data/dist/iso_document/frontend/assets/index-mwzbzmnK.js +0 -22
  173. data/lib/data/dist/iso_document/frontend/assets/index-pGvKTNid.css +0 -1
  174. data/lib/data/dist/iso_document/frontend/assets/iso-red.svg +0 -53
  175. data/lib/data/dist/iso_document/frontend/index.html +0 -13
  176. data/lib/metanorma/document/relaton/bib_item_size_type.rb +0 -21
  177. data/lib/metanorma/document/relaton/bibliographic_date_type.rb +0 -22
  178. data/lib/metanorma/document/relaton/document_relation_type.rb +0 -31
  179. data/lib/metanorma/document/relaton/iso4217_code.rb +0 -17
  180. data/lib/metanorma/document/relaton/iso8601_date.rb +0 -17
  181. data/lib/metanorma/document/relaton/personal_identifier_type.rb +0 -21
  182. data/lib/metanorma/document/relaton/region_type.rb +0 -20
  183. data/lib/metanorma/document/relaton/series_type_type.rb +0 -21
  184. data/lib/metanorma/document/relaton/specific_locality_type.rb +0 -25
  185. data/lib/metanorma/document/relaton/title_type.rb +0 -21
  186. data/lib/metanorma/html/oiml_renderer.rb +0 -33
  187. data/lib/metanorma/mirror/output/html_renderer.rb +0 -95
  188. data/lib/metanorma/mirror/output/html_renderers/block_renderers.rb +0 -178
  189. data/lib/metanorma/mirror/output/html_renderers/inline_renderer.rb +0 -61
  190. data/lib/metanorma/mirror/output/html_renderers/list_renderers.rb +0 -96
  191. data/lib/metanorma/mirror/output/html_renderers/mark_renderers.rb +0 -41
  192. data/lib/metanorma/mirror/output/html_renderers/section_renderers.rb +0 -129
  193. data/lib/metanorma/mirror/output/html_renderers/structural_renderers.rb +0 -80
  194. data/lib/metanorma/mirror/output/html_renderers/table_renderers.rb +0 -87
  195. data/lib/metanorma/mirror/output/html_renderers.rb +0 -76
  196. data/lib/metanorma/oiml_document.rb +0 -9
  197. data/lib/metanorma/standard_document/annotation.rb +0 -37
@@ -4,12 +4,13 @@ module Metanorma
4
4
  module Mirror
5
5
  module Model
6
6
  class Guide
7
- attr_reader :content, :meta, :title
7
+ attr_reader :content, :meta, :title, :document
8
8
 
9
- def initialize(content:, meta: {}, title: nil)
9
+ def initialize(content:, meta: {}, title: nil, document: nil)
10
10
  @content = content
11
11
  @meta = meta
12
12
  @title = title
13
+ @document = document
13
14
  end
14
15
 
15
16
  def to_h
@@ -8,12 +8,42 @@ module Metanorma
8
8
  module Output
9
9
  module Formats
10
10
  class InlineFormat < BaseFormat
11
+ # Classic content styles inlined for the no-JS SSR body: reset +
12
+ # typography + block/inline component styles from the classic
13
+ # asset pipeline. Page chrome (layout, print, transitions, dark,
14
+ # cover, header, footer, toc, search, progress, shortcuts,
15
+ # glossary panel, flavor modules) is owned by the SPA and
16
+ # excluded.
17
+ CONTENT_CSS_MODULES = %w[
18
+ base/_reset
19
+ base/_typography
20
+ components/section
21
+ components/note
22
+ components/example
23
+ components/sourcecode
24
+ components/formula
25
+ components/admonition
26
+ components/table
27
+ components/footnote
28
+ components/figure
29
+ components/term
30
+ components/bibliography
31
+ components/inline
32
+ components/index
33
+ ].freeze
34
+
35
+ class << self
36
+ attr_accessor :missing_bundle_warned
37
+ end
38
+
11
39
  def write(output_path, guide, title: "Metanorma")
12
40
  FileUtils.mkdir_p(File.dirname(output_path))
13
41
 
14
- data_script = "window.METANORMA_DATA = #{safe_json(guide)};"
15
- ssr_body = HtmlRenderer.new(guide).render
16
- head_parts = []
42
+ warn_missing_bundle unless iife_bundle_exists?
43
+
44
+ data_script = "window.METANORMA_DATA = #{safe_json(guide.to_h)};"
45
+ ssr_body = render_ssr_body(guide)
46
+ head_parts = [build_style(classic_content_css)]
17
47
  css_inline = read_css_inline
18
48
  if css_inline && !css_inline.empty?
19
49
  head_parts << build_style(css_inline)
@@ -42,6 +72,37 @@ module Metanorma
42
72
 
43
73
  private
44
74
 
75
+ # SSR body is the classic renderer's document body: identical to
76
+ # the static HTML output, embedded as the no-JS / first-paint
77
+ # placeholder the SPA replaces on mount.
78
+ def render_ssr_body(guide)
79
+ document = guide.document
80
+ unless document
81
+ raise ArgumentError,
82
+ "InlineFormat requires a Guide carrying its source document"
83
+ end
84
+
85
+ renderer = Metanorma::Html::Generator.renderer_for(document).new
86
+ renderer.generate_body(document)
87
+ end
88
+
89
+ def classic_content_css
90
+ css_dir = Metanorma::Html::AssetPipeline::CSS_DIR
91
+ CONTENT_CSS_MODULES.filter_map do |mod|
92
+ path = File.join(css_dir, "#{mod}.css")
93
+ File.read(path) if File.exist?(path)
94
+ end.join("\n")
95
+ end
96
+
97
+ def warn_missing_bundle
98
+ return if self.class.missing_bundle_warned
99
+
100
+ warn "metanorma-document: #{iife_bundle_path} not found — " \
101
+ "writing static HTML without the interactive SPA. " \
102
+ "Run `rake build_frontend` to build it."
103
+ self.class.missing_bundle_warned = true
104
+ end
105
+
45
106
  def build_style(css)
46
107
  Nokogiri::HTML5::Builder.new do |doc|
47
108
  doc.style { doc.text css }
@@ -23,6 +23,7 @@ id_strategy: nil)
23
23
  content: @context.content,
24
24
  meta: @context.meta,
25
25
  title: @context.title,
26
+ document: @context.parsed,
26
27
  )
27
28
  end
28
29
 
@@ -6,8 +6,6 @@ module Metanorma
6
6
  autoload :Pipeline, "#{__dir__}/output/pipeline"
7
7
  autoload :PipelineContext, "#{__dir__}/output/pipeline_context"
8
8
  autoload :Builder, "#{__dir__}/output/builder"
9
- autoload :HtmlRenderers, "#{__dir__}/output/html_renderers"
10
- autoload :HtmlRenderer, "#{__dir__}/output/html_renderer"
11
9
  autoload :Formats, "#{__dir__}/output/formats"
12
10
  end
13
11
  end
@@ -6,7 +6,9 @@ module Metanorma
6
6
  # per-type customization. Despite living in the reverse-conversion
7
7
  # namespace, this class produces a Model graph (not Metanorma XML) —
8
8
  # the output is a fully model-driven representation that can be
9
- # serialized via Model#to_h or rendered via Output::HtmlRenderer.
9
+ # serialized via Model#to_h or embedded into HTML output by
10
+ # Output::Formats::InlineFormat (which renders the source document
11
+ # through the classic Metanorma::Html renderer).
10
12
  #
11
13
  # Instance API:
12
14
  # Rewriter.new(skip: Set.new(%w[review footnotes]))
@@ -38,8 +38,8 @@ module Metanorma
38
38
  Lutaml::Model::GlobalRegister.register(reg)
39
39
  end
40
40
 
41
- def setup_oiml_register
42
- reg = Lutaml::Model::Register.new(:oiml_document,
41
+ def setup_csa_register
42
+ reg = Lutaml::Model::Register.new(:csa_document,
43
43
  fallback: [:iso_document])
44
44
  Lutaml::Model::GlobalRegister.register(reg)
45
45
  end
@@ -155,6 +155,10 @@ module Metanorma
155
155
  from_type: sd::Sections::Preface,
156
156
  to_type: Metanorma::UnDocument::Sections::UnPreface,
157
157
  )
158
+ reg.register_global_type_substitution(
159
+ from_type: Metanorma::Document::Components::MultiParagraph::AdmonitionBlock,
160
+ to_type: Metanorma::UnDocument::Blocks::UnAdmonitionBlock,
161
+ )
158
162
  end
159
163
  end
160
164
  end
@@ -10,6 +10,7 @@ module Metanorma
10
10
  attribute :to, :string
11
11
  attribute :type, :string
12
12
  attribute :date, :string
13
+ attribute :semx_id, :string
13
14
  attribute :paragraphs,
14
15
  Metanorma::Document::Components::Paragraphs::ParagraphBlock,
15
16
  collection: true
@@ -22,6 +23,7 @@ module Metanorma
22
23
  map_attribute "to", to: :to
23
24
  map_attribute "type", to: :type
24
25
  map_attribute "date", to: :date
26
+ map_attribute "semx-id", to: :semx_id
25
27
  map_element "p", to: :paragraphs
26
28
  end
27
29
  end
@@ -3,31 +3,10 @@
3
3
  module Metanorma
4
4
  module StandardDocument
5
5
  module Elements
6
- # Indication of text added through editorial intervention.
7
- class Input < Metanorma::StandardDocument::Elements::FormInput
8
- attribute :type, :string
9
- attribute :checked, :boolean
10
- attribute :disabled, :boolean
11
- attribute :readonly, :boolean
12
- attribute :maxlength, :integer
13
- attribute :minlength, :integer
14
-
15
- attribute :semx_id, :string
16
- attribute :original_id, :string
17
-
18
- xml do
19
- element "input"
20
- map_attribute "type", to: :type
21
- map_attribute "checked", to: :checked
22
- map_attribute "disabled", to: :disabled
23
- map_attribute "readonly", to: :readonly
24
- map_attribute "maxlength", to: :maxlength
25
- map_attribute "minlength", to: :minlength
26
-
27
- map_attribute "semx-id", to: :semx_id
28
- map_attribute "original-id", to: :original_id
29
- end
30
- end
6
+ # Kept as the StandardDocument-layer alias of the document-layer
7
+ # Input model (see lib/metanorma/document/elements/input.rb) so
8
+ # existing StandardDocument references keep working.
9
+ Input = Metanorma::Document::Elements::Input
31
10
  end
32
11
  end
33
12
  end
@@ -3,12 +3,22 @@
3
3
  module Metanorma
4
4
  module StandardDocument
5
5
  module Metadata
6
+ # <metanorma-extension> holds processor-generated metadata.
7
+ # Children, when present, appear in this fixed order:
8
+ # semantic-metadata, presentation-metadata, UnitsML,
9
+ # source-highlighter-css.
6
10
  class MetanormaExtension < Lutaml::Model::Serializable
7
- attribute :content, :string
11
+ attribute :semantic_metadata, SemanticMetadata
12
+ attribute :presentation_metadata, PresentationMetadata
13
+ attribute :unitsml, Unitsml::UnitsmlRoot
14
+ attribute :source_highlighter_css, :string
8
15
 
9
16
  xml do
10
17
  element "metanorma-extension"
11
- map_all_content to: :content
18
+ map_element "semantic-metadata", to: :semantic_metadata
19
+ map_element "presentation-metadata", to: :presentation_metadata
20
+ map_element "UnitsML", to: :unitsml
21
+ map_element "source-highlighter-css", to: :source_highlighter_css
12
22
  end
13
23
  end
14
24
  end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ # <presentation-metadata> carries rendering hints for the document.
7
+ #
8
+ # Current serialization uses typed children (toc-heading-levels,
9
+ # document-scheme, the OGC color-* family, OIML doctype-alias/fonts,
10
+ # isodoc html-details-open). The legacy serialization (still emitted
11
+ # into misc-container by some flavors) uses <name>/<value> pairs
12
+ # instead. Both shapes are mapped here so either round-trips
13
+ # losslessly. map_element order matches the order emitted by
14
+ # metanorma across spec fixtures.
15
+ class PresentationMetadata < Lutaml::Model::Serializable
16
+ attribute :doctype_alias, :string
17
+ attribute :document_scheme, :string
18
+ attribute :color_admonition_caution, :string
19
+ attribute :color_admonition_editor, :string
20
+ attribute :color_admonition_important, :string
21
+ attribute :color_admonition_note, :string
22
+ attribute :color_admonition_safety_precaution, :string
23
+ attribute :color_admonition_tip, :string
24
+ attribute :color_admonition_todo, :string
25
+ attribute :color_admonition_warning, :string
26
+ attribute :color_background_definition_description, :string
27
+ attribute :color_background_definition_term, :string
28
+ attribute :color_background_page, :string
29
+ attribute :color_background_table_header, :string
30
+ attribute :color_background_table_row_even, :string
31
+ attribute :color_background_table_row_odd, :string
32
+ attribute :color_background_term_admitted_label, :string
33
+ attribute :color_background_term_deprecated_label, :string
34
+ attribute :color_background_term_preferred_label, :string
35
+ attribute :color_background_text_label_legacy, :string
36
+ attribute :color_secondary_shade1, :string
37
+ attribute :color_secondary_shade2, :string
38
+ attribute :color_text, :string
39
+ attribute :color_text_title, :string
40
+ attribute :toc_heading_levels, :string
41
+ attribute :html_toc_heading_levels, :string
42
+ attribute :doc_toc_heading_levels, :string
43
+ attribute :pdf_toc_heading_levels, :string
44
+ attribute :html_details_open, :string
45
+ attribute :fonts, :string, collection: true
46
+ attribute :name, :string
47
+ attribute :value, :string
48
+
49
+ xml do
50
+ element "presentation-metadata"
51
+ map_element "doctype-alias", to: :doctype_alias
52
+ map_element "document-scheme", to: :document_scheme
53
+ map_element "color-admonition-caution",
54
+ to: :color_admonition_caution
55
+ map_element "color-admonition-editor",
56
+ to: :color_admonition_editor
57
+ map_element "color-admonition-important",
58
+ to: :color_admonition_important
59
+ map_element "color-admonition-note",
60
+ to: :color_admonition_note
61
+ map_element "color-admonition-safety-precaution",
62
+ to: :color_admonition_safety_precaution
63
+ map_element "color-admonition-tip",
64
+ to: :color_admonition_tip
65
+ map_element "color-admonition-todo",
66
+ to: :color_admonition_todo
67
+ map_element "color-admonition-warning",
68
+ to: :color_admonition_warning
69
+ map_element "color-background-definition-description",
70
+ to: :color_background_definition_description
71
+ map_element "color-background-definition-term",
72
+ to: :color_background_definition_term
73
+ map_element "color-background-page",
74
+ to: :color_background_page
75
+ map_element "color-background-table-header",
76
+ to: :color_background_table_header
77
+ map_element "color-background-table-row-even",
78
+ to: :color_background_table_row_even
79
+ map_element "color-background-table-row-odd",
80
+ to: :color_background_table_row_odd
81
+ map_element "color-background-term-admitted-label",
82
+ to: :color_background_term_admitted_label
83
+ map_element "color-background-term-deprecated-label",
84
+ to: :color_background_term_deprecated_label
85
+ map_element "color-background-term-preferred-label",
86
+ to: :color_background_term_preferred_label
87
+ map_element "color-background-text-label-legacy",
88
+ to: :color_background_text_label_legacy
89
+ map_element "color-secondary-shade-1",
90
+ to: :color_secondary_shade1
91
+ map_element "color-secondary-shade-2",
92
+ to: :color_secondary_shade2
93
+ map_element "color-text", to: :color_text
94
+ map_element "color-text-title", to: :color_text_title
95
+ map_element "toc-heading-levels", to: :toc_heading_levels
96
+ map_element "html-toc-heading-levels", to: :html_toc_heading_levels
97
+ map_element "doc-toc-heading-levels", to: :doc_toc_heading_levels
98
+ map_element "pdf-toc-heading-levels", to: :pdf_toc_heading_levels
99
+ map_element "html-details-open", to: :html_details_open
100
+ map_element "fonts", to: :fonts
101
+ map_element "name", to: :name
102
+ map_element "value", to: :value
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ # <semantic-metadata> carries semantic flags about the document
7
+ # (only <stage-published> has been observed in the wild).
8
+ class SemanticMetadata < Lutaml::Model::Serializable
9
+ attribute :stage_published, :string
10
+
11
+ xml do
12
+ element "semantic-metadata"
13
+ map_element "stage-published", to: :stage_published
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class AmountOfSubstance < Lutaml::Model::Serializable
8
+ include BaseQuantityAttributes
9
+
10
+ xml do
11
+ element "AmountOfSubstance"
12
+ namespace Unitsml::Namespace
13
+ BaseQuantityXmlMapping.apply(self)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ # Shared attributes for the eight UnitsML base-quantity elements
8
+ # (Length, Mass, Time, ElectricCurrent, AmountOfSubstance,
9
+ # ThermodynamicTemperature, LuminousIntensity, PlaneAngle).
10
+ module BaseQuantityAttributes
11
+ def self.included(base)
12
+ base.class_eval do
13
+ attribute :symbol, :string
14
+ attribute :power_numerator, :integer
15
+ attribute :power_denominator, :integer
16
+ end
17
+ end
18
+ end
19
+
20
+ # Shared attribute mappings for the base-quantity elements.
21
+ # lutaml-model does not inherit xml mappings, so each per-tag class
22
+ # applies this inside its own `xml do` block (same pattern as
23
+ # StandardDocument::RootXmlMapping).
24
+ module BaseQuantityXmlMapping
25
+ def self.apply(mapping)
26
+ mapping.map_attribute "symbol", to: :symbol
27
+ mapping.map_attribute "powerNumerator", to: :power_numerator
28
+ mapping.map_attribute "powerDenominator", to: :power_denominator
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class Dimension < Lutaml::Model::Serializable
8
+ attribute :id, :string
9
+ attribute :semx_id, :string
10
+
11
+ attribute :length, Length
12
+ attribute :mass, Mass
13
+ attribute :time, Time
14
+ attribute :electric_current, ElectricCurrent
15
+ attribute :thermodynamic_temperature, ThermodynamicTemperature
16
+ attribute :amount_of_substance, AmountOfSubstance
17
+ attribute :luminous_intensity, LuminousIntensity
18
+ attribute :plane_angle, PlaneAngle
19
+
20
+ xml do
21
+ element "Dimension"
22
+ namespace Unitsml::Namespace
23
+ map_attribute "id", to: :id
24
+ map_attribute "semx-id", to: :semx_id
25
+ map_element "Length", to: :length
26
+ map_element "Mass", to: :mass
27
+ map_element "Time", to: :time
28
+ map_element "ElectricCurrent", to: :electric_current
29
+ map_element "ThermodynamicTemperature",
30
+ to: :thermodynamic_temperature
31
+ map_element "AmountOfSubstance", to: :amount_of_substance
32
+ map_element "LuminousIntensity", to: :luminous_intensity
33
+ map_element "PlaneAngle", to: :plane_angle
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class DimensionSet < Lutaml::Model::Serializable
8
+ attribute :dimension, Dimension, collection: true
9
+
10
+ xml do
11
+ element "DimensionSet"
12
+ namespace Unitsml::Namespace
13
+ map_element "Dimension", to: :dimension
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class ElectricCurrent < Lutaml::Model::Serializable
8
+ include BaseQuantityAttributes
9
+
10
+ xml do
11
+ element "ElectricCurrent"
12
+ namespace Unitsml::Namespace
13
+ BaseQuantityXmlMapping.apply(self)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class EnumeratedRootUnit < Lutaml::Model::Serializable
8
+ attribute :unit, :string
9
+ attribute :prefix, :string
10
+ attribute :power_numerator, :integer
11
+
12
+ xml do
13
+ element "EnumeratedRootUnit"
14
+ namespace Unitsml::Namespace
15
+ map_attribute "unit", to: :unit
16
+ map_attribute "prefix", to: :prefix
17
+ map_attribute "powerNumerator", to: :power_numerator
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class Length < Lutaml::Model::Serializable
8
+ include BaseQuantityAttributes
9
+
10
+ xml do
11
+ element "Length"
12
+ namespace Unitsml::Namespace
13
+ BaseQuantityXmlMapping.apply(self)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class LuminousIntensity < Lutaml::Model::Serializable
8
+ include BaseQuantityAttributes
9
+
10
+ xml do
11
+ element "LuminousIntensity"
12
+ namespace Unitsml::Namespace
13
+ BaseQuantityXmlMapping.apply(self)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class Mass < Lutaml::Model::Serializable
8
+ include BaseQuantityAttributes
9
+
10
+ xml do
11
+ element "Mass"
12
+ namespace Unitsml::Namespace
13
+ BaseQuantityXmlMapping.apply(self)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ # UnitsML vocabulary namespace. Fixtures use the default-namespace
8
+ # form (<UnitsML xmlns="..."> with unprefixed children), so no
9
+ # prefix_default is declared.
10
+ class Namespace < Lutaml::Xml::Namespace
11
+ uri "https://schema.unitsml.org/unitsml/1.0"
12
+ element_form_default :qualified
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class PlaneAngle < Lutaml::Model::Serializable
8
+ include BaseQuantityAttributes
9
+
10
+ xml do
11
+ element "PlaneAngle"
12
+ namespace Unitsml::Namespace
13
+ BaseQuantityXmlMapping.apply(self)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class Prefix < Lutaml::Model::Serializable
8
+ attribute :prefix_base, :integer
9
+ attribute :prefix_power, :integer
10
+ attribute :id, :string
11
+ attribute :semx_id, :string
12
+
13
+ attribute :prefix_name, PrefixName
14
+ attribute :prefix_symbol, PrefixSymbol, collection: true
15
+
16
+ xml do
17
+ element "Prefix"
18
+ namespace Unitsml::Namespace
19
+ map_attribute "prefixBase", to: :prefix_base
20
+ map_attribute "prefixPower", to: :prefix_power
21
+ map_attribute "id", to: :id
22
+ map_attribute "semx-id", to: :semx_id
23
+ map_element "PrefixName", to: :prefix_name
24
+ map_element "PrefixSymbol", to: :prefix_symbol
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module StandardDocument
5
+ module Metadata
6
+ module Unitsml
7
+ class PrefixName < Lutaml::Model::Serializable
8
+ attribute :lang, :string
9
+ attribute :text, :string
10
+
11
+ xml do
12
+ element "PrefixName"
13
+ namespace Unitsml::Namespace
14
+ map_attribute "lang", to: :lang
15
+ map_content to: :text
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end