metanorma-document 0.3.0 → 0.4.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.
- checksums.yaml +4 -4
- data/CLAUDE.md +3 -2
- data/Rakefile +30 -5
- data/frontend/dist/app.css +1 -0
- data/frontend/dist/app.iife.js +24 -0
- data/frontend/package-lock.json +7 -505
- data/frontend/tailwind.config.js +5 -0
- data/lib/metanorma/csa_document/root.rb +27 -0
- data/lib/metanorma/csa_document.rb +9 -0
- data/lib/metanorma/document/cli.rb +52 -0
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_body.rb +14 -0
- data/lib/metanorma/document/components/inline/comma_element.rb +3 -0
- data/lib/metanorma/document/components/inline/enum_comma_element.rb +3 -0
- data/lib/metanorma/document/components/inline/eref_element.rb +4 -1
- data/lib/metanorma/document/components/inline/fmt_termsource_element.rb +4 -2
- data/lib/metanorma/document/components/inline/math_element.rb +13 -7
- data/lib/metanorma/document/components/inline/vocabulary.rb +4 -0
- data/lib/metanorma/document/components/multi_paragraph/admonition_block.rb +6 -1
- data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +3 -0
- data/lib/metanorma/document/components/reference_elements/callout.rb +3 -2
- data/lib/metanorma/document/components/tables/table_cell.rb +3 -0
- data/lib/metanorma/document/elements/input.rb +44 -0
- data/lib/metanorma/document/elements.rb +1 -0
- data/lib/metanorma/document/relaton/address.rb +5 -0
- data/lib/metanorma/document/relaton/affiliation.rb +3 -0
- data/lib/metanorma/document/relaton/bib_item_size.rb +8 -9
- data/lib/metanorma/document/relaton/bib_item_type.rb +3 -0
- data/lib/metanorma/document/relaton/bibliographic_date.rb +5 -0
- data/lib/metanorma/document/relaton/contact_method.rb +5 -0
- data/lib/metanorma/document/relaton/contribution_info.rb +6 -2
- data/lib/metanorma/document/relaton/contributor.rb +4 -0
- data/lib/metanorma/document/relaton/contributor_role.rb +3 -0
- data/lib/metanorma/document/relaton/copyright_association.rb +3 -0
- data/lib/metanorma/document/relaton/copyright_owner.rb +3 -0
- data/lib/metanorma/document/relaton/date_time.rb +3 -0
- data/lib/metanorma/document/relaton/document_identifier.rb +4 -0
- data/lib/metanorma/document/relaton/document_relation.rb +8 -0
- data/lib/metanorma/document/relaton/document_status.rb +4 -0
- data/lib/metanorma/document/relaton/formatted_address.rb +4 -0
- data/lib/metanorma/document/relaton/full_name.rb +14 -3
- data/lib/metanorma/document/relaton/keyword_type.rb +3 -0
- data/lib/metanorma/document/relaton/locality_stack.rb +6 -9
- data/lib/metanorma/document/relaton/localized_name.rb +8 -5
- data/lib/metanorma/document/relaton/logo_element.rb +5 -0
- data/lib/metanorma/document/relaton/medium_type.rb +5 -16
- data/lib/metanorma/document/relaton/org_identifier.rb +2 -0
- data/lib/metanorma/document/relaton/org_subdivision.rb +2 -0
- data/lib/metanorma/document/relaton/org_subdivision_identifier.rb +2 -0
- data/lib/metanorma/document/relaton/organization.rb +3 -0
- data/lib/metanorma/document/relaton/person.rb +7 -1
- data/lib/metanorma/document/relaton/person_identifier.rb +3 -0
- data/lib/metanorma/document/relaton/place_type.rb +5 -0
- data/lib/metanorma/document/relaton/region_element.rb +3 -9
- data/lib/metanorma/document/relaton/relaton_collection.rb +2 -0
- data/lib/metanorma/document/relaton/series_type.rb +7 -0
- data/lib/metanorma/document/relaton/typed_note.rb +4 -0
- data/lib/metanorma/document/relaton/typed_title_string.rb +4 -0
- data/lib/metanorma/document/relaton/typed_uri.rb +3 -8
- data/lib/metanorma/document/relaton/validity_type.rb +8 -10
- data/lib/metanorma/document/relaton/variant_full_name.rb +3 -0
- data/lib/metanorma/document/relaton/variant_org_name.rb +3 -0
- data/lib/metanorma/document/relaton/version_info.rb +5 -0
- data/lib/metanorma/document/relaton/vocab_id_type.rb +6 -12
- data/lib/metanorma/document/relaton.rb +0 -14
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +1 -0
- data/lib/metanorma/html/base_renderer.rb +86 -234
- data/lib/metanorma/html/concerns/metadata_extraction.rb +61 -0
- data/lib/metanorma/html/concerns/presentation_validation.rb +61 -0
- data/lib/metanorma/html/concerns/svg_processing.rb +32 -0
- data/lib/metanorma/html/concerns/text_extraction.rb +93 -0
- data/lib/metanorma/html/concerns/toc_registry.rb +47 -0
- data/lib/metanorma/html/csa_renderer.rb +9 -0
- data/lib/metanorma/html/drops/figure_drop.rb +33 -10
- data/lib/metanorma/html/drops/sourcecode_drop.rb +3 -6
- data/lib/metanorma/html/flavor.rb +6 -1
- data/lib/metanorma/html/generator.rb +8 -1
- data/lib/metanorma/html/iso_renderer.rb +0 -142
- data/lib/metanorma/html/renderers/block_renderer.rb +10 -0
- data/lib/metanorma/html/renderers/element_order_traversal.rb +15 -1
- data/lib/metanorma/html/renderers/inline_renderer.rb +13 -75
- data/lib/metanorma/html/standard_renderer.rb +195 -35
- data/lib/metanorma/html.rb +1 -51
- data/lib/metanorma/iso_document/sections/iso_preface.rb +27 -13
- data/lib/metanorma/mirror/default_registry.rb +21 -0
- data/lib/metanorma/mirror/handlers/inline/catalog.rb +7 -12
- data/lib/metanorma/mirror/handlers/inline/rich_html_renderer.rb +2 -3
- data/lib/metanorma/mirror/handlers/sourcecode.rb +1 -1
- data/lib/metanorma/mirror/model/guide.rb +3 -2
- data/lib/metanorma/mirror/output/formats/inline_format.rb +64 -3
- data/lib/metanorma/mirror/output/pipeline.rb +1 -0
- data/lib/metanorma/mirror/output.rb +0 -2
- data/lib/metanorma/mirror/rewriter.rb +3 -1
- data/lib/metanorma/registers/setup.rb +10 -0
- data/lib/metanorma/standard_document/annotation_container.rb +2 -0
- data/lib/metanorma/standard_document/elements/input.rb +4 -25
- data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +12 -2
- data/lib/metanorma/standard_document/metadata/presentation_metadata.rb +107 -0
- data/lib/metanorma/standard_document/metadata/semantic_metadata.rb +18 -0
- data/lib/metanorma/standard_document/metadata/unitsml/amount_of_substance.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/base_quantity.rb +34 -0
- data/lib/metanorma/standard_document/metadata/unitsml/dimension.rb +39 -0
- data/lib/metanorma/standard_document/metadata/unitsml/dimension_set.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/electric_current.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/enumerated_root_unit.rb +23 -0
- data/lib/metanorma/standard_document/metadata/unitsml/length.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/luminous_intensity.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/mass.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/namespace.rb +17 -0
- data/lib/metanorma/standard_document/metadata/unitsml/plane_angle.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/prefix.rb +30 -0
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_name.rb +21 -0
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_set.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_symbol.rb +21 -0
- data/lib/metanorma/standard_document/metadata/unitsml/quantity.rb +28 -0
- data/lib/metanorma/standard_document/metadata/unitsml/quantity_name.rb +21 -0
- data/lib/metanorma/standard_document/metadata/unitsml/quantity_set.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/root_units.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/thermodynamic_temperature.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/time.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/unit.rb +32 -0
- data/lib/metanorma/standard_document/metadata/unitsml/unit_name.rb +21 -0
- data/lib/metanorma/standard_document/metadata/unitsml/unit_set.rb +19 -0
- data/lib/metanorma/standard_document/metadata/unitsml/unit_symbol.rb +36 -0
- data/lib/metanorma/standard_document/metadata/unitsml/unit_system.rb +23 -0
- data/lib/metanorma/standard_document/metadata/unitsml/unitsml_root.rb +28 -0
- data/lib/metanorma/standard_document/metadata/unitsml.rb +39 -0
- data/lib/metanorma/standard_document/metadata.rb +4 -0
- data/lib/metanorma/standard_document/sections/misc_container.rb +8 -6
- data/lib/metanorma/standard_document/sections/sections.rb +7 -0
- data/lib/metanorma/un_document/blocks/un_admonition_block.rb +86 -0
- data/lib/metanorma/un_document/blocks.rb +9 -0
- data/lib/metanorma/un_document/root.rb +8 -0
- data/lib/metanorma/un_document/sections/un_abstract_section.rb +48 -0
- data/lib/metanorma/un_document/sections/un_preface.rb +19 -2
- data/lib/metanorma/un_document/sections.rb +1 -0
- data/lib/metanorma/un_document/un_text_element.rb +116 -0
- data/lib/metanorma/un_document.rb +2 -0
- data/script/benchmark_render.rb +35 -0
- data/tasks/roundtrip_samples.rake +1 -1
- metadata +63 -45
- data/.rubocop_todo.yml +0 -220
- data/TODO.finalize/01-split-multi-class-files.md +0 -8
- data/TODO.finalize/02-remove-data-dist-iso-document-frontend.md +0 -6
- data/TODO.finalize/03-align-frontend-iife-and-gha-build.md +0 -11
- data/TODO.finalize/04-theme-per-flavor-config-driven.md +0 -9
- data/TODO.finalize/05-migrate-all-html-to-liquid.md +0 -16
- data/TODO.finalize/06-integrate-pubid-library.md +0 -16
- data/TODO.finalize/07-replace-relaton-models-with-relaton-bib.md +0 -39
- data/TODO.finalize/08-refactor-renderer-architecture.md +0 -25
- data/TODO.finalize/09-eliminate-code-smells.md +0 -14
- data/TODO.finalize/10-comprehensive-spec-coverage.md +0 -24
- data/TODO.finalize/11-config-driven-flavor-metadata.md +0 -20
- data/TODO.finalize/12-add-frozen-string-literal.md +0 -6
- data/TODO.finalize/13-extract-composition-from-god-class.md +0 -96
- data/TODO.finalize/14-config-driven-section-ordering.md +0 -31
- data/TODO.finalize/15-theme-directories-per-flavor.md +0 -46
- data/TODO.finalize/16-theme-lutaml-model-schema.md +0 -44
- data/docs/html-renderer.adoc +0 -261
- data/lib/data/dist/iso_document/frontend/assets/index-mwzbzmnK.js +0 -22
- data/lib/data/dist/iso_document/frontend/assets/index-pGvKTNid.css +0 -1
- data/lib/data/dist/iso_document/frontend/assets/iso-red.svg +0 -53
- data/lib/data/dist/iso_document/frontend/index.html +0 -13
- data/lib/metanorma/document/relaton/bib_item_size_type.rb +0 -21
- data/lib/metanorma/document/relaton/bibliographic_date_type.rb +0 -22
- data/lib/metanorma/document/relaton/document_relation_type.rb +0 -31
- data/lib/metanorma/document/relaton/iso4217_code.rb +0 -17
- data/lib/metanorma/document/relaton/iso8601_date.rb +0 -17
- data/lib/metanorma/document/relaton/personal_identifier_type.rb +0 -21
- data/lib/metanorma/document/relaton/region_type.rb +0 -20
- data/lib/metanorma/document/relaton/series_type_type.rb +0 -21
- data/lib/metanorma/document/relaton/specific_locality_type.rb +0 -25
- data/lib/metanorma/document/relaton/title_type.rb +0 -21
- data/lib/metanorma/mirror/output/html_renderer.rb +0 -95
- data/lib/metanorma/mirror/output/html_renderers/block_renderers.rb +0 -178
- data/lib/metanorma/mirror/output/html_renderers/inline_renderer.rb +0 -61
- data/lib/metanorma/mirror/output/html_renderers/list_renderers.rb +0 -96
- data/lib/metanorma/mirror/output/html_renderers/mark_renderers.rb +0 -41
- data/lib/metanorma/mirror/output/html_renderers/section_renderers.rb +0 -129
- data/lib/metanorma/mirror/output/html_renderers/structural_renderers.rb +0 -80
- data/lib/metanorma/mirror/output/html_renderers/table_renderers.rb +0 -87
- data/lib/metanorma/mirror/output/html_renderers.rb +0 -76
- data/lib/metanorma/standard_document/annotation.rb +0 -37
data/frontend/tailwind.config.js
CHANGED
|
@@ -4,6 +4,11 @@ export default {
|
|
|
4
4
|
'./src/**/*.{vue,ts,html}',
|
|
5
5
|
],
|
|
6
6
|
darkMode: 'class',
|
|
7
|
+
corePlugins: {
|
|
8
|
+
// Preflight resets bare elements, which would clobber the classic
|
|
9
|
+
// renderer's SSR body inlined by InlineFormat (no-JS placeholder).
|
|
10
|
+
preflight: false,
|
|
11
|
+
},
|
|
7
12
|
theme: {
|
|
8
13
|
extend: {
|
|
9
14
|
colors: {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module CsaDocument
|
|
5
|
+
class Root < Lutaml::Model::Serializable
|
|
6
|
+
include Metanorma::StandardDocument::RootAttributes
|
|
7
|
+
|
|
8
|
+
def self.lutaml_default_register
|
|
9
|
+
:csa_document
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
attribute :bibdata,
|
|
13
|
+
Metanorma::IsoDocument::Metadata::IsoBibliographicItem
|
|
14
|
+
attribute :preface, Metanorma::IsoDocument::Sections::IsoPreface
|
|
15
|
+
attribute :sections, Metanorma::IsoDocument::Sections::IsoSections
|
|
16
|
+
attribute :annex, Metanorma::IsoDocument::Sections::IsoAnnexSection,
|
|
17
|
+
collection: true
|
|
18
|
+
|
|
19
|
+
xml do
|
|
20
|
+
element "metanorma"
|
|
21
|
+
namespace Metanorma::StandardDocument::Namespace
|
|
22
|
+
|
|
23
|
+
Metanorma::StandardDocument::RootXmlMapping.apply(self)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -17,11 +17,20 @@ module Metanorma
|
|
|
17
17
|
keyword_init: true,
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
+
ToHtmlOptions = Struct.new(
|
|
21
|
+
:xml_path,
|
|
22
|
+
:output,
|
|
23
|
+
:flavor,
|
|
24
|
+
keyword_init: true,
|
|
25
|
+
)
|
|
26
|
+
|
|
20
27
|
def self.run(argv)
|
|
21
28
|
command = argv.shift
|
|
22
29
|
case command
|
|
23
30
|
when "to-mirror"
|
|
24
31
|
to_mirror(argv)
|
|
32
|
+
when "to-html"
|
|
33
|
+
to_html(argv)
|
|
25
34
|
when nil, "-h", "--help"
|
|
26
35
|
puts usage
|
|
27
36
|
else
|
|
@@ -101,12 +110,55 @@ module Metanorma
|
|
|
101
110
|
end
|
|
102
111
|
end
|
|
103
112
|
|
|
113
|
+
def self.to_html(argv)
|
|
114
|
+
options = parse_to_html_options(argv)
|
|
115
|
+
execute_to_html(options)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def self.parse_to_html_options(argv)
|
|
119
|
+
options = ToHtmlOptions.new(output: nil, flavor: nil)
|
|
120
|
+
|
|
121
|
+
parser = OptionParser.new do |opts|
|
|
122
|
+
opts.banner = "Usage: metanorma-document to-html <xml_path> [options]"
|
|
123
|
+
|
|
124
|
+
opts.on("-o", "--output PATH",
|
|
125
|
+
"Output HTML path (default: stdout)") do |path|
|
|
126
|
+
options.output = path
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
opts.on("-f", "--flavor FLAVOR",
|
|
130
|
+
"Document flavor (default: auto-detect)") do |flavor|
|
|
131
|
+
options.flavor = flavor
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
parser.parse!(argv)
|
|
136
|
+
|
|
137
|
+
xml_path = argv.shift
|
|
138
|
+
raise Error, "XML path required" unless xml_path
|
|
139
|
+
raise Error, "File not found: #{xml_path}" unless File.exist?(xml_path)
|
|
140
|
+
|
|
141
|
+
options.xml_path = xml_path
|
|
142
|
+
options
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def self.execute_to_html(options)
|
|
146
|
+
# Metanorma::Html is autoloaded from metanorma/document.
|
|
147
|
+
# Reuse the mirror pipeline's flavor inference/model dispatch so
|
|
148
|
+
# to-html and to-mirror parse documents identically.
|
|
149
|
+
step = Mirror::Output::Pipeline::Steps::ParseXml.new
|
|
150
|
+
flavor = options.flavor || step.infer_flavor(options.xml_path)
|
|
151
|
+
doc = step.flavor_class(flavor).from_xml(File.read(options.xml_path))
|
|
152
|
+
write_output(Html::Generator.generate(doc), options.output)
|
|
153
|
+
end
|
|
154
|
+
|
|
104
155
|
def self.usage
|
|
105
156
|
<<~USAGE
|
|
106
157
|
Usage: metanorma-document <command> [options]
|
|
107
158
|
|
|
108
159
|
Commands:
|
|
109
160
|
to-mirror Convert presentation XML to mirror JSON
|
|
161
|
+
to-html Render presentation XML to standalone HTML
|
|
110
162
|
|
|
111
163
|
Run `metanorma-document <command> --help` for command-specific options.
|
|
112
164
|
USAGE
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "cgi"
|
|
4
|
+
|
|
3
5
|
module Metanorma
|
|
4
6
|
module Document
|
|
5
7
|
module Components
|
|
@@ -11,6 +13,18 @@ module Metanorma
|
|
|
11
13
|
element "body"
|
|
12
14
|
map_all_content to: :content
|
|
13
15
|
end
|
|
16
|
+
|
|
17
|
+
# The source text with XML entities DECODED (`<` → `<`).
|
|
18
|
+
#
|
|
19
|
+
# `content` is markup-encoded by design: map_all_content keeps
|
|
20
|
+
# the raw inner markup so to_xml can re-emit it verbatim
|
|
21
|
+
# (roundtrip fidelity). Consumers that display the code as
|
|
22
|
+
# text need the decoded form — without it they double-escape
|
|
23
|
+
# (`&lt;`) or hand-roll fragile gsub chains. Comments in
|
|
24
|
+
# the listing stay literal ("<!-- ... -->").
|
|
25
|
+
def decoded_content
|
|
26
|
+
CGI.unescapeHTML(Array(content).join)
|
|
27
|
+
end
|
|
14
28
|
end
|
|
15
29
|
end
|
|
16
30
|
end
|
|
@@ -5,6 +5,8 @@ module Metanorma
|
|
|
5
5
|
module Components
|
|
6
6
|
module Inline
|
|
7
7
|
class ErefElement < Lutaml::Model::Serializable
|
|
8
|
+
include Inline::Vocabulary
|
|
9
|
+
|
|
8
10
|
attribute :id, :string
|
|
9
11
|
attribute :type, :string
|
|
10
12
|
attribute :bibitemid, :string
|
|
@@ -15,10 +17,10 @@ module Metanorma
|
|
|
15
17
|
attribute :relative, :string
|
|
16
18
|
attribute :locality_stack, Metanorma::Document::Relaton::LocalityStack,
|
|
17
19
|
collection: true
|
|
18
|
-
attribute :text, :string
|
|
19
20
|
|
|
20
21
|
xml do
|
|
21
22
|
element "eref"
|
|
23
|
+
mixed_content
|
|
22
24
|
map_attribute "id", to: :id
|
|
23
25
|
map_attribute "type", to: :type
|
|
24
26
|
map_attribute "bibitemid", to: :bibitemid
|
|
@@ -29,6 +31,7 @@ module Metanorma
|
|
|
29
31
|
map_attribute "relative", to: :relative
|
|
30
32
|
map_element "localityStack", to: :locality_stack
|
|
31
33
|
map_content to: :text
|
|
34
|
+
Vocabulary::VocabularyXmlMapping.apply_inline_mappings(self)
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
end
|
|
@@ -6,16 +6,18 @@ module Metanorma
|
|
|
6
6
|
module Inline
|
|
7
7
|
class FmtTermsourceElement < Lutaml::Model::Serializable
|
|
8
8
|
include RenderedDisplay
|
|
9
|
+
include Inline::Vocabulary
|
|
9
10
|
|
|
10
11
|
attribute :status, :string
|
|
11
12
|
attribute :type, :string
|
|
12
|
-
attribute :semx, SemxElement
|
|
13
13
|
|
|
14
14
|
xml do
|
|
15
15
|
element "fmt-termsource"
|
|
16
|
+
mixed_content
|
|
16
17
|
map_attribute "status", to: :status
|
|
17
18
|
map_attribute "type", to: :type
|
|
18
|
-
|
|
19
|
+
map_content to: :text
|
|
20
|
+
Vocabulary::VocabularyXmlMapping.apply_inline_mappings(self)
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "mml"
|
|
4
|
+
|
|
3
5
|
module Metanorma
|
|
4
6
|
module Document
|
|
5
7
|
module Components
|
|
6
8
|
module Inline
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
# A MathML `<math>` element. Modeled via the mml gem's
|
|
10
|
+
# `Mml::V3::Math`, which carries the MathML namespace and a full
|
|
11
|
+
# MathML content model — no raw markup strings (project rule),
|
|
12
|
+
# and the `xmlns` survives round-trips (previously the
|
|
13
|
+
# raw-capture mapping dropped it, silently moving `<math>` into
|
|
14
|
+
# the standoc namespace on serialize).
|
|
15
|
+
#
|
|
16
|
+
# Subclasses SemanticMathElement/RenderedMathElement stay as pure
|
|
17
|
+
# markers so consumers can distinguish the canonical form from
|
|
18
|
+
# the locale-rendered form via `is_a?`.
|
|
19
|
+
class MathElement < Mml::V3::Math
|
|
14
20
|
end
|
|
15
21
|
end
|
|
16
22
|
end
|
|
@@ -107,6 +107,9 @@ module Metanorma
|
|
|
107
107
|
collection: true
|
|
108
108
|
base.attribute :del, "Metanorma::Document::Elements::Del",
|
|
109
109
|
collection: true
|
|
110
|
+
base.attribute :input,
|
|
111
|
+
Metanorma::Document::Elements::Input,
|
|
112
|
+
collection: true
|
|
110
113
|
end
|
|
111
114
|
|
|
112
115
|
def declare_rendered_display_attributes_on(base)
|
|
@@ -164,6 +167,7 @@ module Metanorma
|
|
|
164
167
|
"index" => :index,
|
|
165
168
|
"add" => :add,
|
|
166
169
|
"del" => :del,
|
|
170
|
+
"input" => :input,
|
|
167
171
|
"fmt-stem" => :fmt_stem,
|
|
168
172
|
"fmt-concept" => :fmt_concept,
|
|
169
173
|
"fmt-fn-label" => :fmt_fn_label,
|
|
@@ -10,10 +10,15 @@ module Metanorma
|
|
|
10
10
|
# Subclass of admonition determining how it is to be rendered; e.g.
|
|
11
11
|
# Warning, Note, Tip.
|
|
12
12
|
# Distinct admonition types are often associated with distinct icons or rendering.
|
|
13
|
+
# Values are the union of AdmonitionType across current flavor grammars:
|
|
14
|
+
# basicdoc + isodoc: caution, editorial, important, note, statement,
|
|
15
|
+
# tip, warning, box
|
|
16
|
+
# isostandard.rng / un.rng: danger, safety precautions
|
|
17
|
+
# bsi.rng / jis.rng: commentary
|
|
13
18
|
attribute :type, :string,
|
|
14
19
|
values: %w[danger caution warning important
|
|
15
20
|
safety\ precautions editorial tip note
|
|
16
|
-
commentary]
|
|
21
|
+
commentary statement box]
|
|
17
22
|
|
|
18
23
|
# Caption of admonition.
|
|
19
24
|
attribute :name, Metanorma::Document::Components::TextElements::TextElement,
|
|
@@ -81,6 +81,8 @@ module Metanorma
|
|
|
81
81
|
collection: true
|
|
82
82
|
attribute :del, "Metanorma::Document::Elements::Del",
|
|
83
83
|
collection: true
|
|
84
|
+
attribute :input, Metanorma::Document::Elements::Input,
|
|
85
|
+
collection: true
|
|
84
86
|
|
|
85
87
|
# JSON serialization attributes
|
|
86
88
|
attribute :json_type, :string
|
|
@@ -138,6 +140,7 @@ module Metanorma
|
|
|
138
140
|
map_element "image", to: :image
|
|
139
141
|
map_element "add", to: :add
|
|
140
142
|
map_element "del", to: :del
|
|
143
|
+
map_element "input", to: :input
|
|
141
144
|
end
|
|
142
145
|
|
|
143
146
|
def json_content
|
|
@@ -10,13 +10,14 @@ module Metanorma
|
|
|
10
10
|
class Callout < ReferenceToIdElement
|
|
11
11
|
attribute :target_attr, :string
|
|
12
12
|
attribute :type, :string
|
|
13
|
-
attribute :text,
|
|
13
|
+
attribute :text, :string, collection: true
|
|
14
14
|
|
|
15
15
|
xml do
|
|
16
16
|
element "callout"
|
|
17
|
+
mixed_content
|
|
17
18
|
map_attribute "target", to: :target_attr
|
|
18
19
|
map_element "type", to: :type
|
|
19
|
-
|
|
20
|
+
map_content to: :text
|
|
20
21
|
end
|
|
21
22
|
end
|
|
22
23
|
end
|
|
@@ -84,6 +84,8 @@ module Metanorma
|
|
|
84
84
|
collection: true
|
|
85
85
|
attribute :bookmark, Metanorma::Document::Components::IdElements::Bookmark,
|
|
86
86
|
collection: true
|
|
87
|
+
attribute :input, Metanorma::Document::Elements::Input,
|
|
88
|
+
collection: true
|
|
87
89
|
attribute :fmt_annotation_start,
|
|
88
90
|
Metanorma::Document::Components::Inline::FmtAnnotationStartElement, collection: true
|
|
89
91
|
attribute :fmt_annotation_end,
|
|
@@ -130,6 +132,7 @@ module Metanorma
|
|
|
130
132
|
map_element "semx", to: :semx
|
|
131
133
|
map_element "span", to: :span
|
|
132
134
|
map_element "bookmark", to: :bookmark
|
|
135
|
+
map_element "input", to: :input
|
|
133
136
|
map_element "fmt-annotation-start", to: :fmt_annotation_start
|
|
134
137
|
map_element "fmt-annotation-end", to: :fmt_annotation_end
|
|
135
138
|
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Metanorma
|
|
4
|
+
module Document
|
|
5
|
+
module Elements
|
|
6
|
+
# An `<input>` form field (text, checkbox, ...) as it appears inline
|
|
7
|
+
# in form-bearing documents (e.g. OIML application forms). Lives in
|
|
8
|
+
# the document layer so shared inline containers (ParagraphBlock,
|
|
9
|
+
# TableCell, Inline::Vocabulary) can map it without referencing
|
|
10
|
+
# higher model layers.
|
|
11
|
+
class Input < Lutaml::Model::Serializable
|
|
12
|
+
attribute :id, :string
|
|
13
|
+
attribute :name, :string
|
|
14
|
+
attribute :value, :string
|
|
15
|
+
attribute :type, :string
|
|
16
|
+
attribute :checked, :boolean
|
|
17
|
+
attribute :disabled, :boolean
|
|
18
|
+
attribute :readonly, :boolean
|
|
19
|
+
attribute :maxlength, :integer
|
|
20
|
+
attribute :minlength, :integer
|
|
21
|
+
|
|
22
|
+
attribute :semx_id, :string
|
|
23
|
+
attribute :original_id, :string
|
|
24
|
+
|
|
25
|
+
xml do
|
|
26
|
+
element "input"
|
|
27
|
+
|
|
28
|
+
map_attribute "id", to: :id
|
|
29
|
+
map_attribute "name", to: :name
|
|
30
|
+
map_attribute "value", to: :value
|
|
31
|
+
map_attribute "type", to: :type
|
|
32
|
+
map_attribute "checked", to: :checked
|
|
33
|
+
map_attribute "disabled", to: :disabled
|
|
34
|
+
map_attribute "readonly", to: :readonly
|
|
35
|
+
map_attribute "maxlength", to: :maxlength
|
|
36
|
+
map_attribute "minlength", to: :minlength
|
|
37
|
+
|
|
38
|
+
map_attribute "semx-id", to: :semx_id
|
|
39
|
+
map_attribute "original-id", to: :original_id
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
|
+
# An address of a person or organization.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Address has no
|
|
8
|
+
# formatted-address attribute and types formattedAddress as a raw
|
|
9
|
+
# string — fixtures carry structured formattedAddress content with
|
|
10
|
+
# <br/> line breaks (ietf), kept queryable via FormattedAddress.
|
|
6
11
|
class Address < Lutaml::Model::Serializable
|
|
7
12
|
attribute :formatted_address_attr, :string
|
|
8
13
|
attribute :formatted_address, FormattedAddress
|
|
@@ -4,6 +4,9 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# The affiliation of a person with an organization.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Affiliation
|
|
8
|
+
# sanitizes description (LocalizedMarkedUpString strips semx/span/fmt-*)
|
|
9
|
+
# and types name/organization as relaton's own classes.
|
|
7
10
|
class Affiliation < Lutaml::Model::Serializable
|
|
8
11
|
attribute :name, Metanorma::Document::Components::DataTypes::LocalizedString
|
|
9
12
|
attribute :description,
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "relaton/bib"
|
|
4
|
+
|
|
3
5
|
module Metanorma
|
|
4
6
|
module Document
|
|
5
7
|
module Relaton
|
|
6
8
|
# The size of a bibliographic item being referred to.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
map_attribute "type", to: :type
|
|
14
|
-
map_element "value", to: :value
|
|
15
|
-
end
|
|
9
|
+
# relaton-bib's <size><value type>text</value></size> grammar matches
|
|
10
|
+
# metanorma biblio.rng; this gem's previous grammar had +type+ on
|
|
11
|
+
# +size+ itself and a singular +value+.
|
|
12
|
+
class BibItemSize < ::Relaton::Bib::Size
|
|
13
|
+
# Compatibility reader: relaton-bib carries +type+ on each +value+.
|
|
14
|
+
def type = value&.first&.type
|
|
16
15
|
end
|
|
17
16
|
end
|
|
18
17
|
end
|
|
@@ -4,6 +4,9 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# Type of bibliographic item.
|
|
7
|
+
# Keep-forever (wave-5 sweep): relaton-bib 2.2.0.pre.alpha.1 carries
|
|
8
|
+
# the item type as a plain accessor, not a mapped bib-item-type
|
|
9
|
+
# element class; not a migration candidate.
|
|
7
10
|
class BibItemType < Lutaml::Model::Serializable
|
|
8
11
|
attribute :value, :string
|
|
9
12
|
|
|
@@ -4,6 +4,11 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# Significant date in the lifecycle of the bibliographic item.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Bib::Date has no
|
|
8
|
+
# +format+ attribute and no text content, and casts on→at as StringDate
|
|
9
|
+
# (nil-ing non-ISO values like "–") — fixture dates such as
|
|
10
|
+
# <date type="published" format="ddMMMyyyy">I.2019</date> would
|
|
11
|
+
# re-serialize as a bare <date type="published"/>.
|
|
7
12
|
class BibliographicDate < Lutaml::Model::Serializable
|
|
8
13
|
attribute :type, :string
|
|
9
14
|
attribute :format, :string
|
|
@@ -4,6 +4,11 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# Contact information for a person or organization.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 has no Contact
|
|
8
|
+
# model class — its Contact mixin inlines phone/email/address/uri
|
|
9
|
+
# directly on Person/Organization (the fixture shape), so there is no
|
|
10
|
+
# counterpart to inherit. The <contact> wrapper appears in no fixture;
|
|
11
|
+
# kept because the Person and Organization mappings declare it.
|
|
7
12
|
class ContactMethod < Lutaml::Model::Serializable
|
|
8
13
|
attribute :address, Metanorma::Document::Relaton::Address
|
|
9
14
|
attribute :phone, Metanorma::Document::Relaton::Phone, collection: true
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "relaton/bib"
|
|
4
|
+
|
|
3
5
|
module Metanorma
|
|
4
6
|
module Document
|
|
5
7
|
module Relaton
|
|
6
8
|
# Description of a contributor to the production of the bibliographic item.
|
|
7
|
-
|
|
9
|
+
# Inherits relaton-bib's Contributor (role + person/organization choice);
|
|
10
|
+
# the three mappings are re-declared with Metanorma's richer model
|
|
11
|
+
# classes (mixed-content role, presentation-aware person/organization).
|
|
12
|
+
class ContributionInfo < ::Relaton::Bib::Contributor
|
|
8
13
|
attribute :role, ContributorRole, collection: true
|
|
9
14
|
attribute :organization, Organization
|
|
10
15
|
attribute :person, Person
|
|
11
16
|
|
|
12
17
|
xml do
|
|
13
|
-
element "contributor"
|
|
14
18
|
map_element "role", to: :role
|
|
15
19
|
map_element "organization", to: :organization
|
|
16
20
|
map_element "person", to: :person
|
|
@@ -5,6 +5,10 @@ module Metanorma
|
|
|
5
5
|
module Relaton
|
|
6
6
|
# The contributor involved in the production of a bibliographic item; may be either a person or an
|
|
7
7
|
# organization.
|
|
8
|
+
# Keep-forever (wave-5 sweep): internal base class for Organization and
|
|
9
|
+
# the contributor-typed attributes — relaton-bib 2.2.0.pre.alpha.1
|
|
10
|
+
# Contributor is a role+entity model, not this wrapper; not a migration
|
|
11
|
+
# candidate.
|
|
8
12
|
class Contributor < Lutaml::Model::Serializable
|
|
9
13
|
xml do
|
|
10
14
|
element "contributor"
|
|
@@ -4,6 +4,9 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# A description of the role of the contributor in the production of a bibliographic item.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Contributor::Role
|
|
8
|
+
# has no mixed content (BIPM fixture: <role type="editor">Author for
|
|
9
|
+
# correspondence</role>) and sanitizes description markup.
|
|
7
10
|
class ContributorRole < Lutaml::Model::Serializable
|
|
8
11
|
attribute :type, :string
|
|
9
12
|
attribute :description,
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Copyright types
|
|
7
|
+
# from/to as bare strings (ours preserve the DateTime text attribute) and
|
|
8
|
+
# maps scope as an element (ours is an attribute).
|
|
6
9
|
class CopyrightAssociation < Lutaml::Model::Serializable
|
|
7
10
|
attribute :from, Metanorma::Document::Relaton::DateTime
|
|
8
11
|
attribute :to, Metanorma::Document::Relaton::DateTime
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 has no owner
|
|
7
|
+
# wrapper (Copyright maps owner directly to ContributionInfo); the
|
|
8
|
+
# wrapper is kept for consumer compatibility.
|
|
6
9
|
class CopyrightOwner < Lutaml::Model::Serializable
|
|
7
10
|
attribute :organization, Organization
|
|
8
11
|
|
|
@@ -5,6 +5,9 @@ module Metanorma
|
|
|
5
5
|
module Relaton
|
|
6
6
|
# Type which allows date and time to be specified as either a Gregorian
|
|
7
7
|
# date and time, as specified in <<iso8601>>, as text, or as both.
|
|
8
|
+
# Keep-forever (wave-5 sweep): Metanorma-specific text/content shape
|
|
9
|
+
# with no relaton-bib 2.2.0.pre.alpha.1 counterpart; not a migration
|
|
10
|
+
# candidate.
|
|
8
11
|
class DateTime < Lutaml::Model::Serializable
|
|
9
12
|
attribute :text, :string
|
|
10
13
|
attribute :content, :string
|
|
@@ -4,6 +4,10 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# An identifier of a bibliographic item in an international standard scheme.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Docidentifier
|
|
8
|
+
# inherits LocalizedMarkedUpString, whose Sanitizer strips
|
|
9
|
+
# span/semx/link/fmt-* from the content at assignment time, and reads
|
|
10
|
+
# the identifier string as +content+ (ours is +id+).
|
|
7
11
|
class DocumentIdentifier < Lutaml::Model::Serializable
|
|
8
12
|
attribute :id, :string
|
|
9
13
|
attribute :type, :string
|
|
@@ -4,6 +4,14 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# Relation between a bibliographic item and another bibliographic item.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Relation types
|
|
8
|
+
# description as a singular sanitized LocalizedMarkedUpString (ours is
|
|
9
|
+
# a FormattedString collection), bibitem as relaton's own ItemBase tree
|
|
10
|
+
# (fixtures nest full Metanorma bibitems — fetched, multi-language
|
|
11
|
+
# titles, typed uris, primary docidentifiers — modeled by our
|
|
12
|
+
# BibliographicItem), and replaces the localityStack/
|
|
13
|
+
# sourceLocalityStack-only shape with choice(locality|localityStack)
|
|
14
|
+
# under different attribute names.
|
|
7
15
|
class DocumentRelation < Lutaml::Model::Serializable
|
|
8
16
|
attribute :type, :string
|
|
9
17
|
attribute :description,
|
|
@@ -4,6 +4,10 @@ module Metanorma
|
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
6
|
# The publication or preparation status of a document.
|
|
7
|
+
# Keeps its own mapping: relaton-bib 2.2.0.pre.alpha.1 Status has
|
|
8
|
+
# singular stage/substage, its Stage lacks +language+, and there is no
|
|
9
|
+
# stage-abbreviation element — fixtures carry multi-language stage
|
|
10
|
+
# collections (read as .value/.language by the ISO renderer).
|
|
7
11
|
class DocumentStatus < Lutaml::Model::Serializable
|
|
8
12
|
attribute :stage, Metanorma::Document::Components::DataTypes::FormattedString,
|
|
9
13
|
collection: true
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Document
|
|
5
5
|
module Relaton
|
|
6
|
+
# A pre-formatted postal address with explicit line breaks.
|
|
7
|
+
# Keep-forever (wave-5 sweep): structured content + br elements —
|
|
8
|
+
# relaton-bib 2.2.0.pre.alpha.1 types formattedAddress as a raw string;
|
|
9
|
+
# not a migration candidate.
|
|
6
10
|
class FormattedAddress < Lutaml::Model::Serializable
|
|
7
11
|
attribute :content, :string, collection: true
|
|
8
12
|
attribute :br, Metanorma::Document::Components::Inline::BrElement,
|