metanorma-document 0.5.1 → 0.5.2.pre.alpha.1
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/README.adoc +81 -0
- data/Rakefile +3 -7
- data/data/themes/ogc.yaml +5 -0
- data/lib/metanorma/basic_document/ancillary_blocks/figure_block.rb +2 -2
- data/lib/metanorma/basic_document/multi_paragraph/admonition_block.rb +2 -2
- data/lib/metanorma/document/cli.rb +134 -0
- data/lib/metanorma/document/components/ancillary_blocks/figure_block.rb +5 -0
- data/lib/metanorma/document/components/ancillary_blocks/fmt_figure_element.rb +47 -0
- data/lib/metanorma/document/components/ancillary_blocks/formula_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/imagemap_element.rb +73 -0
- data/lib/metanorma/document/components/ancillary_blocks/literal_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/svg_target_element.rb +27 -0
- data/lib/metanorma/document/components/ancillary_blocks/svgmap_element.rb +28 -0
- data/lib/metanorma/document/components/ancillary_blocks.rb +4 -0
- data/lib/metanorma/document/components/bib_data/bibliographic_item.rb +4 -0
- data/lib/metanorma/document/components/blocks/fmt_provision.rb +25 -0
- data/lib/metanorma/document/components/blocks/note_block.rb +8 -0
- data/lib/metanorma/document/components/blocks/permission_model.rb +9 -0
- data/lib/metanorma/document/components/blocks/recommendation_model.rb +9 -0
- data/lib/metanorma/document/components/blocks/requirement_base.rb +12 -0
- data/lib/metanorma/document/components/blocks/requirement_import.rb +23 -0
- data/lib/metanorma/document/components/blocks/requirement_measurement_target.rb +23 -0
- data/lib/metanorma/document/components/blocks/requirement_model.rb +9 -0
- data/lib/metanorma/document/components/blocks/requirement_specification.rb +23 -0
- data/lib/metanorma/document/components/blocks/requirement_verification.rb +23 -0
- data/lib/metanorma/document/components/blocks.rb +8 -0
- data/lib/metanorma/document/components/data_types/formatted_string.rb +9 -0
- data/lib/metanorma/document/components/id_elements/image.rb +4 -0
- data/lib/metanorma/document/components/inline/columnbreak_element.rb +17 -0
- data/lib/metanorma/document/components/inline/concept_element.rb +18 -0
- data/lib/metanorma/document/components/inline/date_element.rb +29 -0
- data/lib/metanorma/document/components/inline/display_text_element.rb +2 -0
- data/lib/metanorma/document/components/inline/em_raw_element.rb +6 -7
- data/lib/metanorma/document/components/inline/eref_element.rb +48 -22
- data/lib/metanorma/document/components/inline/eref_stack.rb +23 -0
- data/lib/metanorma/document/components/inline/error_message.rb +28 -0
- data/lib/metanorma/document/components/inline/fmt_date_element.rb +28 -0
- data/lib/metanorma/document/components/inline/fmt_date_inline_element.rb +26 -0
- data/lib/metanorma/document/components/inline/fmt_eref_element.rb +25 -0
- data/lib/metanorma/document/components/inline/fmt_origin_element.rb +24 -0
- data/lib/metanorma/document/components/inline/fmt_preferred_element.rb +3 -0
- data/lib/metanorma/document/components/inline/fmt_source_element.rb +31 -0
- data/lib/metanorma/document/components/inline/fn_element.rb +11 -0
- data/lib/metanorma/document/components/inline/link_element.rb +8 -0
- data/lib/metanorma/document/components/inline/name_with_id_element.rb +2 -0
- data/lib/metanorma/document/components/inline/refterm_element.rb +21 -0
- data/lib/metanorma/document/components/inline/semx_element.rb +22 -0
- data/lib/metanorma/document/components/inline/sourcelocality_stack_element.rb +27 -0
- data/lib/metanorma/document/components/inline/span_element.rb +2 -0
- data/lib/metanorma/document/components/inline/stem_inline_element.rb +2 -0
- data/lib/metanorma/document/components/inline/strong_raw_element.rb +6 -9
- data/lib/metanorma/document/components/inline/sub_element.rb +2 -0
- data/lib/metanorma/document/components/inline/termref_element.rb +24 -0
- data/lib/metanorma/document/components/inline/title_with_annotation_element.rb +10 -31
- data/lib/metanorma/document/components/inline/variant_title_element.rb +2 -0
- data/lib/metanorma/document/components/inline/vocabulary.rb +36 -0
- data/lib/metanorma/document/components/inline.rb +23 -0
- data/lib/metanorma/document/components/lists/dd_element.rb +6 -1
- data/lib/metanorma/document/components/lists/definition.rb +2 -0
- data/lib/metanorma/document/components/lists/definition_list.rb +3 -0
- data/lib/metanorma/document/components/lists/dt_element.rb +3 -0
- data/lib/metanorma/document/components/lists/fmt_list_element.rb +73 -0
- data/lib/metanorma/document/components/lists/list_item.rb +3 -0
- data/lib/metanorma/document/components/lists/ordered_list.rb +4 -2
- data/lib/metanorma/document/components/lists/unordered_list.rb +2 -0
- data/lib/metanorma/document/components/lists.rb +2 -0
- data/lib/metanorma/document/components/multi_paragraph/quote_block.rb +16 -0
- data/lib/metanorma/document/components/multi_paragraph/review_block.rb +2 -2
- data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +15 -0
- data/lib/metanorma/document/components/reference_elements/citation.rb +7 -0
- data/lib/metanorma/document/components/reference_elements/source_element.rb +4 -0
- data/lib/metanorma/document/components/semantic/node.rb +46 -0
- data/lib/metanorma/document/components/semantic.rb +11 -0
- data/lib/metanorma/document/components/tables/header_table_cell.rb +1 -0
- data/lib/metanorma/document/components/tables/table_cell.rb +70 -44
- data/lib/metanorma/document/components/tables/text_table_cell.rb +1 -0
- data/lib/metanorma/document/components/tables/text_table_row.rb +2 -0
- data/lib/metanorma/document/components/text_elements/ruby_annotation_element.rb +26 -0
- data/lib/metanorma/document/components/text_elements/ruby_element.rb +41 -6
- data/lib/metanorma/document/components/text_elements/ruby_pronunciation_element.rb +25 -0
- data/lib/metanorma/document/components/text_elements/strike_element.rb +3 -0
- data/lib/metanorma/document/components/text_elements/underline_element.rb +3 -0
- data/lib/metanorma/document/components/text_elements.rb +2 -0
- data/lib/metanorma/document/components.rb +1 -0
- data/lib/metanorma/document/grammar_vocabulary.rb +109 -0
- data/lib/metanorma/document/mirror_seed.rb +253 -0
- data/lib/metanorma/document/mko/collection.rb +168 -0
- data/lib/metanorma/document/mko/exporter.rb +17 -0
- data/lib/metanorma/document/mko/project.rb +1110 -0
- data/lib/metanorma/document/mko.rb +122 -0
- data/lib/metanorma/document/model_access.rb +44 -0
- data/lib/metanorma/document/native_models.rb +319 -0
- data/lib/metanorma/document/plain_text.rb +39 -0
- data/lib/metanorma/document/relaton/version_info.rb +4 -0
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +19 -26
- data/lib/metanorma/{collection → document_collection}/directive.rb +1 -1
- data/lib/metanorma/{collection → document_collection}/doc_container.rb +6 -2
- data/lib/metanorma/{collection → document_collection}/entry.rb +2 -2
- data/lib/metanorma/{collection → document_collection}/root.rb +2 -2
- data/lib/metanorma/document_collection.rb +10 -0
- data/lib/metanorma/html/base_renderer.rb +94 -25
- data/lib/metanorma/html/component/footnote_collector.rb +21 -20
- data/lib/metanorma/html/concerns/metadata_extraction.rb +8 -3
- data/lib/metanorma/html/concerns/presentation_validation.rb +1 -2
- data/lib/metanorma/html/concerns/text_extraction.rb +154 -35
- data/lib/metanorma/html/concerns.rb +19 -0
- data/lib/metanorma/html/drops/admonition_drop.rb +1 -1
- data/lib/metanorma/html/drops/footnote_drop.rb +1 -1
- data/lib/metanorma/html/drops/sourcecode_drop.rb +22 -4
- data/lib/metanorma/html/generator.rb +11 -187
- data/lib/metanorma/html/renderer_delegation.rb +2 -2
- data/lib/metanorma/html/renderers/block_renderer.rb +206 -46
- data/lib/metanorma/html/renderers/inline_renderer.rb +144 -17
- data/lib/metanorma/html/renderers/section_renderer.rb +12 -2
- data/lib/metanorma/html/renderers/semantic_renderer.rb +487 -0
- data/lib/metanorma/html/renderers.rb +2 -0
- data/lib/metanorma/html/standard_renderer.rb +732 -76
- data/lib/metanorma/html/templates/_agency_cover.html.liquid +30 -0
- data/lib/metanorma/html/templates/_columnbreak.html.liquid +1 -0
- data/lib/metanorma/html/templates/_cover.html.liquid +3 -0
- data/lib/metanorma/html/templates/_main_content.html.liquid +1 -1
- data/lib/metanorma/html/templates/_ruby.html.liquid +1 -0
- data/lib/metanorma/html/templates/_sourcecode.html.liquid +4 -3
- data/lib/metanorma/html/templates/_standard_cover.html.liquid +54 -3
- data/lib/metanorma/html.rb +30 -15
- data/tasks/flavors.rake +116 -0
- data/tasks/grammar.rake +28 -0
- data/tasks/roundtrip_samples.rake +48 -34
- metadata +121 -416
- data/frontend/dist/app.css +0 -1
- data/frontend/dist/app.iife.js +0 -24
- data/lib/metanorma/bipm_document/metadata/bipm_bib_data_extension_type.rb +0 -20
- data/lib/metanorma/bipm_document/metadata/bipm_bibliographic_item.rb +0 -17
- data/lib/metanorma/bipm_document/metadata/bipm_structured_identifier.rb +0 -21
- data/lib/metanorma/bipm_document/metadata/depiction_element.rb +0 -18
- data/lib/metanorma/bipm_document/metadata.rb +0 -15
- data/lib/metanorma/bipm_document/root.rb +0 -25
- data/lib/metanorma/bipm_document.rb +0 -8
- data/lib/metanorma/bsi_document/metadata/bsi_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/bsi_document/metadata/bsi_bibliographic_item.rb +0 -15
- data/lib/metanorma/bsi_document/metadata.rb +0 -12
- data/lib/metanorma/bsi_document/root.rb +0 -29
- data/lib/metanorma/bsi_document/sections/bsi_annex_section.rb +0 -25
- data/lib/metanorma/bsi_document/sections/bsi_clause_section.rb +0 -25
- data/lib/metanorma/bsi_document/sections/bsi_sections.rb +0 -27
- data/lib/metanorma/bsi_document/sections.rb +0 -11
- data/lib/metanorma/bsi_document.rb +0 -11
- data/lib/metanorma/cc_document/metadata/cc_bib_data_extension_type.rb +0 -12
- data/lib/metanorma/cc_document/metadata/cc_bibliographic_item.rb +0 -17
- data/lib/metanorma/cc_document/metadata.rb +0 -11
- data/lib/metanorma/cc_document/root.rb +0 -25
- data/lib/metanorma/cc_document.rb +0 -8
- data/lib/metanorma/collection.rb +0 -10
- data/lib/metanorma/csa_document/root.rb +0 -27
- data/lib/metanorma/csa_document.rb +0 -9
- data/lib/metanorma/gb_document/metadata/gb_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/gb_document/metadata/gb_bibliographic_item.rb +0 -15
- data/lib/metanorma/gb_document/metadata.rb +0 -12
- data/lib/metanorma/gb_document/root.rb +0 -29
- data/lib/metanorma/gb_document.rb +0 -10
- data/lib/metanorma/generic_document/root.rb +0 -31
- data/lib/metanorma/generic_document.rb +0 -7
- data/lib/metanorma/html/bipm_renderer.rb +0 -23
- data/lib/metanorma/html/cc_renderer.rb +0 -9
- data/lib/metanorma/html/csa_renderer.rb +0 -9
- data/lib/metanorma/html/flavor.rb +0 -50
- data/lib/metanorma/html/flavor_registry.rb +0 -49
- data/lib/metanorma/html/icc_renderer.rb +0 -10
- data/lib/metanorma/html/iec_renderer.rb +0 -9
- data/lib/metanorma/html/ieee_renderer.rb +0 -9
- data/lib/metanorma/html/ietf_renderer.rb +0 -9
- data/lib/metanorma/html/iho_renderer.rb +0 -9
- data/lib/metanorma/html/iso_renderer.rb +0 -535
- data/lib/metanorma/html/itu_renderer.rb +0 -9
- data/lib/metanorma/html/ogc_renderer.rb +0 -23
- data/lib/metanorma/html/pdfa_renderer.rb +0 -10
- data/lib/metanorma/html/ribose_renderer.rb +0 -9
- data/lib/metanorma/html/templates/_bipm_cover.html.liquid +0 -27
- data/lib/metanorma/html/templates/_iso_cover.html.liquid +0 -31
- data/lib/metanorma/html/templates/_iso_doc_title.html.liquid +0 -3
- data/lib/metanorma/iec_document/root.rb +0 -27
- data/lib/metanorma/iec_document.rb +0 -9
- data/lib/metanorma/ieee_document/metadata/ieee_bib_data_extension_type.rb +0 -18
- data/lib/metanorma/ieee_document/metadata/ieee_bibliographic_item.rb +0 -20
- data/lib/metanorma/ieee_document/metadata/ieee_structured_identifier.rb +0 -25
- data/lib/metanorma/ieee_document/metadata.rb +0 -14
- data/lib/metanorma/ieee_document/root.rb +0 -29
- data/lib/metanorma/ieee_document/sections/ieee_sections.rb +0 -31
- data/lib/metanorma/ieee_document/sections.rb +0 -9
- data/lib/metanorma/ieee_document.rb +0 -11
- data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -31
- data/lib/metanorma/ietf_document/metadata/ietf_bibliographic_item.rb +0 -51
- data/lib/metanorma/ietf_document/metadata/ietf_editorial_group.rb +0 -17
- data/lib/metanorma/ietf_document/metadata/pi_settings.rb +0 -32
- data/lib/metanorma/ietf_document/metadata.rb +0 -16
- data/lib/metanorma/ietf_document/root.rb +0 -30
- data/lib/metanorma/ietf_document/sections/ietf_annex_section.rb +0 -26
- data/lib/metanorma/ietf_document/sections/ietf_clause_section.rb +0 -26
- data/lib/metanorma/ietf_document/sections/ietf_content_section.rb +0 -25
- data/lib/metanorma/ietf_document/sections/ietf_sections.rb +0 -35
- data/lib/metanorma/ietf_document/sections.rb +0 -12
- data/lib/metanorma/ietf_document.rb +0 -11
- data/lib/metanorma/iho_document/metadata/iho_bib_data_extension_type.rb +0 -23
- data/lib/metanorma/iho_document/metadata/iho_bibliographic_item.rb +0 -20
- data/lib/metanorma/iho_document/metadata/iho_editorial_group.rb +0 -19
- data/lib/metanorma/iho_document/metadata/iho_series.rb +0 -22
- data/lib/metanorma/iho_document/metadata/iho_sub_group.rb +0 -18
- data/lib/metanorma/iho_document/metadata.rb +0 -15
- data/lib/metanorma/iho_document/root.rb +0 -25
- data/lib/metanorma/iho_document.rb +0 -8
- data/lib/metanorma/iso_document/annotation_container.rb +0 -7
- data/lib/metanorma/iso_document/blocks/iso_admonition_block.rb +0 -27
- data/lib/metanorma/iso_document/blocks/iso_admonition_type.rb +0 -25
- data/lib/metanorma/iso_document/blocks.rb +0 -12
- data/lib/metanorma/iso_document/boilerplate.rb +0 -7
- data/lib/metanorma/iso_document/metadata/abstract_title.rb +0 -36
- data/lib/metanorma/iso_document/metadata/doc_identifier.rb +0 -26
- data/lib/metanorma/iso_document/metadata/doctype_element.rb +0 -20
- data/lib/metanorma/iso_document/metadata/ics.rb +0 -19
- data/lib/metanorma/iso_document/metadata/iec_document_category.rb +0 -23
- data/lib/metanorma/iso_document/metadata/iso_bib_data_extension_type.rb +0 -38
- data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +0 -103
- data/lib/metanorma/iso_document/metadata/iso_document_id.rb +0 -46
- data/lib/metanorma/iso_document/metadata/iso_document_stage_codes.rb +0 -26
- data/lib/metanorma/iso_document/metadata/iso_document_status.rb +0 -26
- data/lib/metanorma/iso_document/metadata/iso_document_substage_codes.rb +0 -26
- data/lib/metanorma/iso_document/metadata/iso_document_type.rb +0 -25
- data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +0 -61
- data/lib/metanorma/iso_document/metadata/iso_project_group.rb +0 -32
- data/lib/metanorma/iso_document/metadata/iso_sub_group.rb +0 -38
- data/lib/metanorma/iso_document/metadata/language_element.rb +0 -18
- data/lib/metanorma/iso_document/metadata/metanorma_extension.rb +0 -9
- data/lib/metanorma/iso_document/metadata/project_number.rb +0 -22
- data/lib/metanorma/iso_document/metadata/script_element.rb +0 -18
- data/lib/metanorma/iso_document/metadata/stage_element.rb +0 -26
- data/lib/metanorma/iso_document/metadata/stagename_element.rb +0 -18
- data/lib/metanorma/iso_document/metadata/structured_identifier.rb +0 -16
- data/lib/metanorma/iso_document/metadata/title_amd.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_amendment_prefix.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_collection.rb +0 -47
- data/lib/metanorma/iso_document/metadata/title_full.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_intro.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_main.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_part.rb +0 -12
- data/lib/metanorma/iso_document/metadata/title_part_prefix.rb +0 -12
- data/lib/metanorma/iso_document/metadata.rb +0 -44
- data/lib/metanorma/iso_document/root.rb +0 -26
- data/lib/metanorma/iso_document/sections/colophon.rb +0 -3
- data/lib/metanorma/iso_document/sections/iso_abstract_section.rb +0 -15
- data/lib/metanorma/iso_document/sections/iso_amendment_clause.rb +0 -24
- data/lib/metanorma/iso_document/sections/iso_annex_section.rb +0 -50
- data/lib/metanorma/iso_document/sections/iso_clause_section.rb +0 -49
- data/lib/metanorma/iso_document/sections/iso_foreword_section.rb +0 -33
- data/lib/metanorma/iso_document/sections/iso_preface.rb +0 -51
- data/lib/metanorma/iso_document/sections/iso_sections.rb +0 -51
- data/lib/metanorma/iso_document/sections/iso_terms_section.rb +0 -76
- data/lib/metanorma/iso_document/sections.rb +0 -17
- data/lib/metanorma/iso_document/terms/iso_term.rb +0 -71
- data/lib/metanorma/iso_document/terms/iso_term_collection.rb +0 -20
- data/lib/metanorma/iso_document/terms/term_definition.rb +0 -30
- data/lib/metanorma/iso_document/terms/term_designation.rb +0 -44
- data/lib/metanorma/iso_document/terms/term_domain_element.rb +0 -18
- data/lib/metanorma/iso_document/terms/term_example.rb +0 -40
- data/lib/metanorma/iso_document/terms/term_expression.rb +0 -10
- data/lib/metanorma/iso_document/terms/term_note.rb +0 -42
- data/lib/metanorma/iso_document/terms/term_origin.rb +0 -4
- data/lib/metanorma/iso_document/terms/term_source.rb +0 -21
- data/lib/metanorma/iso_document/terms/verbal_definition.rb +0 -42
- data/lib/metanorma/iso_document/terms.rb +0 -21
- data/lib/metanorma/iso_document.rb +0 -15
- data/lib/metanorma/itu_document/metadata/itu_bib_data_extension_type.rb +0 -26
- data/lib/metanorma/itu_document/metadata/itu_bibliographic_item.rb +0 -21
- data/lib/metanorma/itu_document/metadata/itu_series.rb +0 -22
- data/lib/metanorma/itu_document/metadata/itu_structured_identifier.rb +0 -23
- data/lib/metanorma/itu_document/metadata/meeting_date.rb +0 -18
- data/lib/metanorma/itu_document/metadata/meeting_element.rb +0 -18
- data/lib/metanorma/itu_document/metadata/study_period.rb +0 -18
- data/lib/metanorma/itu_document/metadata.rb +0 -18
- data/lib/metanorma/itu_document/root.rb +0 -25
- data/lib/metanorma/itu_document.rb +0 -8
- data/lib/metanorma/jis_document/metadata/jis_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/jis_document/metadata/jis_bibliographic_item.rb +0 -15
- data/lib/metanorma/jis_document/metadata.rb +0 -12
- data/lib/metanorma/jis_document/root.rb +0 -29
- data/lib/metanorma/jis_document/sections/jis_annex_section.rb +0 -20
- data/lib/metanorma/jis_document/sections.rb +0 -9
- data/lib/metanorma/jis_document.rb +0 -11
- data/lib/metanorma/m3d_document/metadata/m3d_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/m3d_document/metadata/m3d_bibliographic_item.rb +0 -15
- data/lib/metanorma/m3d_document/metadata.rb +0 -12
- data/lib/metanorma/m3d_document/root.rb +0 -29
- data/lib/metanorma/m3d_document.rb +0 -10
- data/lib/metanorma/mirror/default_registry.rb +0 -191
- data/lib/metanorma/mirror/handler_registry.rb +0 -60
- data/lib/metanorma/mirror/handler_result.rb +0 -37
- data/lib/metanorma/mirror/handlers/admonition.rb +0 -18
- data/lib/metanorma/mirror/handlers/example.rb +0 -21
- data/lib/metanorma/mirror/handlers/figure.rb +0 -53
- data/lib/metanorma/mirror/handlers/formula.rb +0 -35
- data/lib/metanorma/mirror/handlers/inline/catalog.rb +0 -52
- data/lib/metanorma/mirror/handlers/inline/rich_html_renderer.rb +0 -158
- data/lib/metanorma/mirror/handlers/inline/text_extractor.rb +0 -116
- data/lib/metanorma/mirror/handlers/inline.rb +0 -226
- data/lib/metanorma/mirror/handlers/list.rb +0 -110
- data/lib/metanorma/mirror/handlers/note.rb +0 -26
- data/lib/metanorma/mirror/handlers/paragraph.rb +0 -19
- data/lib/metanorma/mirror/handlers/quote.rb +0 -16
- data/lib/metanorma/mirror/handlers/review.rb +0 -19
- data/lib/metanorma/mirror/handlers/section.rb +0 -149
- data/lib/metanorma/mirror/handlers/sourcecode.rb +0 -27
- data/lib/metanorma/mirror/handlers/structural.rb +0 -68
- data/lib/metanorma/mirror/handlers/table.rb +0 -81
- data/lib/metanorma/mirror/handlers/term.rb +0 -100
- data/lib/metanorma/mirror/handlers.rb +0 -60
- data/lib/metanorma/mirror/id_strategy/positional.rb +0 -166
- data/lib/metanorma/mirror/id_strategy/preserve.rb +0 -12
- data/lib/metanorma/mirror/id_strategy.rb +0 -34
- data/lib/metanorma/mirror/math_util.rb +0 -53
- data/lib/metanorma/mirror/metadata.rb +0 -37
- data/lib/metanorma/mirror/model/container.rb +0 -47
- data/lib/metanorma/mirror/model/factory.rb +0 -52
- data/lib/metanorma/mirror/model/guide.rb +0 -26
- data/lib/metanorma/mirror/model/leaf.rb +0 -17
- data/lib/metanorma/mirror/model/mark.rb +0 -53
- data/lib/metanorma/mirror/model/node.rb +0 -47
- data/lib/metanorma/mirror/model/soft_break.rb +0 -33
- data/lib/metanorma/mirror/model/text.rb +0 -34
- data/lib/metanorma/mirror/model.rb +0 -16
- data/lib/metanorma/mirror/output/builder.rb +0 -39
- data/lib/metanorma/mirror/output/formats/base_format.rb +0 -90
- data/lib/metanorma/mirror/output/formats/inline_format.rb +0 -142
- data/lib/metanorma/mirror/output/formats.rb +0 -53
- data/lib/metanorma/mirror/output/pipeline.rb +0 -93
- data/lib/metanorma/mirror/output/pipeline_context.rb +0 -22
- data/lib/metanorma/mirror/output.rb +0 -12
- data/lib/metanorma/mirror/rewriter.rb +0 -123
- data/lib/metanorma/mirror/safe_attr.rb +0 -16
- data/lib/metanorma/mirror/serialization/json_serializer.rb +0 -25
- data/lib/metanorma/mirror/serialization/yaml_serializer.rb +0 -20
- data/lib/metanorma/mirror/serialization.rb +0 -10
- data/lib/metanorma/mirror/transformer.rb +0 -110
- data/lib/metanorma/mirror.rb +0 -31
- data/lib/metanorma/nist_document/metadata/nist_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/nist_document/metadata/nist_bibliographic_item.rb +0 -15
- data/lib/metanorma/nist_document/metadata.rb +0 -12
- data/lib/metanorma/nist_document/root.rb +0 -29
- data/lib/metanorma/nist_document/sections/errata.rb +0 -16
- data/lib/metanorma/nist_document/sections/errata_clause.rb +0 -20
- data/lib/metanorma/nist_document/sections/errata_row.rb +0 -22
- data/lib/metanorma/nist_document/sections/nist_preface.rb +0 -30
- data/lib/metanorma/nist_document/sections.rb +0 -12
- data/lib/metanorma/nist_document.rb +0 -11
- data/lib/metanorma/ogc_document/metadata/ogc_bib_data_extension_type.rb +0 -12
- data/lib/metanorma/ogc_document/metadata/ogc_bibliographic_item.rb +0 -19
- data/lib/metanorma/ogc_document/metadata.rb +0 -12
- data/lib/metanorma/ogc_document/root.rb +0 -25
- data/lib/metanorma/ogc_document.rb +0 -8
- data/lib/metanorma/plateau_document/metadata/plateau_bibliographic_item.rb +0 -13
- data/lib/metanorma/plateau_document/metadata.rb +0 -10
- data/lib/metanorma/plateau_document/root.rb +0 -29
- data/lib/metanorma/plateau_document.rb +0 -10
- data/lib/metanorma/registers/setup.rb +0 -166
- data/lib/metanorma/registers.rb +0 -7
- data/lib/metanorma/ribose_document/metadata/ribose_bib_data_extension_type.rb +0 -20
- data/lib/metanorma/ribose_document/metadata/ribose_bibliographic_item.rb +0 -18
- data/lib/metanorma/ribose_document/metadata.rb +0 -12
- data/lib/metanorma/ribose_document/root.rb +0 -26
- data/lib/metanorma/ribose_document.rb +0 -8
- data/lib/metanorma/standard_document/annotation_container.rb +0 -39
- data/lib/metanorma/standard_document/block_attributes.rb +0 -281
- data/lib/metanorma/standard_document/blocks/amend_block.rb +0 -50
- data/lib/metanorma/standard_document/blocks/amend_content_block.rb +0 -35
- data/lib/metanorma/standard_document/blocks/auto_number.rb +0 -20
- data/lib/metanorma/standard_document/blocks/block_source.rb +0 -22
- data/lib/metanorma/standard_document/blocks/change_type.rb +0 -21
- data/lib/metanorma/standard_document/blocks/element_name.rb +0 -22
- data/lib/metanorma/standard_document/blocks/form.rb +0 -38
- data/lib/metanorma/standard_document/blocks/image_map_area_type.rb +0 -24
- data/lib/metanorma/standard_document/blocks/image_map_area_type_type.rb +0 -21
- data/lib/metanorma/standard_document/blocks/image_map_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/image_map_coords.rb +0 -19
- data/lib/metanorma/standard_document/blocks/image_map_radius.rb +0 -19
- data/lib/metanorma/standard_document/blocks/multilingual_rendering_type.rb +0 -21
- data/lib/metanorma/standard_document/blocks/passthrough.rb +0 -3
- data/lib/metanorma/standard_document/blocks/requirement_model.rb +0 -20
- data/lib/metanorma/standard_document/blocks/source_origin_element.rb +0 -23
- data/lib/metanorma/standard_document/blocks/standard_admonition_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/standard_block.rb +0 -28
- data/lib/metanorma/standard_document/blocks/standard_block_no_notes.rb +0 -34
- data/lib/metanorma/standard_document/blocks/standard_example_block.rb +0 -30
- data/lib/metanorma/standard_document/blocks/standard_figure_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/standard_formula_block.rb +0 -30
- data/lib/metanorma/standard_document/blocks/standard_note_block.rb +0 -64
- data/lib/metanorma/standard_document/blocks/standard_paragraph_block.rb +0 -25
- data/lib/metanorma/standard_document/blocks/standard_quote_block.rb +0 -29
- data/lib/metanorma/standard_document/blocks/standard_sourcecode_block.rb +0 -32
- data/lib/metanorma/standard_document/blocks/standard_table_block.rb +0 -39
- data/lib/metanorma/standard_document/blocks/svg_map_block.rb +0 -23
- data/lib/metanorma/standard_document/blocks/svg_target_type.rb +0 -20
- data/lib/metanorma/standard_document/blocks/table_col.rb +0 -16
- data/lib/metanorma/standard_document/blocks/to_c.rb +0 -17
- data/lib/metanorma/standard_document/blocks.rb +0 -60
- data/lib/metanorma/standard_document/boilerplate.rb +0 -32
- data/lib/metanorma/standard_document/elements/add.rb +0 -3
- data/lib/metanorma/standard_document/elements/del.rb +0 -3
- data/lib/metanorma/standard_document/elements/form_input.rb +0 -27
- data/lib/metanorma/standard_document/elements/input.rb +0 -12
- data/lib/metanorma/standard_document/elements/input_type.rb +0 -27
- data/lib/metanorma/standard_document/elements/label.rb +0 -19
- data/lib/metanorma/standard_document/elements/option.rb +0 -27
- data/lib/metanorma/standard_document/elements/orientation_type.rb +0 -27
- data/lib/metanorma/standard_document/elements/select.rb +0 -32
- data/lib/metanorma/standard_document/elements/standard_page_break_element.rb +0 -22
- data/lib/metanorma/standard_document/elements/textarea.rb +0 -25
- data/lib/metanorma/standard_document/elements.rb +0 -20
- data/lib/metanorma/standard_document/lists/standard_definition.rb +0 -24
- data/lib/metanorma/standard_document/lists/standard_definition_list.rb +0 -30
- data/lib/metanorma/standard_document/lists/standard_definition_term.rb +0 -27
- data/lib/metanorma/standard_document/lists/standard_unordered_list.rb +0 -28
- data/lib/metanorma/standard_document/lists/unordered_checkable_list_item.rb +0 -26
- data/lib/metanorma/standard_document/lists.rb +0 -17
- data/lib/metanorma/standard_document/metadata/editorial_group_type.rb +0 -25
- data/lib/metanorma/standard_document/metadata/ics_type.rb +0 -26
- data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +0 -26
- data/lib/metanorma/standard_document/metadata/presentation_metadata.rb +0 -107
- data/lib/metanorma/standard_document/metadata/semantic_metadata.rb +0 -18
- data/lib/metanorma/standard_document/metadata/standard_bib_data.rb +0 -25
- data/lib/metanorma/standard_document/metadata/standard_bib_data_extension_type.rb +0 -37
- data/lib/metanorma/standard_document/metadata/structured_identifier_type.rb +0 -48
- data/lib/metanorma/standard_document/metadata/technical_committee_type.rb +0 -27
- data/lib/metanorma/standard_document/metadata/unitsml/amount_of_substance.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/base_quantity.rb +0 -34
- data/lib/metanorma/standard_document/metadata/unitsml/dimension.rb +0 -39
- data/lib/metanorma/standard_document/metadata/unitsml/dimension_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/electric_current.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/enumerated_root_unit.rb +0 -23
- data/lib/metanorma/standard_document/metadata/unitsml/length.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/luminous_intensity.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/mass.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/namespace.rb +0 -17
- data/lib/metanorma/standard_document/metadata/unitsml/plane_angle.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/prefix.rb +0 -30
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_name.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/prefix_symbol.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/quantity.rb +0 -28
- data/lib/metanorma/standard_document/metadata/unitsml/quantity_name.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/quantity_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/root_units.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/thermodynamic_temperature.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/time.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/unit.rb +0 -32
- data/lib/metanorma/standard_document/metadata/unitsml/unit_name.rb +0 -21
- data/lib/metanorma/standard_document/metadata/unitsml/unit_set.rb +0 -19
- data/lib/metanorma/standard_document/metadata/unitsml/unit_symbol.rb +0 -36
- data/lib/metanorma/standard_document/metadata/unitsml/unit_system.rb +0 -23
- data/lib/metanorma/standard_document/metadata/unitsml/unitsml_root.rb +0 -28
- data/lib/metanorma/standard_document/metadata/unitsml.rb +0 -39
- data/lib/metanorma/standard_document/metadata.rb +0 -23
- data/lib/metanorma/standard_document/namespace.rb +0 -11
- data/lib/metanorma/standard_document/refs/reference_to_term.rb +0 -26
- data/lib/metanorma/standard_document/refs/reference_to_termbase.rb +0 -27
- data/lib/metanorma/standard_document/refs/standoc_locality_stack.rb +0 -24
- data/lib/metanorma/standard_document/refs/standoc_reference_to_citation_element.rb +0 -27
- data/lib/metanorma/standard_document/refs/standoc_reference_to_id_element.rb +0 -36
- data/lib/metanorma/standard_document/refs/xref_case_type.rb +0 -27
- data/lib/metanorma/standard_document/refs/xref_connective_type.rb +0 -27
- data/lib/metanorma/standard_document/refs/xref_target_type.rb +0 -25
- data/lib/metanorma/standard_document/refs.rb +0 -18
- data/lib/metanorma/standard_document/root.rb +0 -10
- data/lib/metanorma/standard_document/root_attributes.rb +0 -78
- data/lib/metanorma/standard_document/sections/abstract.rb +0 -19
- data/lib/metanorma/standard_document/sections/acknowledgements.rb +0 -19
- data/lib/metanorma/standard_document/sections/annex_section.rb +0 -69
- data/lib/metanorma/standard_document/sections/bibliography_section.rb +0 -20
- data/lib/metanorma/standard_document/sections/boilerplate_type.rb +0 -32
- data/lib/metanorma/standard_document/sections/clause_hierarchical_section.rb +0 -32
- data/lib/metanorma/standard_document/sections/clause_section.rb +0 -91
- data/lib/metanorma/standard_document/sections/colophon.rb +0 -16
- data/lib/metanorma/standard_document/sections/definition_section.rb +0 -72
- data/lib/metanorma/standard_document/sections/floating_section_title.rb +0 -23
- data/lib/metanorma/standard_document/sections/floating_title.rb +0 -27
- data/lib/metanorma/standard_document/sections/foreword.rb +0 -19
- data/lib/metanorma/standard_document/sections/introduction.rb +0 -20
- data/lib/metanorma/standard_document/sections/misc_container.rb +0 -31
- data/lib/metanorma/standard_document/sections/normative_type.rb +0 -29
- data/lib/metanorma/standard_document/sections/preface.rb +0 -36
- data/lib/metanorma/standard_document/sections/sections.rb +0 -47
- data/lib/metanorma/standard_document/sections/standard_content_section.rb +0 -41
- data/lib/metanorma/standard_document/sections/standard_hierarchical_section.rb +0 -30
- data/lib/metanorma/standard_document/sections/standard_references_section.rb +0 -74
- data/lib/metanorma/standard_document/sections/standard_section.rb +0 -39
- data/lib/metanorma/standard_document/sections/terms_section.rb +0 -61
- data/lib/metanorma/standard_document/sections.rb +0 -34
- data/lib/metanorma/standard_document/standard_document_type.rb +0 -15
- data/lib/metanorma/standard_document/terms/abbreviation_type.rb +0 -27
- data/lib/metanorma/standard_document/terms/concept.rb +0 -42
- data/lib/metanorma/standard_document/terms/definition_collection.rb +0 -24
- data/lib/metanorma/standard_document/terms/designation.rb +0 -31
- data/lib/metanorma/standard_document/terms/expression_designation.rb +0 -38
- data/lib/metanorma/standard_document/terms/expression_type.rb +0 -27
- data/lib/metanorma/standard_document/terms/grammar_gender.rb +0 -27
- data/lib/metanorma/standard_document/terms/grammar_info.rb +0 -36
- data/lib/metanorma/standard_document/terms/graphical_symbol_designation.rb +0 -25
- data/lib/metanorma/standard_document/terms/letter_symbol_designation.rb +0 -27
- data/lib/metanorma/standard_document/terms/non_verbal_representation.rb +0 -33
- data/lib/metanorma/standard_document/terms/related_term.rb +0 -31
- data/lib/metanorma/standard_document/terms/related_term_type.rb +0 -28
- data/lib/metanorma/standard_document/terms/term.rb +0 -66
- data/lib/metanorma/standard_document/terms/term_collection.rb +0 -24
- data/lib/metanorma/standard_document/terms/term_definition.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_expression.rb +0 -20
- data/lib/metanorma/standard_document/terms/term_name_element.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_source.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_source_status.rb +0 -29
- data/lib/metanorma/standard_document/terms/term_source_type.rb +0 -21
- data/lib/metanorma/standard_document/terms/verbal_expression.rb +0 -35
- data/lib/metanorma/standard_document/terms.rb +0 -33
- data/lib/metanorma/standard_document.rb +0 -27
- data/lib/metanorma/un_document/blocks/un_admonition_block.rb +0 -86
- data/lib/metanorma/un_document/blocks.rb +0 -9
- data/lib/metanorma/un_document/metadata/un_bib_data_extension_type.rb +0 -10
- data/lib/metanorma/un_document/metadata/un_bibliographic_item.rb +0 -15
- data/lib/metanorma/un_document/metadata.rb +0 -12
- data/lib/metanorma/un_document/root.rb +0 -37
- data/lib/metanorma/un_document/sections/un_abstract_section.rb +0 -48
- data/lib/metanorma/un_document/sections/un_preface.rb +0 -40
- data/lib/metanorma/un_document/sections/un_sections.rb +0 -24
- data/lib/metanorma/un_document/sections.rb +0 -11
- data/lib/metanorma/un_document/un_text_element.rb +0 -116
- data/lib/metanorma/un_document.rb +0 -13
|
@@ -3,75 +3,266 @@
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Html
|
|
5
5
|
class StandardRenderer < BaseRenderer
|
|
6
|
-
|
|
6
|
+
include Renderers::SemanticRenderer
|
|
7
|
+
|
|
8
|
+
register_render "Metanorma::Standoc::Document::Root",
|
|
7
9
|
:render_standard_document
|
|
8
|
-
register_render Metanorma::
|
|
9
|
-
register_render Metanorma::
|
|
10
|
+
register_render "Metanorma::Standoc::Document::Terms::Term", :render_term
|
|
11
|
+
register_render "Metanorma::Standoc::Document::Terms::TermSource",
|
|
12
|
+
:render_term_source
|
|
13
|
+
register_render "Metanorma::Standoc::Document::Terms::FmtDefinitionSemx",
|
|
14
|
+
:render_fmt_definition_semx
|
|
15
|
+
register_render "Metanorma::Standoc::Document::Sections::TermsSection",
|
|
10
16
|
:render_terms_section
|
|
11
|
-
register_render Metanorma::
|
|
17
|
+
register_render "Metanorma::Document::Components::Blocks::RequirementModel",
|
|
18
|
+
:render_requirement
|
|
19
|
+
register_render "Metanorma::Document::Components::Blocks::RecommendationModel",
|
|
20
|
+
:render_requirement
|
|
21
|
+
register_render "Metanorma::Document::Components::Blocks::PermissionModel",
|
|
22
|
+
:render_requirement
|
|
23
|
+
register_render "Metanorma::Document::Components::Blocks::FmtProvision",
|
|
24
|
+
:render_reqt_component
|
|
25
|
+
register_render "Metanorma::Standoc::Document::Sections::StandardReferencesSection",
|
|
12
26
|
:render_references_section
|
|
13
|
-
register_render Metanorma::
|
|
27
|
+
register_render "Metanorma::Standoc::Document::Sections::BibliographySection",
|
|
14
28
|
:render_bibliography
|
|
15
|
-
register_render Metanorma::
|
|
29
|
+
register_render "Metanorma::Standoc::Document::Sections::ClauseSection",
|
|
16
30
|
:render_clause_section
|
|
17
|
-
register_render Metanorma::
|
|
31
|
+
register_render "Metanorma::Standoc::Document::Sections::AnnexSection",
|
|
18
32
|
:render_annex_section
|
|
19
|
-
register_render Metanorma::
|
|
33
|
+
register_render "Metanorma::Standoc::Document::Sections::StandardSection",
|
|
20
34
|
:render_standard_section
|
|
21
|
-
register_render Metanorma::
|
|
35
|
+
register_render "Metanorma::Standoc::Document::Sections::Abstract",
|
|
22
36
|
:render_abstract_section
|
|
23
|
-
register_render Metanorma::
|
|
37
|
+
register_render "Metanorma::Standoc::Document::Sections::Foreword",
|
|
24
38
|
:render_foreword_section
|
|
25
|
-
register_render Metanorma::
|
|
39
|
+
register_render "Metanorma::Standoc::Document::Sections::Introduction",
|
|
26
40
|
:render_introduction_section
|
|
27
|
-
register_render Metanorma::
|
|
41
|
+
register_render "Metanorma::Standoc::Document::Sections::Preface",
|
|
42
|
+
:render_preface
|
|
43
|
+
register_render "Metanorma::Standoc::Document::Sections::Sections",
|
|
44
|
+
:render_standard_section
|
|
45
|
+
register_render "Metanorma::Standoc::Document::Sections::ContentSection",
|
|
46
|
+
:render_standard_section
|
|
47
|
+
register_render "Metanorma::Standoc::Document::Sections::DefinitionSection",
|
|
48
|
+
:render_standard_section
|
|
49
|
+
register_render "Metanorma::Standoc::Document::Sections::FloatingTitle",
|
|
28
50
|
:render_floating_title
|
|
29
|
-
register_render Metanorma::
|
|
51
|
+
register_render "Metanorma::Standoc::Document::Blocks::AmendBlock",
|
|
30
52
|
:render_amend_block
|
|
53
|
+
register_render "Metanorma::Standoc::Document::Sections::Colophon",
|
|
54
|
+
:render_colophon
|
|
55
|
+
register_render "Metanorma::Standoc::Document::Blocks::ToC",
|
|
56
|
+
:render_toc
|
|
31
57
|
|
|
32
58
|
def render_standard_document(doc, **_opts)
|
|
33
59
|
cover = render_coverpage(doc)
|
|
60
|
+
cover += render_boilerplate(doc) if doc.respond_to?(:boilerplate) &&
|
|
61
|
+
doc.boilerplate
|
|
34
62
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
63
|
+
cover + render_liquid("_main_content.html.liquid",
|
|
64
|
+
{ "content" => main_sections_html(doc) })
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def main_sections_html(doc)
|
|
68
|
+
parts = []
|
|
69
|
+
parts << (render(doc.preface) || "") if doc.preface
|
|
70
|
+
parts << (render_doc_title(doc) || "")
|
|
71
|
+
parts << (render(doc.sections) || "") if doc.sections
|
|
72
|
+
doc.annex&.each { |annex| parts << (render(annex) || "") }
|
|
73
|
+
parts << (render(doc.bibliography) || "") if doc.bibliography
|
|
74
|
+
parts << (render(doc.colophon) || "") if doc.respond_to?(:colophon) &&
|
|
75
|
+
doc.colophon
|
|
41
76
|
|
|
42
77
|
unless @index_term_collector.empty?
|
|
43
78
|
index_component = Component::IndexSection.new(self)
|
|
44
|
-
|
|
79
|
+
parts << (index_component.render(@index_term_collector) || "")
|
|
45
80
|
end
|
|
46
81
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"content" => content_parts.join,
|
|
52
|
-
})
|
|
82
|
+
parts << (render(doc.indexsect) || "") if doc.indexsect
|
|
83
|
+
parts << (render_semantic_annexes(doc) || "")
|
|
84
|
+
parts << (render_footnotes_section || "")
|
|
85
|
+
parts.join
|
|
53
86
|
end
|
|
54
87
|
|
|
55
88
|
def render_coverpage(doc)
|
|
56
89
|
bibdata = doc.bibdata
|
|
57
90
|
return "" unless bibdata
|
|
58
91
|
|
|
59
|
-
cover_id =
|
|
60
|
-
bibdata.doc_identifier&.each do |di|
|
|
61
|
-
next unless safe_attr(di, :type) == "iso-reference"
|
|
62
|
-
|
|
63
|
-
id = extract_text_value(di)
|
|
64
|
-
next if id.to_s.empty?
|
|
65
|
-
|
|
66
|
-
cover_id = id
|
|
67
|
-
break
|
|
68
|
-
end
|
|
92
|
+
cover_id = extract_primary_doc_id
|
|
69
93
|
|
|
70
94
|
title_text = extract_display_title(bibdata)
|
|
71
95
|
|
|
72
96
|
render_liquid("_cover.html.liquid", {
|
|
73
97
|
"doc_id" => cover_id,
|
|
74
98
|
"title" => title_text,
|
|
99
|
+
"stage_html" => cover_stage_html(bibdata),
|
|
100
|
+
"tc_html" => cover_tc_html(bibdata),
|
|
101
|
+
"dates_html" => cover_dates_html(bibdata),
|
|
102
|
+
})
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def cover_tc_html(bibdata)
|
|
106
|
+
name = cover_tc_name(bibdata)
|
|
107
|
+
return nil unless name
|
|
108
|
+
|
|
109
|
+
render_liquid("_element.html.liquid", "tag" => "div",
|
|
110
|
+
"extra_attrs" => %( class="coverpage-tc-name"),
|
|
111
|
+
"content" => %(<span>#{escape_html(name)}</span>))
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# The native covers open with type and maturity bands ("IHO
|
|
115
|
+
# Regulation", "Published 2017-06"); derive both from bibdata.
|
|
116
|
+
# The committee subdivision name renders as the cover tc-name
|
|
117
|
+
# ("hssc"); value-only extraction — the contributor graph is
|
|
118
|
+
# self-referential under to_s/inspect.
|
|
119
|
+
def cover_tc_name(bibdata)
|
|
120
|
+
if bibdata.respond_to?(:subdivision_text_for)
|
|
121
|
+
name = begin
|
|
122
|
+
bibdata.subdivision_text_for("committee", :name)
|
|
123
|
+
rescue StandardError
|
|
124
|
+
nil
|
|
125
|
+
end
|
|
126
|
+
return name if name.is_a?(String) && !name.empty?
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
Array(safe_attr(bibdata, :contributor)).each do |c|
|
|
130
|
+
roles = Array(safe_attr(c, :role))
|
|
131
|
+
author = roles.any? { |r| r.is_a?(String) ? r == "author" : safe_attr(r, :type) == "author" }
|
|
132
|
+
next unless author
|
|
133
|
+
|
|
134
|
+
org = safe_attr(c, :organization)
|
|
135
|
+
Array(safe_attr(org, :subdivision)).each do |sub|
|
|
136
|
+
name = safe_attr(sub, :name)
|
|
137
|
+
name = cover_date_text(name) unless name.is_a?(String)
|
|
138
|
+
return name if name && !name.empty?
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
nil
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def cover_stage_html(bibdata)
|
|
145
|
+
bands = []
|
|
146
|
+
if (doctype = cover_doctype_label(bibdata))
|
|
147
|
+
bands << %(<span class="coverpage-stage" id="#{escape_html(cover_doctype_id(bibdata))}">#{escape_html(doctype)}</span>)
|
|
148
|
+
end
|
|
149
|
+
status = safe_attr(bibdata, :status)
|
|
150
|
+
# status.stage is an Array of mixed-content StageElement;
|
|
151
|
+
# extract the text value (stringifying can hit self-reference).
|
|
152
|
+
stage_el = Array(safe_attr(status, :stage)).first
|
|
153
|
+
stage = if stage_el.nil?
|
|
154
|
+
nil
|
|
155
|
+
elsif stage_el.is_a?(String)
|
|
156
|
+
stage_el
|
|
157
|
+
elsif stage_el.respond_to?(:value)
|
|
158
|
+
Array(stage_el.value).join.strip
|
|
159
|
+
end
|
|
160
|
+
stage = nil if stage.respond_to?(:empty?) && stage.empty?
|
|
161
|
+
if stage
|
|
162
|
+
label = { "in-force" => "Published" }.fetch(stage, stage.capitalize)
|
|
163
|
+
pub = Array(safe_attr(bibdata, :date)).find do |d|
|
|
164
|
+
safe_attr(d, :type) == "published"
|
|
165
|
+
end
|
|
166
|
+
# The native maturity band reads <on> only; when absent it
|
|
167
|
+
# prints the literal placeholder XXX.
|
|
168
|
+
on = cover_date_text(pub && safe_attr(pub, :on))
|
|
169
|
+
text = on ? "#{label} #{on}" : "#{label} XXX"
|
|
170
|
+
bands << %(<p><span class="coverpage-maturity" id="#{escape_html(stage)}">#{escape_html(text)}</span></p>)
|
|
171
|
+
end
|
|
172
|
+
return nil if bands.empty?
|
|
173
|
+
|
|
174
|
+
render_liquid("_element.html.liquid", "tag" => "div",
|
|
175
|
+
"extra_attrs" => %( class="coverpage-stage-block"),
|
|
176
|
+
"content" => bands.join)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def cover_doctype_label(bibdata)
|
|
180
|
+
dt = cover_doctype_value(bibdata)
|
|
181
|
+
return nil unless dt
|
|
182
|
+
|
|
183
|
+
pretty = cover_date_text(dt) || dt.to_s
|
|
184
|
+
pretty = pretty.split("-").map(&:capitalize).join(" ")
|
|
185
|
+
prefix = cover_publisher_prefix(bibdata)
|
|
186
|
+
prefix ? "#{prefix} #{pretty}" : pretty
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def cover_doctype_id(bibdata)
|
|
190
|
+
cover_date_text(cover_doctype_value(bibdata))&.downcase
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# doctype lives either on the bibdata or its flavor extension.
|
|
194
|
+
def cover_doctype_value(bibdata)
|
|
195
|
+
Array(safe_attr(bibdata, :doctype)).first ||
|
|
196
|
+
Array(safe_attr(safe_attr(bibdata, :ext), :doctype)).first
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# bibdata dates are Relaton value objects; pull the text out.
|
|
200
|
+
def cover_date_text(value)
|
|
201
|
+
return nil if value.nil?
|
|
202
|
+
return value if value.is_a?(String)
|
|
203
|
+
return Array(value.value).join.strip if value.respond_to?(:value)
|
|
204
|
+
|
|
205
|
+
# Relaton DateTime maps <on>YYYY-MM</on> to content.
|
|
206
|
+
return value.content if value.respond_to?(:content) && value.content.is_a?(String)
|
|
207
|
+
return value.text if value.respond_to?(:text) && value.text.is_a?(String)
|
|
208
|
+
|
|
209
|
+
nil
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Publisher abbreviation (preferred) or name from the bibdata
|
|
213
|
+
# contributor graph, value-only extraction: to_s/inspect on lutaml
|
|
214
|
+
# collections recurses into self-referential model graphs.
|
|
215
|
+
|
|
216
|
+
# The committee subdivision name renders as the cover tc-name
|
|
217
|
+
# ("hssc"); value-only extraction — the contributor graph is
|
|
218
|
+
# self-referential under to_s/inspect.
|
|
219
|
+
|
|
220
|
+
# doctype lives either on the bibdata or its flavor extension.
|
|
221
|
+
|
|
222
|
+
# bibdata dates are Relaton value objects; pull the text out.
|
|
223
|
+
|
|
224
|
+
# The contributor graph is self-referential under lutaml-model;
|
|
225
|
+
# walking it for the publisher organization loops forever. The
|
|
226
|
+
# flavor theme already carries the publisher name.
|
|
227
|
+
def cover_publisher_prefix(_bibdata)
|
|
228
|
+
name = theme.respond_to?(:publisher_name) ? theme.publisher_name : nil
|
|
229
|
+
name.is_a?(String) && !name.empty? ? name : nil
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Document dates (issue/implementation/...) as a cover band.
|
|
233
|
+
def cover_dates_html(bibdata)
|
|
234
|
+
items = Array(safe_attr(bibdata, :date)).filter_map do |d|
|
|
235
|
+
type = cover_date_text(safe_attr(d, :type)) || safe_attr(d, :type)
|
|
236
|
+
on = cover_date_text(safe_attr(d, :on)) || cover_date_text(safe_attr(d, :from))
|
|
237
|
+
next unless type && on
|
|
238
|
+
|
|
239
|
+
%(<span class="coverpage-date date-#{escape_html(type)}">#{escape_html(type.capitalize)}: #{escape_html(on)}</span>)
|
|
240
|
+
end
|
|
241
|
+
return nil if items.empty?
|
|
242
|
+
|
|
243
|
+
render_liquid("_element.html.liquid", "tag" => "div",
|
|
244
|
+
"extra_attrs" => %( class="coverpage-dates"),
|
|
245
|
+
"content" => items.join)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# The document <boilerplate> front-matter block (copyright,
|
|
249
|
+
# licence, legal and feedback statements): part of the native
|
|
250
|
+
# cover matter, rendered right after the title cover.
|
|
251
|
+
def render_boilerplate(doc)
|
|
252
|
+
boilerplate = doc.boilerplate
|
|
253
|
+
parts = []
|
|
254
|
+
%i[copyright_statement license_statement legal_statement
|
|
255
|
+
feedback_statement clause paragraphs quote_blocks].each do |grouping|
|
|
256
|
+
Array(boilerplate.public_send(grouping)).each do |child|
|
|
257
|
+
parts << (render(child, level: 1) || "")
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
render_liquid("_element.html.liquid", {
|
|
261
|
+
"tag" => "div",
|
|
262
|
+
"extra_attrs" => element_attrs(
|
|
263
|
+
class: "document-boilerplate",
|
|
264
|
+
),
|
|
265
|
+
"content" => parts.join,
|
|
75
266
|
})
|
|
76
267
|
end
|
|
77
268
|
|
|
@@ -97,10 +288,19 @@ module Metanorma
|
|
|
97
288
|
else
|
|
98
289
|
render_standard_title(section, level) || ""
|
|
99
290
|
end
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
291
|
+
if section.respond_to?(:element_order) && Array(section.element_order).any?
|
|
292
|
+
# Document order (element_order) preserves interleaved blocks —
|
|
293
|
+
# paragraphs between figures, notes between lists — which the
|
|
294
|
+
# attribute-grouping path below cannot express.
|
|
295
|
+
parts << (render_ordered_content(section, level) || "")
|
|
296
|
+
else
|
|
297
|
+
parts << (render_standard_section_blocks(section, level) || "")
|
|
298
|
+
parts << (render_subsections(section, level) || "") if with_subsections
|
|
299
|
+
if with_terms
|
|
300
|
+
section.terms&.each { |term| parts << (render_term(term, level: level + 1) || "") }
|
|
301
|
+
end
|
|
302
|
+
parts << (render_section_groupings(section, level,
|
|
303
|
+
skip_terms: with_terms) || "")
|
|
104
304
|
end
|
|
105
305
|
render_liquid("_element.html.liquid", {
|
|
106
306
|
"tag" => "div",
|
|
@@ -109,6 +309,22 @@ module Metanorma
|
|
|
109
309
|
})
|
|
110
310
|
end
|
|
111
311
|
|
|
312
|
+
# Clause-embedded terms/definitions/references groupings are not
|
|
313
|
+
# `clause` children, so render_subsections skips them and their
|
|
314
|
+
# content would be lost. Render each grouping's children through
|
|
315
|
+
# the normal dispatch (DefinitionSection, ReferenceSection, Term).
|
|
316
|
+
def render_section_groupings(section, level, skip_terms: false)
|
|
317
|
+
parts = []
|
|
318
|
+
%i[terms definitions references].each do |grouping|
|
|
319
|
+
next if skip_terms && grouping == :terms
|
|
320
|
+
|
|
321
|
+
Array(safe_attr(section, grouping)).each do |child|
|
|
322
|
+
parts << (render(child, level: level + 1) || "")
|
|
323
|
+
end
|
|
324
|
+
end
|
|
325
|
+
parts.join
|
|
326
|
+
end
|
|
327
|
+
|
|
112
328
|
def render_clause_section(section, level: 1, **)
|
|
113
329
|
render_section(section, level: level, with_subsections: true)
|
|
114
330
|
end
|
|
@@ -121,6 +337,143 @@ module Metanorma
|
|
|
121
337
|
render_section(section, level: level)
|
|
122
338
|
end
|
|
123
339
|
|
|
340
|
+
# Requirement / recommendation / permission blocks: the requirements
|
|
341
|
+
# table — label row, then one row per populated component
|
|
342
|
+
# (subject, statement, specification, etc.). Component children
|
|
343
|
+
# (p/ol/ul/...) render through the regular dispatch.
|
|
344
|
+
REQ_COMPONENTS = {
|
|
345
|
+
description: "Description",
|
|
346
|
+
specification: "Statement",
|
|
347
|
+
measurement_target: "Measurement target",
|
|
348
|
+
verification: "Verification",
|
|
349
|
+
inherit: "Inheritance",
|
|
350
|
+
import: "Imported",
|
|
351
|
+
}.freeze
|
|
352
|
+
|
|
353
|
+
def render_requirement(req, **_opts)
|
|
354
|
+
parts = []
|
|
355
|
+
label = req.respond_to?(:fmt_name) && req.fmt_name ? render(req.fmt_name) : reqt_label(req)
|
|
356
|
+
parts << %(<div class="reqt"><p class="reqt-label">#{escape_html(label.to_s)}</p>)
|
|
357
|
+
|
|
358
|
+
if req.respond_to?(:fmt_provision) && req.fmt_provision
|
|
359
|
+
parts << requirement_fmt_provision_html(req)
|
|
360
|
+
else
|
|
361
|
+
parts << requirement_component_rows(req)
|
|
362
|
+
parts << requirement_classification_row(req)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
parts << %(</div>)
|
|
366
|
+
parts.join
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# Presentation-layer formatted provision: the requirement's own
|
|
370
|
+
# rendered table — when present it carries the full content.
|
|
371
|
+
def requirement_fmt_provision_html(req)
|
|
372
|
+
provision = render(req.fmt_provision) || ""
|
|
373
|
+
|
|
374
|
+
# Nested requirements (tests inside conformance classes) are
|
|
375
|
+
# not part of the formatted table — render them after it.
|
|
376
|
+
nested = %i[requirement recommendation permission].flat_map do |attr|
|
|
377
|
+
next [] unless req.respond_to?(attr)
|
|
378
|
+
|
|
379
|
+
Array(req.send(attr)).map { |child| render(child) || "" }
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
"#{provision}#{nested.join}"
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def requirement_component_rows(req)
|
|
386
|
+
REQ_COMPONENTS.filter_map do |attr, row_label|
|
|
387
|
+
value = req.respond_to?(attr) ? req.send(attr) : nil
|
|
388
|
+
next if value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
|
389
|
+
|
|
390
|
+
cells = Array(value).filter_map { |component| render_reqt_component(component) }.join
|
|
391
|
+
next if cells.empty?
|
|
392
|
+
|
|
393
|
+
%(<div class="reqt-row"><span class="reqt-key">#{row_label}:</span> #{cells}</div>)
|
|
394
|
+
end.join
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def requirement_classification_row(req)
|
|
398
|
+
return "" unless req.respond_to?(:classification) && req.classification&.any?
|
|
399
|
+
|
|
400
|
+
cls = req.classification.filter_map do |c|
|
|
401
|
+
next unless c.respond_to?(:value)
|
|
402
|
+
|
|
403
|
+
"#{c.tag if c.respond_to?(:tag)} #{c.value}".strip
|
|
404
|
+
end.reject(&:empty?).join("; ")
|
|
405
|
+
return "" if cls.empty?
|
|
406
|
+
|
|
407
|
+
%(<div class="reqt-row"><span class="reqt-key">Classification:</span> #{escape_html(cls)}</div>)
|
|
408
|
+
end
|
|
409
|
+
|
|
410
|
+
# Requirement labels come from mn-requirements' i18n vocabulary
|
|
411
|
+
# (the same strings the native isodoc pipeline renders), selected
|
|
412
|
+
# by the requirement's type attribute.
|
|
413
|
+
def reqt_labels
|
|
414
|
+
@reqt_labels ||= begin
|
|
415
|
+
require "isodoc-i18n"
|
|
416
|
+
gem_path = Gem.loaded_specs["mn-requirements"]&.full_gem_path
|
|
417
|
+
gem_path && require(File.join(gem_path, "lib/isodoc/i18n"))
|
|
418
|
+
i18n = IsoDoc::MnRequirementsI18n.new(document_language, nil)
|
|
419
|
+
req = Hash(i18n.get["requirements"])
|
|
420
|
+
# vocabulary nests under default: and modspec: — merge them
|
|
421
|
+
Hash(req["default"]).merge(Hash(req["modspec"]))
|
|
422
|
+
rescue StandardError
|
|
423
|
+
{}
|
|
424
|
+
end
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
def document_language
|
|
428
|
+
lang = respond_to?(:language) ? language : nil
|
|
429
|
+
lang.to_s.empty? ? "en" : lang.to_s
|
|
430
|
+
rescue StandardError
|
|
431
|
+
"en"
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
def reqt_label(req)
|
|
435
|
+
type = req.respond_to?(:type) ? req.type.to_s : ""
|
|
436
|
+
base = reqt_labels[type] ||
|
|
437
|
+
reqt_labels[req.class.name.split("::").last.to_s.delete_suffix("Model").downcase] ||
|
|
438
|
+
req.class.name.split("::").last.to_s.delete_suffix("Model").capitalize
|
|
439
|
+
ident = req.identifier.to_s if req.respond_to?(:identifier)
|
|
440
|
+
ident && ident.empty? ? base : "#{base} #{ident}"
|
|
441
|
+
end
|
|
442
|
+
|
|
443
|
+
def render_reqt_component(component, **_opts)
|
|
444
|
+
return "" if component.nil? || component.is_a?(String)
|
|
445
|
+
|
|
446
|
+
component.class.attributes.each_key.filter_map do |attr|
|
|
447
|
+
value = begin
|
|
448
|
+
component.send(attr)
|
|
449
|
+
rescue StandardError
|
|
450
|
+
next
|
|
451
|
+
end
|
|
452
|
+
if value.is_a?(Array)
|
|
453
|
+
value.map { |v| v.is_a?(String) ? v : render(v) }.join
|
|
454
|
+
elsif !value.nil? && !value.is_a?(String)
|
|
455
|
+
render(value)
|
|
456
|
+
end
|
|
457
|
+
end.join
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
# fmt-xref-label: the cross-reference label text ("Requirement
|
|
461
|
+
# A.14-1", "Clause 3") carried ahead of blocks in mixed content.
|
|
462
|
+
def render_fmt_xref_label(element, **_opts)
|
|
463
|
+
parts = []
|
|
464
|
+
if element.respond_to?(:text) && element.text
|
|
465
|
+
parts << Array(element.text).join
|
|
466
|
+
end
|
|
467
|
+
if element.respond_to?(:semx)
|
|
468
|
+
Array(element.semx).each { |s| parts << render(s) }
|
|
469
|
+
end
|
|
470
|
+
if element.respond_to?(:span)
|
|
471
|
+
Array(element.span).each { |s| parts << render(s) }
|
|
472
|
+
end
|
|
473
|
+
joined = parts.join
|
|
474
|
+
joined.empty? ? "" : %(<span class="fmt-xref-label">#{joined}</span>)
|
|
475
|
+
end
|
|
476
|
+
|
|
124
477
|
def render_terms_section(section, level: 1, **)
|
|
125
478
|
render_section(section, level: level, with_terms: true)
|
|
126
479
|
end
|
|
@@ -148,12 +501,86 @@ module Metanorma
|
|
|
148
501
|
})
|
|
149
502
|
end
|
|
150
503
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
504
|
+
# Amend block (machine-readable change): the description paragraphs
|
|
505
|
+
# render bare, the new content blocks render inside a single
|
|
506
|
+
# Quote AmendNewcontent wrapper — matching native isodoc output.
|
|
507
|
+
def render_amend_block(amend, **opts)
|
|
508
|
+
parts = Array(safe_attr(amend, :description)).map do |desc|
|
|
509
|
+
render_amend_content(desc, **opts)
|
|
510
|
+
end
|
|
511
|
+
new_contents = Array(safe_attr(amend, :new_content))
|
|
512
|
+
if new_contents.any?
|
|
513
|
+
inner = new_contents.map { |nc| render_amend_content(nc, **opts) }.join
|
|
514
|
+
attrs = element_attrs(id: safe_attr(amend, :id),
|
|
515
|
+
class: "Quote AmendNewcontent")
|
|
516
|
+
parts << render_liquid("_element.html.liquid", {
|
|
517
|
+
"tag" => "div",
|
|
518
|
+
"extra_attrs" => attrs,
|
|
519
|
+
"content" => inner,
|
|
520
|
+
})
|
|
521
|
+
end
|
|
522
|
+
parts.join
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
def render_amend_content(content, **opts)
|
|
526
|
+
parts = []
|
|
527
|
+
%i[paragraphs note ol ul dl figure clause].each do |attr|
|
|
528
|
+
Array(safe_attr(content, attr)).each do |child|
|
|
529
|
+
parts << (render_amend_child(child, **opts) || "")
|
|
530
|
+
end
|
|
531
|
+
end
|
|
532
|
+
parts.join
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
def render_amend_child(child, **)
|
|
536
|
+
if child.is_a?(Metanorma::Standoc::Document::Sections::ClauseSection)
|
|
537
|
+
render_amend_clause(child, **)
|
|
538
|
+
else
|
|
539
|
+
render(child, **)
|
|
540
|
+
end
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
# An annex introduced by an amendment carries its identity in
|
|
544
|
+
# number/obligation attributes rather than a formatted title:
|
|
545
|
+
# native isodoc renders the Annex label, the obligation and the
|
|
546
|
+
# title as one heading paragraph.
|
|
547
|
+
def render_amend_clause(clause, level: 1, **)
|
|
548
|
+
return render(clause, level: level, **) unless safe_attr(clause, :type) == "annex"
|
|
549
|
+
|
|
550
|
+
heading = +""
|
|
551
|
+
number = safe_attr(clause, :number)
|
|
552
|
+
heading << "<b>Annex #{escape_html(number)}</b><br />" if number
|
|
553
|
+
obligation = safe_attr(clause, :obligation)
|
|
554
|
+
if obligation
|
|
555
|
+
heading << %(<span class="obligation">(#{escape_html(obligation)})</span><br />)
|
|
556
|
+
end
|
|
557
|
+
title = safe_attr(clause, :fmt_title) || safe_attr(clause, :title)
|
|
558
|
+
heading << render_mixed_inline(title).to_s if title
|
|
559
|
+
|
|
560
|
+
body = Array(clause.blocks).filter_map do |node|
|
|
561
|
+
next if is_title_element?(node, clause)
|
|
562
|
+
|
|
563
|
+
render(node, level: level + 1)
|
|
564
|
+
end.join
|
|
565
|
+
attrs = element_attrs(id: safe_attr(clause, :id))
|
|
154
566
|
render_liquid("_element.html.liquid", {
|
|
155
567
|
"tag" => "div",
|
|
156
568
|
"extra_attrs" => attrs,
|
|
569
|
+
"content" => %(<p class="h1">#{heading}</p>#{body}),
|
|
570
|
+
})
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
# Authored table-of-contents blocks (clause type="toc"): a list of
|
|
574
|
+
# cross-references rendered as a toc div, mirroring the native
|
|
575
|
+
# isodoc layout.
|
|
576
|
+
def render_toc(toc, **_opts)
|
|
577
|
+
list = safe_attr(toc, :list)
|
|
578
|
+
content = Array(list).filter_map do |ul|
|
|
579
|
+
render_unordered_list(ul)
|
|
580
|
+
end.join
|
|
581
|
+
render_liquid("_element.html.liquid", {
|
|
582
|
+
"tag" => "div",
|
|
583
|
+
"extra_attrs" => element_attrs(class: "toc"),
|
|
157
584
|
"content" => content,
|
|
158
585
|
})
|
|
159
586
|
end
|
|
@@ -178,6 +605,11 @@ module Metanorma
|
|
|
178
605
|
"admitted")
|
|
179
606
|
parts << render_term_designations(term, :fmt_deprecates, :deprecates,
|
|
180
607
|
"deprecated")
|
|
608
|
+
# IEEE-style metadata definition list (figdl), rendered before the
|
|
609
|
+
# definition like the native term entry.
|
|
610
|
+
Array(safe_attr(term, :dl)).each do |list|
|
|
611
|
+
parts << (render_definition_list(list) || "")
|
|
612
|
+
end
|
|
181
613
|
parts << (render_term_domain(term, fmt_definition) || "")
|
|
182
614
|
parts << render_term_definitions(term, fmt_definition)
|
|
183
615
|
parts << render_term_note_parts(term)
|
|
@@ -276,6 +708,30 @@ module Metanorma
|
|
|
276
708
|
parts.join
|
|
277
709
|
end
|
|
278
710
|
|
|
711
|
+
# The <semx> wrapper inside <fmt-definition> carries the definition's
|
|
712
|
+
# block content one level down (standoc FmtDefinitionSemx); render
|
|
713
|
+
# its children in document order.
|
|
714
|
+
def render_fmt_definition_semx(semx, **_opts)
|
|
715
|
+
parts = []
|
|
716
|
+
walk_ordered(semx) do |type, obj|
|
|
717
|
+
next unless type == :element
|
|
718
|
+
|
|
719
|
+
parts << case obj
|
|
720
|
+
when Metanorma::Document::Components::Paragraphs::ParagraphBlock
|
|
721
|
+
render_paragraph(obj)
|
|
722
|
+
when Metanorma::Standoc::Document::Terms::TermNote
|
|
723
|
+
render_term_note(obj)
|
|
724
|
+
when Metanorma::Document::Components::Lists::DefinitionList
|
|
725
|
+
render_definition_list(obj)
|
|
726
|
+
when Metanorma::Document::Components::Lists::OrderedList
|
|
727
|
+
render_ordered_list(obj)
|
|
728
|
+
when Metanorma::Document::Components::Lists::UnorderedList
|
|
729
|
+
render_unordered_list(obj)
|
|
730
|
+
end
|
|
731
|
+
end
|
|
732
|
+
parts.compact.join
|
|
733
|
+
end
|
|
734
|
+
|
|
279
735
|
def render_term_note_parts(term)
|
|
280
736
|
notes = safe_attr(term, :termnote) || Array(safe_attr(term, :note))
|
|
281
737
|
parts = []
|
|
@@ -344,17 +800,62 @@ module Metanorma
|
|
|
344
800
|
})
|
|
345
801
|
end
|
|
346
802
|
else
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
803
|
+
# When the fmt-definition flow already carries the source inline
|
|
804
|
+
# (IEEE-style "(adapted from …)" inside the definition), the
|
|
805
|
+
# semantic [SOURCE: …] line would be a duplicate the native
|
|
806
|
+
# titlepage never emits.
|
|
807
|
+
unless fmt_definition_carries_source?(term)
|
|
808
|
+
term.source&.each { |src| parts << (render_term_source(src) || "") }
|
|
809
|
+
safe_attr(term, :termsource)&.each do |source|
|
|
810
|
+
parts << (render_term_source_element(source) || "")
|
|
811
|
+
end
|
|
350
812
|
end
|
|
351
813
|
end
|
|
352
814
|
parts.join
|
|
353
815
|
end
|
|
354
816
|
|
|
817
|
+
SEMX_SOURCE_SEARCH_ATTRS = %i[semx p span strong em sup sub xref eref
|
|
818
|
+
origin fmt_xref fmt_eref fmt_origin].freeze
|
|
819
|
+
|
|
820
|
+
def fmt_definition_carries_source?(term)
|
|
821
|
+
fmt_def = safe_attr(term, :fmt_definition)
|
|
822
|
+
return false unless fmt_def
|
|
823
|
+
|
|
824
|
+
candidates = Array(fmt_def.semx)
|
|
825
|
+
candidates << fmt_def if fmt_def.is_a?(Lutaml::Model::Serializable) &&
|
|
826
|
+
!fmt_def.is_a?(Metanorma::Document::Components::Inline::SemxElement)
|
|
827
|
+
candidates.any? { |n| semx_tree_has_source?(n) }
|
|
828
|
+
end
|
|
829
|
+
|
|
830
|
+
def semx_tree_has_source?(node, seen = nil)
|
|
831
|
+
return false unless node.is_a?(Lutaml::Model::Serializable)
|
|
832
|
+
|
|
833
|
+
# semx trees may be self-referential (fmt wrappers pointing back
|
|
834
|
+
# at their own definition); guard the walk with an identity set.
|
|
835
|
+
seen ||= {}.compare_by_identity
|
|
836
|
+
return false if seen[node]
|
|
837
|
+
|
|
838
|
+
seen[node] = true
|
|
839
|
+
return true if node.is_a?(Metanorma::Document::Components::Inline::SemxElement) &&
|
|
840
|
+
node.element_attr.to_s == "source"
|
|
841
|
+
|
|
842
|
+
SEMX_SOURCE_SEARCH_ATTRS.each do |attr|
|
|
843
|
+
next unless node.respond_to?(attr)
|
|
844
|
+
|
|
845
|
+
Array(node.public_send(attr)).each do |child|
|
|
846
|
+
return true if semx_tree_has_source?(child, seen)
|
|
847
|
+
end
|
|
848
|
+
end
|
|
849
|
+
false
|
|
850
|
+
end
|
|
851
|
+
|
|
355
852
|
def extract_term_name(term)
|
|
356
853
|
fmt_pref = safe_attr(term, :fmt_preferred)
|
|
357
|
-
if fmt_pref && !fmt_pref.empty?
|
|
854
|
+
if fmt_pref.is_a?(String) && !fmt_pref.empty?
|
|
855
|
+
return fmt_pref
|
|
856
|
+
end
|
|
857
|
+
|
|
858
|
+
if fmt_pref.is_a?(Array) && !fmt_pref.empty?
|
|
358
859
|
fp = fmt_pref.first
|
|
359
860
|
if fp.p && !fp.p.empty?
|
|
360
861
|
return extract_plain_text(fp.p.first)
|
|
@@ -380,10 +881,12 @@ module Metanorma
|
|
|
380
881
|
end
|
|
381
882
|
|
|
382
883
|
def render_term_designation(designation, _type)
|
|
383
|
-
|
|
384
|
-
return nil unless
|
|
884
|
+
name_element = designation_name_element(designation)
|
|
885
|
+
return nil unless name_element
|
|
385
886
|
|
|
386
|
-
inner =
|
|
887
|
+
inner = Array(name_element).map do |n|
|
|
888
|
+
n.is_a?(String) ? escape_html(n) : render_mixed_inline(n)
|
|
889
|
+
end.join
|
|
387
890
|
dfn = render_liquid("_element.html.liquid",
|
|
388
891
|
{ "tag" => "dfn", "extra_attrs" => "",
|
|
389
892
|
"content" => inner })
|
|
@@ -397,25 +900,62 @@ module Metanorma
|
|
|
397
900
|
})
|
|
398
901
|
end
|
|
399
902
|
|
|
903
|
+
# The raw name element(s) of a designation — String or
|
|
904
|
+
# mixed-content name elements (e.g. TermNameElement) — for rich
|
|
905
|
+
# inline rendering by the caller.
|
|
906
|
+
def designation_name_element(designation)
|
|
907
|
+
if designation.is_a?(Metanorma::Standoc::Document::Terms::Designation) && designation.expression
|
|
908
|
+
expr = designation.expression
|
|
909
|
+
if expr.is_a?(Metanorma::Standoc::Document::Terms::TermExpression) && expr.name
|
|
910
|
+
expr.name
|
|
911
|
+
end
|
|
912
|
+
elsif designation.is_a?(Metanorma::Standoc::Document::Terms::TermExpression)
|
|
913
|
+
designation.name
|
|
914
|
+
elsif designation.is_a?(Metanorma::Standoc::Document::Terms::Designation)
|
|
915
|
+
designation
|
|
916
|
+
end
|
|
917
|
+
end
|
|
918
|
+
|
|
400
919
|
def extract_designation_name(designation)
|
|
401
|
-
if designation.is_a?(Metanorma::
|
|
920
|
+
if designation.is_a?(Metanorma::Standoc::Document::Terms::Designation) && designation.expression
|
|
402
921
|
expr = designation.expression
|
|
403
|
-
if expr.is_a?(Metanorma::
|
|
404
|
-
|
|
922
|
+
if expr.is_a?(Metanorma::Standoc::Document::Terms::TermExpression) && expr.name
|
|
923
|
+
join_designation_names(expr.name)
|
|
405
924
|
end
|
|
406
|
-
elsif designation.is_a?(Metanorma::
|
|
407
|
-
|
|
925
|
+
elsif designation.is_a?(Metanorma::Standoc::Document::Terms::TermExpression) && designation.name
|
|
926
|
+
join_designation_names(designation.name)
|
|
408
927
|
else
|
|
409
928
|
extract_text_value(designation)
|
|
410
929
|
end
|
|
411
930
|
end
|
|
412
931
|
|
|
932
|
+
# Designation names may be plain strings or mixed-content name
|
|
933
|
+
# elements (e.g. TermNameElement); stringify through the text
|
|
934
|
+
# extractors instead of Object#to_s.
|
|
935
|
+
def join_designation_names(names)
|
|
936
|
+
Array(names).map do |n|
|
|
937
|
+
next n if n.is_a?(String)
|
|
938
|
+
|
|
939
|
+
extract_plain_text(n) || extract_text_value(n) || ""
|
|
940
|
+
end.join
|
|
941
|
+
end
|
|
942
|
+
|
|
413
943
|
def render_term_definition(definition)
|
|
414
944
|
return nil unless definition
|
|
415
|
-
return nil unless definition.is_a?(Metanorma::
|
|
945
|
+
return nil unless definition.is_a?(Metanorma::Standoc::Document::Terms::TermDefinition)
|
|
416
946
|
|
|
417
947
|
ve = definition.verbalexpression
|
|
418
|
-
|
|
948
|
+
unless ve
|
|
949
|
+
# Legacy presentation XML states the definition's blocks
|
|
950
|
+
# directly under <definition>: render them in document order.
|
|
951
|
+
legacy = collect_ordered_children(definition)
|
|
952
|
+
return legacy.empty? ? nil : legacy.filter_map { |child| render(child) }.join
|
|
953
|
+
end
|
|
954
|
+
|
|
955
|
+
walked = collect_ordered_children(ve)
|
|
956
|
+
unless walked.empty?
|
|
957
|
+
return walked.filter_map { |child| render(child) }.join
|
|
958
|
+
end
|
|
419
959
|
|
|
420
960
|
parts = []
|
|
421
961
|
ve.paragraph&.each { |para| parts << (render_paragraph(para) || "") }
|
|
@@ -468,7 +1008,7 @@ module Metanorma
|
|
|
468
1008
|
})
|
|
469
1009
|
end
|
|
470
1010
|
|
|
471
|
-
def render_term_source(source)
|
|
1011
|
+
def render_term_source(source, **_opts)
|
|
472
1012
|
return nil unless source
|
|
473
1013
|
|
|
474
1014
|
parts = []
|
|
@@ -481,24 +1021,30 @@ module Metanorma
|
|
|
481
1021
|
citeas = safe_attr(origin, :citeas)
|
|
482
1022
|
bibitemid = safe_attr(origin, :bibitemid)
|
|
483
1023
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
1024
|
+
# isodoc shows the origin's own text when the source states it
|
|
1025
|
+
# (<origin citeas="ISO 19101">ISO 19101-1:2014</origin>),
|
|
1026
|
+
# falling back to the citeas anchor.
|
|
1027
|
+
display = Array(safe_attr(origin, :content)).join.strip
|
|
1028
|
+
display = citeas.to_s if display.empty? && citeas && !citeas.to_s.empty?
|
|
1029
|
+
parts << if !display.empty? && bibitemid && !bibitemid.to_s.empty?
|
|
1030
|
+
render_liquid("_link.html.liquid", {
|
|
1031
|
+
"attrs" => element_attrs(
|
|
1032
|
+
href: "##{escape_html(bibitemid.to_s)}", class: "bibref",
|
|
1033
|
+
),
|
|
1034
|
+
"content" => escape_html(display),
|
|
1035
|
+
})
|
|
1036
|
+
elsif !display.empty?
|
|
1037
|
+
escape_html(display)
|
|
495
1038
|
else
|
|
496
1039
|
render_mixed_inline(origin) || ""
|
|
497
1040
|
end
|
|
498
1041
|
|
|
499
1042
|
modification = safe_attr(source, :modification)
|
|
500
|
-
if modification
|
|
501
|
-
|
|
1043
|
+
if modification
|
|
1044
|
+
mod_content = Array(safe_attr(modification, :p)).map do |para|
|
|
1045
|
+
render_mixed_inline(para) || ""
|
|
1046
|
+
end.join
|
|
1047
|
+
parts << ", modified — #{mod_content}" unless mod_content.strip.empty?
|
|
502
1048
|
end
|
|
503
1049
|
else
|
|
504
1050
|
parts << (render_mixed_inline(source) || "")
|
|
@@ -521,6 +1067,16 @@ module Metanorma
|
|
|
521
1067
|
|
|
522
1068
|
# --- Bibliography / References ---
|
|
523
1069
|
|
|
1070
|
+
# The document <colophon> (e.g. the BIPM "Document Control" and
|
|
1071
|
+
# "Revision History" clauses): trailing display clauses rendered
|
|
1072
|
+
# like any other clause content.
|
|
1073
|
+
def render_colophon(colophon, **_opts)
|
|
1074
|
+
parts = Array(colophon.clause).filter_map do |clause|
|
|
1075
|
+
render(clause)
|
|
1076
|
+
end
|
|
1077
|
+
parts.join
|
|
1078
|
+
end
|
|
1079
|
+
|
|
524
1080
|
def render_bibliography(bib, level: 1, **_opts)
|
|
525
1081
|
parts = []
|
|
526
1082
|
bib.references&.each do |ref|
|
|
@@ -542,6 +1098,12 @@ module Metanorma
|
|
|
542
1098
|
default_class: is_normative ? "" : "section-sub") || "")
|
|
543
1099
|
section.p&.each { |para| parts << (render_paragraph(para) || "") }
|
|
544
1100
|
section.note&.each { |note| parts << (render_paragraph(note) || "") }
|
|
1101
|
+
Array(safe_attr(section, :ol)).each do |list|
|
|
1102
|
+
parts << (render_ordered_list(list) || "")
|
|
1103
|
+
end
|
|
1104
|
+
Array(safe_attr(section, :ul)).each do |list|
|
|
1105
|
+
parts << (render_unordered_list(list) || "")
|
|
1106
|
+
end
|
|
545
1107
|
section.references&.each_with_index do |bibitem, i|
|
|
546
1108
|
parts << (render_bibitem(bibitem, i + 1,
|
|
547
1109
|
normative: is_normative) || "")
|
|
@@ -637,11 +1199,16 @@ module Metanorma
|
|
|
637
1199
|
|
|
638
1200
|
def render_bibitem_content(item)
|
|
639
1201
|
parts = []
|
|
640
|
-
if item.formatted_ref
|
|
641
|
-
|
|
1202
|
+
if (fr = item.formatted_ref)
|
|
1203
|
+
frs = fr.is_a?(Array) ? fr : [fr]
|
|
1204
|
+
frs.each do |f|
|
|
1205
|
+
parts << (render_mixed_inline(f) || "")
|
|
1206
|
+
end
|
|
642
1207
|
return parts.join
|
|
643
1208
|
end
|
|
644
1209
|
|
|
1210
|
+
parts << (bibitem_author_prefix(item) || "")
|
|
1211
|
+
|
|
645
1212
|
rendered_pubid = render_pubid_identifier(item)
|
|
646
1213
|
unless rendered_pubid
|
|
647
1214
|
render_docidentifier_fallback_into(parts, item)
|
|
@@ -672,16 +1239,90 @@ module Metanorma
|
|
|
672
1239
|
})
|
|
673
1240
|
end
|
|
674
1241
|
end
|
|
1242
|
+
|
|
1243
|
+
parts << (bibitem_publisher_statement(item) || "")
|
|
1244
|
+
parts << (bibitem_uri_statement(item) || "")
|
|
675
1245
|
parts.join
|
|
676
1246
|
end
|
|
677
1247
|
|
|
1248
|
+
# isodoc reference layout: authors lead the entry ("A. Phillips,
|
|
1249
|
+
# M. Davis: ") ahead of the document identifier. Author entities
|
|
1250
|
+
# are persons (completename) or organizations (name).
|
|
1251
|
+
def bibitem_author_prefix(item)
|
|
1252
|
+
names = Array(item.contributor).filter_map do |contributor|
|
|
1253
|
+
next unless Array(contributor.role).any? { |r| safe_attr(r, :type) == "author" }
|
|
1254
|
+
|
|
1255
|
+
if contributor.person
|
|
1256
|
+
Array(contributor.person.name&.completename).map do |name|
|
|
1257
|
+
extract_text_value(name).to_s
|
|
1258
|
+
end.join
|
|
1259
|
+
elsif contributor.organization
|
|
1260
|
+
Array(contributor.organization.name).map do |name|
|
|
1261
|
+
extract_text_value(name).to_s
|
|
1262
|
+
end.join(", ")
|
|
1263
|
+
end
|
|
1264
|
+
end.map(&:strip).reject(&:empty?)
|
|
1265
|
+
return nil if names.empty?
|
|
1266
|
+
|
|
1267
|
+
render_liquid("_inline_span.html.liquid", {
|
|
1268
|
+
"attrs" => " class=\"ref-authors\"",
|
|
1269
|
+
"content" => "#{escape_html(names.join(', '))}: ",
|
|
1270
|
+
})
|
|
1271
|
+
end
|
|
1272
|
+
|
|
1273
|
+
# Publisher, place and publication year close the entry
|
|
1274
|
+
# ("Open Geospatial Consortium , Geneva (2004).").
|
|
1275
|
+
def bibitem_publisher_statement(item)
|
|
1276
|
+
publishers = Array(item.contributor).filter_map do |contributor|
|
|
1277
|
+
next unless Array(contributor.role).any? { |r| safe_attr(r, :type) == "publisher" }
|
|
1278
|
+
next unless contributor.organization
|
|
1279
|
+
|
|
1280
|
+
Array(contributor.organization.name).map do |name|
|
|
1281
|
+
extract_text_value(name).to_s
|
|
1282
|
+
end.join(", ").strip
|
|
1283
|
+
end.reject(&:empty?)
|
|
1284
|
+
|
|
1285
|
+
places = Array(item.place).map do |place|
|
|
1286
|
+
extract_text_value(place).to_s
|
|
1287
|
+
end.map(&:strip).reject(&:empty?)
|
|
1288
|
+
|
|
1289
|
+
segments = publishers + places
|
|
1290
|
+
return nil if segments.empty?
|
|
1291
|
+
|
|
1292
|
+
year = Array(item.date).filter_map do |date|
|
|
1293
|
+
next unless safe_attr(date, :type) == "published"
|
|
1294
|
+
|
|
1295
|
+
date_on = date.is_a?(Metanorma::Document::Relaton::BibliographicDate) ? date.on : nil
|
|
1296
|
+
value = extract_text_value(date_on || safe_attr(date, :text)).to_s
|
|
1297
|
+
value[/\d{4}/]
|
|
1298
|
+
end.first
|
|
1299
|
+
|
|
1300
|
+
closing = year ? " (#{escape_html(year)})." : "."
|
|
1301
|
+
render_liquid("_inline_span.html.liquid", {
|
|
1302
|
+
"attrs" => " class=\"ref-publisher\"",
|
|
1303
|
+
"content" => "#{escape_html(segments.join(', '))}#{closing} ",
|
|
1304
|
+
})
|
|
1305
|
+
end
|
|
1306
|
+
|
|
1307
|
+
# The reference's canonical URI is visible text in isodoc output,
|
|
1308
|
+
# not only an href on the identifier anchor.
|
|
1309
|
+
def bibitem_uri_statement(item)
|
|
1310
|
+
url = bibitem_url(item)
|
|
1311
|
+
return nil unless url
|
|
1312
|
+
|
|
1313
|
+
render_liquid("_inline_span.html.liquid", {
|
|
1314
|
+
"attrs" => " class=\"ref-uri\"",
|
|
1315
|
+
"content" => escape_html(url),
|
|
1316
|
+
})
|
|
1317
|
+
end
|
|
1318
|
+
|
|
678
1319
|
def render_pubid_identifier(item)
|
|
679
1320
|
return nil unless item.docidentifier && !item.docidentifier.empty?
|
|
680
1321
|
|
|
681
1322
|
docids = Array(item.docidentifier)
|
|
682
1323
|
primary = docids.find do |di|
|
|
683
1324
|
val = extract_text_value(di).to_s
|
|
684
|
-
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:
|
|
1325
|
+
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:URN|[a-z]+-reference)\s/)
|
|
685
1326
|
end
|
|
686
1327
|
return nil unless primary
|
|
687
1328
|
|
|
@@ -700,7 +1341,7 @@ module Metanorma
|
|
|
700
1341
|
docids = Array(item.docidentifier)
|
|
701
1342
|
primary = docids.find do |di|
|
|
702
1343
|
val = extract_text_value(di).to_s
|
|
703
|
-
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:
|
|
1344
|
+
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:URN|[a-z]+-reference)\s/)
|
|
704
1345
|
end
|
|
705
1346
|
return unless primary
|
|
706
1347
|
|
|
@@ -771,7 +1412,8 @@ module Metanorma
|
|
|
771
1412
|
end
|
|
772
1413
|
|
|
773
1414
|
%i[tables figures formulas examples notes admonitions sourcecode_blocks
|
|
774
|
-
quote_blocks
|
|
1415
|
+
quote_blocks requirement recommendation permission
|
|
1416
|
+
term_sources].each do |attr|
|
|
775
1417
|
values = safe_attr(section, attr)
|
|
776
1418
|
if values
|
|
777
1419
|
Array(values).each do |v|
|
|
@@ -803,6 +1445,20 @@ module Metanorma
|
|
|
803
1445
|
|
|
804
1446
|
"Note to entry"
|
|
805
1447
|
end
|
|
1448
|
+
|
|
1449
|
+
# Semantic notes (e.g. inside amendment newcontent) carry their
|
|
1450
|
+
# number as the number attribute, with no fmt-name or autonum.
|
|
1451
|
+
def extract_block_label(block, default)
|
|
1452
|
+
label = super
|
|
1453
|
+
return label unless label == default
|
|
1454
|
+
|
|
1455
|
+
number = safe_attr(block, :number)
|
|
1456
|
+
if number && !number.to_s.empty?
|
|
1457
|
+
"#{default} #{number}"
|
|
1458
|
+
else
|
|
1459
|
+
label
|
|
1460
|
+
end
|
|
1461
|
+
end
|
|
806
1462
|
end
|
|
807
1463
|
end
|
|
808
1464
|
end
|