metanorma-document 0.2.12 → 0.2.13
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/.github/workflows/rake.yml +21 -0
- data/.github/workflows/release.yml +25 -0
- data/.github/workflows/roundtrip-samples.yml +132 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/.rubocop.yml +22 -0
- data/.rubocop_todo.yml +66 -164
- data/CHANGELOG.md +1 -0
- data/Gemfile +32 -0
- data/README.adoc +0 -144
- data/Rakefile +2 -14
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/data/javascripts/components/mn-lightbox.js +2 -18
- data/data/javascripts/components/mn-shortcuts.js +0 -2
- data/data/javascripts/core/mn-navigation.js +0 -8
- data/data/javascripts/core/mn-theme.js +9 -9
- data/data/logos/pdfa-logo.svg +94 -31
- data/data/stylesheets/base/_layout.css +0 -3
- data/data/stylesheets/base/_reset.css +3 -3
- data/data/stylesheets/base/_typography.css +5 -0
- data/data/stylesheets/components/bibliography.css +3 -3
- data/data/stylesheets/components/cover.css +1 -3
- data/data/stylesheets/components/figure.css +1 -13
- data/data/stylesheets/components/footnote.css +5 -65
- data/data/stylesheets/components/formula.css +0 -44
- data/data/stylesheets/components/header.css +2 -17
- data/data/stylesheets/components/inline.css +1 -1
- data/data/stylesheets/components/table.css +2 -15
- data/data/stylesheets/components/term.css +1 -0
- data/lib/metanorma/bipm_document/metadata/bipm_bibliographic_item.rb +14 -0
- data/lib/metanorma/bipm_document/metadata.rb +1 -1
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +65 -0
- data/lib/metanorma/document/components/ancillary_blocks.rb +0 -4
- data/lib/metanorma/document/components/bib_data/bib_data.rb +0 -7
- data/lib/metanorma/document/components/blocks/requirement_model.rb +131 -0
- data/lib/metanorma/document/components/blocks.rb +7 -8
- data/lib/metanorma/document/components/id_elements/image.rb +0 -2
- data/lib/metanorma/document/components/inline/asciimath_element.rb +0 -2
- data/lib/metanorma/document/components/inline/attribution_element.rb +0 -2
- data/lib/metanorma/document/components/inline/bcp14_element.rb +0 -2
- data/lib/metanorma/document/components/inline/biblio_tag_element.rb +0 -2
- data/lib/metanorma/document/components/inline/br_element.rb +0 -2
- data/lib/metanorma/document/components/inline/comma_element.rb +0 -2
- data/lib/metanorma/document/components/inline/concept_element.rb +0 -2
- data/lib/metanorma/document/components/inline/display_text_element.rb +0 -2
- data/lib/metanorma/document/components/inline/em_raw_element.rb +0 -2
- data/lib/metanorma/document/components/inline/enum_comma_element.rb +0 -2
- data/lib/metanorma/document/components/inline/eref_element.rb +0 -2
- data/lib/metanorma/document/components/inline/fmt_admitted_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_annotation_body_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_annotation_end_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_annotation_start_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_concept_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_definition_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_fn_body_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_fn_label_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_footnote_container_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_identifier_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_name_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_preferred_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_sourcecode_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_stem_element.rb +0 -10
- data/lib/metanorma/document/components/inline/fmt_termsource_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_title_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_xref_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fmt_xref_label_element.rb +0 -4
- data/lib/metanorma/document/components/inline/fn_element.rb +0 -2
- data/lib/metanorma/document/components/inline/link_element.rb +0 -2
- data/lib/metanorma/document/components/inline/localized_string_element.rb +0 -2
- data/lib/metanorma/document/components/inline/localized_strings_element.rb +0 -2
- data/lib/metanorma/document/components/inline/math_element.rb +0 -2
- data/lib/metanorma/document/components/inline/name_with_id_element.rb +0 -4
- data/lib/metanorma/document/components/inline/semx_child_element.rb +0 -2
- data/lib/metanorma/document/components/inline/semx_element.rb +1 -13
- data/lib/metanorma/document/components/inline/small_cap_element.rb +0 -2
- data/lib/metanorma/document/components/inline/span_element.rb +15 -10
- data/lib/metanorma/document/components/inline/stem_inline_element.rb +1 -7
- data/lib/metanorma/document/components/inline/strong_raw_element.rb +0 -2
- data/lib/metanorma/document/components/inline/sub_element.rb +0 -2
- data/lib/metanorma/document/components/inline/sup_element.rb +0 -2
- data/lib/metanorma/document/components/inline/tab_element.rb +0 -2
- data/lib/metanorma/document/components/inline/title_with_annotation_element.rb +0 -4
- data/lib/metanorma/document/components/inline/tt_element.rb +0 -2
- data/lib/metanorma/document/components/inline/variant_title_element.rb +0 -2
- data/lib/metanorma/document/components/inline/xref_element.rb +0 -10
- data/lib/metanorma/document/components/inline.rb +0 -12
- data/lib/metanorma/document/components/multi_paragraph/quote_block.rb +29 -0
- data/lib/metanorma/document/components/multi_paragraph.rb +0 -2
- data/lib/metanorma/document/components/reference_elements/source_element.rb +31 -0
- data/lib/metanorma/document/components/reference_elements.rb +2 -2
- data/lib/metanorma/document/components/tables/table_block.rb +22 -0
- data/lib/metanorma/document/components/tables/table_section.rb +25 -0
- data/lib/metanorma/document/components/tables.rb +3 -5
- data/lib/metanorma/document/relaton/address.rb +27 -0
- data/lib/metanorma/document/relaton/bib_item_locality.rb +12 -3
- data/lib/metanorma/document/relaton/copyright_association.rb +10 -0
- data/lib/metanorma/document/relaton/edition.rb +7 -4
- data/lib/metanorma/document/relaton/organization.rb +14 -0
- data/lib/metanorma/document/relaton/phone.rb +9 -3
- data/lib/metanorma/document/relaton/place_type.rb +13 -0
- data/lib/metanorma/document/relaton/price_type.rb +9 -3
- data/lib/metanorma/document/relaton.rb +1 -6
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +0 -2
- data/lib/metanorma/html/asset_pipeline.rb +0 -1
- data/lib/metanorma/html/base_renderer.rb +1008 -261
- data/lib/metanorma/html/bipm_renderer.rb +144 -15
- data/lib/metanorma/html/cc_renderer.rb +45 -1
- data/lib/metanorma/html/component/base.rb +7 -2
- data/lib/metanorma/html/component/index_section.rb +43 -41
- data/lib/metanorma/html/drops/admonition_drop.rb +4 -1
- data/lib/metanorma/html/drops/block_element_drop.rb +2 -7
- data/lib/metanorma/html/drops/example_drop.rb +4 -1
- data/lib/metanorma/html/drops/figure_drop.rb +22 -31
- data/lib/metanorma/html/drops/footnote_drop.rb +1 -1
- data/lib/metanorma/html/drops/formula_drop.rb +16 -45
- data/lib/metanorma/html/drops/note_drop.rb +7 -9
- data/lib/metanorma/html/drops/sourcecode_drop.rb +5 -12
- data/lib/metanorma/html/drops.rb +0 -2
- data/lib/metanorma/html/generator.rb +2 -2
- data/lib/metanorma/html/icc_renderer.rb +39 -0
- data/lib/metanorma/html/iec_renderer.rb +44 -1
- data/lib/metanorma/html/ieee_renderer.rb +45 -1
- data/lib/metanorma/html/ietf_renderer.rb +48 -1
- data/lib/metanorma/html/iho_renderer.rb +46 -1
- data/lib/metanorma/html/iso_renderer.rb +343 -290
- data/lib/metanorma/html/itu_renderer.rb +45 -1
- data/lib/metanorma/html/ogc_renderer.rb +76 -15
- data/lib/metanorma/html/oiml_renderer.rb +38 -18
- data/lib/metanorma/html/pdfa_renderer.rb +39 -0
- data/lib/metanorma/html/ribose_renderer.rb +45 -1
- data/lib/metanorma/html/standard_renderer.rb +229 -341
- data/lib/metanorma/html/templates/_footnotes.html.liquid +6 -6
- data/lib/metanorma/html/templates/_formula.html.liquid +1 -1
- data/lib/metanorma/html/templates/_header.html.liquid +1 -1
- data/lib/metanorma/html/templates/_iso_cover.html.liquid +1 -1
- data/lib/metanorma/html/templates/document.html.liquid +0 -4
- data/lib/metanorma/html/theme.rb +107 -180
- data/lib/metanorma/html.rb +3 -14
- data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +25 -0
- data/lib/metanorma/ietf_document/metadata.rb +0 -2
- data/lib/metanorma/iso_document/metadata/iso_bib_data_extension_type.rb +48 -0
- data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +72 -0
- data/lib/metanorma/iso_document/metadata/iso_document_status.rb +30 -0
- data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +1 -4
- data/lib/metanorma/iso_document/metadata/structured_identifier.rb +17 -0
- data/lib/metanorma/iso_document/metadata/title_collection.rb +0 -1
- data/lib/metanorma/iso_document/metadata.rb +4 -9
- data/lib/metanorma/iso_document/terms/iso_term.rb +13 -0
- data/lib/metanorma/iso_document/terms.rb +0 -1
- data/lib/metanorma/itu_document/metadata/itu_bib_data_extension_type.rb +37 -0
- data/lib/metanorma/itu_document/metadata.rb +4 -3
- data/lib/metanorma/standard_document/block_attributes.rb +9 -5
- data/lib/metanorma/standard_document/blocks/block_source.rb +23 -0
- data/lib/metanorma/standard_document/blocks.rb +1 -1
- data/lib/metanorma/standard_document/terms/term_expression.rb +31 -0
- data/lib/metanorma/standard_document/terms.rb +0 -1
- data/metanorma-document.gemspec +35 -0
- metadata +13 -262
- data/CLAUDE.md +0 -26
- 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/data/javascripts/components/mn-footnotes.js +0 -68
- data/data/logos/oiml-logo-full-dark.svg +0 -1
- data/data/logos/oiml-logo-full-light.svg +0 -1
- data/data/logos/oiml-logo-icon-dark.svg +0 -1
- data/data/logos/oiml-logo-icon-light.svg +0 -1
- data/data/logos/oiml-logo.svg +0 -1
- data/data/themes/bipm.yaml +0 -60
- data/data/themes/cc.yaml +0 -43
- data/data/themes/icc.yaml +0 -39
- data/data/themes/iec.yaml +0 -44
- data/data/themes/ieee.yaml +0 -43
- data/data/themes/ietf.yaml +0 -45
- data/data/themes/iho.yaml +0 -46
- data/data/themes/iso.yaml +0 -40
- data/data/themes/itu.yaml +0 -45
- data/data/themes/ogc.yaml +0 -51
- data/data/themes/oiml.yaml +0 -56
- data/data/themes/pdfa.yaml +0 -44
- data/data/themes/ribose.yaml +0 -43
- data/exe/metanorma-document +0 -11
- data/frontend/e2e/sample-html.test.ts +0 -256
- data/frontend/index.html +0 -12
- data/frontend/package-lock.json +0 -4725
- data/frontend/package.json +0 -32
- data/frontend/postcss.config.js +0 -6
- data/frontend/src/App.vue +0 -79
- data/frontend/src/app.ts +0 -21
- data/frontend/src/components/AppSidebar.vue +0 -77
- data/frontend/src/components/DocumentReader.vue +0 -180
- data/frontend/src/components/MirrorRenderer.vue +0 -23
- data/frontend/src/components/ReadingProgressBar.vue +0 -29
- data/frontend/src/components/TextRenderer.vue +0 -131
- data/frontend/src/components/TocItem.vue +0 -57
- data/frontend/src/components/TopBar.vue +0 -49
- data/frontend/src/components/__tests__/MirrorRenderer.test.ts +0 -178
- data/frontend/src/components/blocks/AdmonitionBlock.vue +0 -74
- data/frontend/src/components/blocks/ClauseBlock.vue +0 -53
- data/frontend/src/components/blocks/ExampleBlock.vue +0 -21
- data/frontend/src/components/blocks/FallbackBlock.vue +0 -18
- data/frontend/src/components/blocks/FigureBlock.vue +0 -26
- data/frontend/src/components/blocks/FootnotesBlock.vue +0 -25
- data/frontend/src/components/blocks/ListBlocks.vue +0 -62
- data/frontend/src/components/blocks/NoteBlock.vue +0 -21
- data/frontend/src/components/blocks/ParagraphBlock.vue +0 -25
- data/frontend/src/components/blocks/QuoteBlock.vue +0 -25
- data/frontend/src/components/blocks/ReviewBlock.vue +0 -39
- data/frontend/src/components/blocks/SourcecodeBlock.vue +0 -52
- data/frontend/src/components/blocks/TableBlock.vue +0 -48
- data/frontend/src/components/blocks/index.ts +0 -36
- data/frontend/src/stores/__tests__/documentStore.fixture.test.ts +0 -272
- data/frontend/src/stores/__tests__/documentStore.test.ts +0 -143
- data/frontend/src/stores/__tests__/ebookStore.test.ts +0 -145
- data/frontend/src/stores/__tests__/uiStore.test.ts +0 -42
- data/frontend/src/stores/documentStore.ts +0 -153
- data/frontend/src/stores/ebookStore.ts +0 -179
- data/frontend/src/stores/uiStore.ts +0 -32
- data/frontend/src/styles.css +0 -156
- data/frontend/src/types/__tests__/rendering-contract.test.ts +0 -172
- data/frontend/src/types/rendering-contract.ts +0 -209
- data/frontend/src/utils/__tests__/typeMetadata.test.ts +0 -102
- data/frontend/src/utils/typeMetadata.ts +0 -121
- data/frontend/tailwind.config.js +0 -18
- data/frontend/test/fixtures/iso-document.json +0 -271
- data/frontend/tmp/debug_e2e.cjs +0 -46
- data/frontend/tsconfig.json +0 -25
- data/frontend/tsconfig.node.json +0 -11
- data/frontend/vite.config.ts +0 -37
- data/frontend/vitest.e2e.config.ts +0 -9
- data/lib/metanorma/bipm_document/metadata/depiction_element.rb +0 -18
- data/lib/metanorma/document/cli.rb +0 -116
- data/lib/metanorma/document/components/ancillary_blocks/callout_annotation.rb +0 -27
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_body.rb +0 -18
- data/lib/metanorma/document/components/blocks/classification_value.rb +0 -21
- data/lib/metanorma/document/components/blocks/permission_model.rb +0 -28
- data/lib/metanorma/document/components/blocks/recommendation_model.rb +0 -28
- data/lib/metanorma/document/components/blocks/requirement_base.rb +0 -30
- data/lib/metanorma/document/components/blocks/requirement_classification.rb +0 -20
- data/lib/metanorma/document/components/blocks/requirement_description.rb +0 -43
- data/lib/metanorma/document/components/blocks/requirement_inherit.rb +0 -24
- data/lib/metanorma/document/components/inline/location_element.rb +0 -24
- data/lib/metanorma/document/components/inline/rendered_display.rb +0 -23
- data/lib/metanorma/document/components/inline/rendered_math_element.rb +0 -21
- data/lib/metanorma/document/components/inline/semantic_content.rb +0 -51
- data/lib/metanorma/document/components/inline/semantic_math_element.rb +0 -20
- data/lib/metanorma/document/components/inline/vocabulary.rb +0 -184
- data/lib/metanorma/document/components/multi_paragraph/quote_author_element.rb +0 -20
- data/lib/metanorma/document/components/reference_elements/source_modification.rb +0 -21
- data/lib/metanorma/document/components/reference_elements/source_origin.rb +0 -28
- data/lib/metanorma/document/components/tables/col_element.rb +0 -18
- data/lib/metanorma/document/components/tables/col_group_element.rb +0 -18
- data/lib/metanorma/document/components/tables/table_body_section.rb +0 -16
- data/lib/metanorma/document/components/tables/table_foot_section.rb +0 -16
- data/lib/metanorma/document/components/tables/table_head_section.rb +0 -16
- data/lib/metanorma/document/relaton/copyright_owner.rb +0 -16
- data/lib/metanorma/document/relaton/formatted_address.rb +0 -29
- data/lib/metanorma/document/relaton/logo_element.rb +0 -18
- data/lib/metanorma/document/relaton/region_element.rb +0 -18
- data/lib/metanorma/html/drops/biblio_entry_drop.rb +0 -50
- data/lib/metanorma/html/renderers/block_renderer.rb +0 -372
- data/lib/metanorma/html/renderers/inline_renderer.rb +0 -655
- data/lib/metanorma/html/renderers/pubid_renderer.rb +0 -69
- data/lib/metanorma/html/renderers/section_renderer.rb +0 -193
- data/lib/metanorma/html/renderers.rb +0 -8
- data/lib/metanorma/html/templates/_audio.html.liquid +0 -1
- data/lib/metanorma/html/templates/_biblio_entry.html.liquid +0 -1
- data/lib/metanorma/html/templates/_bipm_cover.html.liquid +0 -27
- data/lib/metanorma/html/templates/_boilerplate.html.liquid +0 -1
- data/lib/metanorma/html/templates/_bookmark.html.liquid +0 -1
- data/lib/metanorma/html/templates/_br.html.liquid +0 -1
- data/lib/metanorma/html/templates/_definition_list.html.liquid +0 -6
- data/lib/metanorma/html/templates/_element.html.liquid +0 -1
- data/lib/metanorma/html/templates/_fn_marker.html.liquid +0 -1
- data/lib/metanorma/html/templates/_heading.html.liquid +0 -1
- data/lib/metanorma/html/templates/_image.html.liquid +0 -1
- data/lib/metanorma/html/templates/_inline_span.html.liquid +0 -1
- data/lib/metanorma/html/templates/_link.html.liquid +0 -1
- data/lib/metanorma/html/templates/_list.html.liquid +0 -3
- data/lib/metanorma/html/templates/_list_item.html.liquid +0 -1
- data/lib/metanorma/html/templates/_main_content.html.liquid +0 -1
- data/lib/metanorma/html/templates/_math_container.html.liquid +0 -1
- data/lib/metanorma/html/templates/_paragraph.html.liquid +0 -1
- data/lib/metanorma/html/templates/_prefatory_section.html.liquid +0 -1
- data/lib/metanorma/html/templates/_pubid_identifier.html.liquid +0 -1
- data/lib/metanorma/html/templates/_quote.html.liquid +0 -4
- data/lib/metanorma/html/templates/_ref_date.html.liquid +0 -1
- data/lib/metanorma/html/templates/_ref_title.html.liquid +0 -1
- data/lib/metanorma/html/templates/_section.html.liquid +0 -5
- data/lib/metanorma/html/templates/_standard_cover.html.liquid +0 -31
- data/lib/metanorma/html/templates/_standard_doc_title.html.liquid +0 -3
- data/lib/metanorma/html/templates/_stem_span.html.liquid +0 -1
- data/lib/metanorma/html/templates/_table.html.liquid +0 -9
- data/lib/metanorma/html/templates/_term_domain.html.liquid +0 -1
- data/lib/metanorma/html/templates/_term_example.html.liquid +0 -1
- data/lib/metanorma/html/templates/_term_note.html.liquid +0 -1
- data/lib/metanorma/html/templates/_term_number.html.liquid +0 -1
- data/lib/metanorma/html/templates/_term_source.html.liquid +0 -1
- data/lib/metanorma/html/templates/_term_text_note.html.liquid +0 -1
- data/lib/metanorma/html/templates/_video.html.liquid +0 -1
- data/lib/metanorma/html/templates/_wrapped_preface.html.liquid +0 -1
- data/lib/metanorma/ietf_document/metadata/pi_settings.rb +0 -32
- data/lib/metanorma/iso_document/metadata/doctype_element.rb +0 -20
- data/lib/metanorma/iso_document/metadata/language_element.rb +0 -18
- 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/terms/term_domain_element.rb +0 -18
- 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/mirror/default_registry.rb +0 -170
- 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/rich_html_renderer.rb +0 -159
- data/lib/metanorma/mirror/handlers/inline/text_extractor.rb +0 -116
- data/lib/metanorma/mirror/handlers/inline.rb +0 -225
- 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/metanorma_to_mirror.rb +0 -101
- 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 -25
- 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 -81
- data/lib/metanorma/mirror/output/formats.rb +0 -53
- 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 -64
- 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/mirror/output/pipeline.rb +0 -92
- data/lib/metanorma/mirror/output/pipeline_context.rb +0 -22
- data/lib/metanorma/mirror/output.rb +0 -14
- data/lib/metanorma/mirror/rewriter.rb +0 -121
- 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 -22
- data/lib/metanorma/mirror.rb +0 -32
- data/lib/metanorma/standard_document/annotation.rb +0 -37
- data/lib/metanorma/standard_document/blocks/source_origin_element.rb +0 -23
- data/lib/metanorma/standard_document/terms/term_name_element.rb +0 -29
- data/script/render_both.rb +0 -18
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Inline
|
|
7
|
-
module TextExtractor
|
|
8
|
-
def self.extract_element_text(element)
|
|
9
|
-
return "" unless element.is_a?(Lutaml::Model::Serializable)
|
|
10
|
-
|
|
11
|
-
text = SafeAttr.read(element, :text)
|
|
12
|
-
if text.is_a?(Array)
|
|
13
|
-
joined = text.join.strip
|
|
14
|
-
return joined unless joined.empty?
|
|
15
|
-
elsif text.is_a?(String) && !text.strip.empty?
|
|
16
|
-
return text
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
content = SafeAttr.read(element, :content)
|
|
20
|
-
if content.is_a?(Array)
|
|
21
|
-
parts = content.filter_map do |c|
|
|
22
|
-
next c.to_s if c.is_a?(String)
|
|
23
|
-
next extract_element_text(c) if c.is_a?(Lutaml::Model::Serializable)
|
|
24
|
-
|
|
25
|
-
nil
|
|
26
|
-
end
|
|
27
|
-
joined = parts.join.strip
|
|
28
|
-
return joined unless joined.empty?
|
|
29
|
-
elsif content.is_a?(String) && !content.strip.empty?
|
|
30
|
-
return content
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
""
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def self.extract_formatted_text(element)
|
|
37
|
-
return "" unless element
|
|
38
|
-
return element.to_s unless element.is_a?(Lutaml::Model::Serializable)
|
|
39
|
-
|
|
40
|
-
parts = []
|
|
41
|
-
element.each_mixed_content do |node|
|
|
42
|
-
case node
|
|
43
|
-
when String
|
|
44
|
-
parts << node
|
|
45
|
-
when Lutaml::Model::Serializable
|
|
46
|
-
inner = extract_formatted_text(node)
|
|
47
|
-
parts << inner if inner && !inner.empty?
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
result = parts.join.strip
|
|
51
|
-
result.empty? ? extract_element_text(element) : result
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def self.extract_text_from_model(node)
|
|
55
|
-
case node
|
|
56
|
-
when Metanorma::Document::Components::Inline::TabElement
|
|
57
|
-
" "
|
|
58
|
-
when Metanorma::Document::Components::Inline::BrElement
|
|
59
|
-
"\n"
|
|
60
|
-
else
|
|
61
|
-
text = extract_formatted_text(node)
|
|
62
|
-
text.empty? ? extract_element_text(node) : text
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def self.extract_fn_label(element)
|
|
67
|
-
label = SafeAttr.read(element, :fmt_fn_label)
|
|
68
|
-
return extract_element_text(element) unless label
|
|
69
|
-
|
|
70
|
-
extract_formatted_text(label)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def self.extract_stem_text(element)
|
|
74
|
-
asciimath = MathUtil.asciimath_from_stem(element)
|
|
75
|
-
return asciimath if asciimath
|
|
76
|
-
|
|
77
|
-
extract_element_text(element)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def self.extract_span_text(element)
|
|
81
|
-
text = extract_element_text(element)
|
|
82
|
-
return text unless text.strip.empty?
|
|
83
|
-
|
|
84
|
-
extract_formatted_text(element)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def self.extract_name_text(name)
|
|
88
|
-
return name if name.is_a?(String)
|
|
89
|
-
|
|
90
|
-
text = SafeAttr.read(name, :text)
|
|
91
|
-
return text.to_s if text.is_a?(String) && !text.strip.empty?
|
|
92
|
-
|
|
93
|
-
stems = SafeAttr.read(name, :stem)
|
|
94
|
-
if stems.is_a?(Array) && !stems.empty?
|
|
95
|
-
parts = Array(text).dup
|
|
96
|
-
stems.each_with_index do |s, i|
|
|
97
|
-
stem_text = MathUtil.text_from_stem(s)
|
|
98
|
-
parts.insert(i + 1, stem_text) if stem_text && !stem_text.empty?
|
|
99
|
-
end
|
|
100
|
-
joined = parts.join.strip
|
|
101
|
-
return joined unless joined.empty?
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
return Array(text).join if text.is_a?(Array) && !text.empty?
|
|
105
|
-
|
|
106
|
-
""
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def self.extract_bibdata_title(bibdata)
|
|
110
|
-
Metadata.title_from_bibdata(bibdata)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
end
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Inline
|
|
7
|
-
autoload :TextExtractor, "#{__dir__}/inline/text_extractor"
|
|
8
|
-
autoload :RichHtmlRenderer, "#{__dir__}/inline/rich_html_renderer"
|
|
9
|
-
|
|
10
|
-
MARK_BUILDERS = {
|
|
11
|
-
Metanorma::Document::Components::Inline::EmRawElement => ->(_el) {
|
|
12
|
-
Handlers.build_mark("emphasis")
|
|
13
|
-
},
|
|
14
|
-
Metanorma::Document::Components::Inline::StrongRawElement => ->(_el) {
|
|
15
|
-
Handlers.build_mark("strong")
|
|
16
|
-
},
|
|
17
|
-
Metanorma::Document::Components::Inline::SubElement => ->(_el) {
|
|
18
|
-
Handlers.build_mark("subscript")
|
|
19
|
-
},
|
|
20
|
-
Metanorma::Document::Components::Inline::SupElement => ->(_el) {
|
|
21
|
-
Handlers.build_mark("superscript")
|
|
22
|
-
},
|
|
23
|
-
Metanorma::Document::Components::Inline::TtElement => ->(_el) {
|
|
24
|
-
Handlers.build_mark("code")
|
|
25
|
-
},
|
|
26
|
-
Metanorma::Document::Components::TextElements::UnderlineElement => ->(_el) {
|
|
27
|
-
Handlers.build_mark("underline")
|
|
28
|
-
},
|
|
29
|
-
Metanorma::Document::Components::TextElements::StrikeElement => ->(_el) {
|
|
30
|
-
Handlers.build_mark("strike")
|
|
31
|
-
},
|
|
32
|
-
Metanorma::Document::Components::Inline::SmallCapElement => ->(_el) {
|
|
33
|
-
Handlers.build_mark("smallcap")
|
|
34
|
-
},
|
|
35
|
-
Metanorma::Document::Components::Inline::Bcp14Element => ->(_el) {
|
|
36
|
-
Handlers.build_mark("bcp14")
|
|
37
|
-
},
|
|
38
|
-
Metanorma::Document::Components::Inline::LinkElement => ->(el) {
|
|
39
|
-
attrs = {
|
|
40
|
-
href: SafeAttr.read(el, :target) || SafeAttr.read(el, :href),
|
|
41
|
-
}.compact
|
|
42
|
-
Handlers.build_mark("link", attrs: attrs)
|
|
43
|
-
},
|
|
44
|
-
Metanorma::Document::Components::Inline::XrefElement => ->(el) {
|
|
45
|
-
attrs = { target: SafeAttr.read(el, :target) }.compact
|
|
46
|
-
Handlers.build_mark("xref", attrs: attrs)
|
|
47
|
-
},
|
|
48
|
-
Metanorma::Document::Components::Inline::ErefElement => ->(el) {
|
|
49
|
-
attrs = {
|
|
50
|
-
bibitemid: SafeAttr.read(el, :bibitemid),
|
|
51
|
-
citeas: SafeAttr.read(el, :citeas),
|
|
52
|
-
}.compact
|
|
53
|
-
Handlers.build_mark("eref", attrs: attrs)
|
|
54
|
-
},
|
|
55
|
-
Metanorma::Document::Components::Inline::FnElement => ->(el) {
|
|
56
|
-
attrs = {
|
|
57
|
-
id: SafeAttr.read(el, :id),
|
|
58
|
-
reference: SafeAttr.read(el, :reference),
|
|
59
|
-
}.compact
|
|
60
|
-
Handlers.build_mark("footnote", attrs: attrs)
|
|
61
|
-
},
|
|
62
|
-
Metanorma::Document::Components::Inline::StemInlineElement => ->(el) {
|
|
63
|
-
attrs = { stem_type: SafeAttr.read(el, :stem_type) || "MathML" }
|
|
64
|
-
math = SafeAttr.read(el, :math)
|
|
65
|
-
attrs[:mathml] = MathUtil.mathml_from_math(math) if math
|
|
66
|
-
Handlers.build_mark("stem", attrs: attrs.compact)
|
|
67
|
-
},
|
|
68
|
-
Metanorma::Document::Components::Inline::ConceptElement => ->(el) {
|
|
69
|
-
attrs = {
|
|
70
|
-
refterm: SafeAttr.read(el, :refterm),
|
|
71
|
-
renderterm: SafeAttr.read(el, :renderterm),
|
|
72
|
-
}.compact
|
|
73
|
-
Handlers.build_mark("concept", attrs: attrs)
|
|
74
|
-
},
|
|
75
|
-
Metanorma::Document::Components::Inline::SpanElement => ->(el) {
|
|
76
|
-
attrs = {
|
|
77
|
-
class_attr: SafeAttr.read(el, :class_attr),
|
|
78
|
-
style: SafeAttr.read(el, :style),
|
|
79
|
-
}.compact
|
|
80
|
-
Handlers.build_mark("span", attrs: attrs)
|
|
81
|
-
},
|
|
82
|
-
}.freeze
|
|
83
|
-
|
|
84
|
-
SEMX_MARK_CONFIG = {
|
|
85
|
-
"xref" => { mark_type: "xref", target_attr: :target,
|
|
86
|
-
fmt_attr: :fmt_xref },
|
|
87
|
-
"eref" => { mark_type: "eref", target_attr: :target,
|
|
88
|
-
fmt_attr: :fmt_xref },
|
|
89
|
-
"link" => { mark_type: "link", target_attr: :target,
|
|
90
|
-
fmt_attr: :fmt_link },
|
|
91
|
-
}.freeze
|
|
92
|
-
|
|
93
|
-
CROSSREF_MARKS = %w[xref eref link].to_set.freeze
|
|
94
|
-
|
|
95
|
-
# Delegates to TextExtractor
|
|
96
|
-
def self.extract_element_text(element)
|
|
97
|
-
TextExtractor.extract_element_text(element)
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
def self.extract_formatted_text(element)
|
|
101
|
-
TextExtractor.extract_formatted_text(element)
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def self.extract_text_from_model(node)
|
|
105
|
-
TextExtractor.extract_text_from_model(node)
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# Delegates to RichHtmlRenderer
|
|
109
|
-
def self.extract_rich_html(element)
|
|
110
|
-
RichHtmlRenderer.extract(element)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Primary entry point: extract inline content from a mixed-content element.
|
|
114
|
-
# Iterates semantic children only — `fmt-*` rendered siblings are skipped
|
|
115
|
-
# to avoid emitting duplicate marks for the same logical content.
|
|
116
|
-
def self.extract_inline(element, context:)
|
|
117
|
-
nodes = []
|
|
118
|
-
Metanorma::Document::Components::Inline::SemanticContent.each(element) do |node|
|
|
119
|
-
case node
|
|
120
|
-
when String
|
|
121
|
-
nodes << context.text_node(node) unless node.empty?
|
|
122
|
-
else
|
|
123
|
-
handle_inline_element(node, nodes, context:)
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
filter_empty_crossrefs(nodes)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def self.handle_inline_element(element, nodes, context:)
|
|
130
|
-
if semx_element?(element)
|
|
131
|
-
handle_semx(element, nodes, context:)
|
|
132
|
-
return
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
if block_in_inline?(element, context)
|
|
136
|
-
handle_block_in_inline(element, nodes, context:)
|
|
137
|
-
return
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
mark_builder = MARK_BUILDERS[element.class]
|
|
141
|
-
if mark_builder
|
|
142
|
-
mark = mark_builder.call(element)
|
|
143
|
-
text = extract_marked_text(mark.type, element)
|
|
144
|
-
nodes << context.text_node(text, marks: [mark])
|
|
145
|
-
else
|
|
146
|
-
handle_structured_inline(element, nodes, context:)
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
def self.handle_semx(element, nodes, context:)
|
|
151
|
-
config = SEMX_MARK_CONFIG[element.element_attr]
|
|
152
|
-
if config
|
|
153
|
-
handle_semx_crossref(element, config, nodes, context:)
|
|
154
|
-
else
|
|
155
|
-
handle_structured_inline(element, nodes, context:)
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def self.handle_semx_crossref(element, config, nodes, context:)
|
|
160
|
-
fmt_children = SafeAttr.read(element, config[:fmt_attr])
|
|
161
|
-
fmt_child = fmt_children&.first
|
|
162
|
-
|
|
163
|
-
mark_attrs = {}
|
|
164
|
-
if fmt_child && config[:target_attr]
|
|
165
|
-
mark_attrs[config[:target_attr]] = SafeAttr.read(fmt_child, :target)
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
if element.element_attr == "eref" && fmt_child
|
|
169
|
-
mark_attrs[:citeas] = extract_formatted_text(fmt_child)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
text = extract_formatted_text(fmt_child || element)
|
|
173
|
-
mark = Handlers.build_mark(config[:mark_type],
|
|
174
|
-
attrs: mark_attrs.compact)
|
|
175
|
-
nodes << context.text_node(text, marks: [mark])
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
def self.handle_block_in_inline(element, nodes, context:)
|
|
179
|
-
result = context.registry.handle(element, context: context)
|
|
180
|
-
result.append_to(nodes)
|
|
181
|
-
end
|
|
182
|
-
|
|
183
|
-
def self.handle_structured_inline(element, nodes, context:)
|
|
184
|
-
if element.is_a?(Lutaml::Model::Serializable)
|
|
185
|
-
inner_nodes = extract_inline(element, context:)
|
|
186
|
-
nodes.concat(inner_nodes)
|
|
187
|
-
else
|
|
188
|
-
text = element.text
|
|
189
|
-
nodes << context.text_node(text) if text.is_a?(String) && !text.strip.empty?
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
def self.mark_text_extractors
|
|
194
|
-
@mark_text_extractors ||= {
|
|
195
|
-
"footnote" => TextExtractor.method(:extract_fn_label),
|
|
196
|
-
"stem" => TextExtractor.method(:extract_stem_text),
|
|
197
|
-
"span" => TextExtractor.method(:extract_span_text),
|
|
198
|
-
}
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
def self.extract_marked_text(mark_type, element)
|
|
202
|
-
extractor = mark_text_extractors[mark_type]
|
|
203
|
-
return extractor.call(element) if extractor
|
|
204
|
-
|
|
205
|
-
TextExtractor.extract_element_text(element)
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def self.semx_element?(element)
|
|
209
|
-
element.is_a?(Metanorma::Document::Components::Inline::SemxElement)
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
def self.block_in_inline?(element, context)
|
|
213
|
-
context.registry.registered?(element.class)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def self.filter_empty_crossrefs(nodes)
|
|
217
|
-
nodes.reject do |n|
|
|
218
|
-
n.is_a?(Model::Text) && n.text.strip.empty? &&
|
|
219
|
-
n.marks.any? { |m| CROSSREF_MARKS.include?(m.type) }
|
|
220
|
-
end
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
end
|
|
225
|
-
end
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module List
|
|
7
|
-
def self.bullet(element, context:)
|
|
8
|
-
attrs = list_attrs(element)
|
|
9
|
-
items = extract_items(element, context:)
|
|
10
|
-
|
|
11
|
-
Handlers.build_node("bullet_list", attrs: attrs, content: items)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.ordered(element, context:)
|
|
15
|
-
attrs = list_attrs(element)
|
|
16
|
-
attrs[:type] = SafeAttr.read(element, :type)
|
|
17
|
-
attrs[:start] = SafeAttr.read(element, :start)
|
|
18
|
-
attrs[:group] = SafeAttr.read(element, :group)
|
|
19
|
-
items = extract_items(element, context:)
|
|
20
|
-
|
|
21
|
-
Handlers.build_node("ordered_list", attrs: attrs.compact,
|
|
22
|
-
content: items)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.definition(element, context:)
|
|
26
|
-
attrs = list_attrs(element)
|
|
27
|
-
attrs[:key] = SafeAttr.read(element, :key)
|
|
28
|
-
items = extract_definition_items(element, context:)
|
|
29
|
-
|
|
30
|
-
Handlers.build_node("dl", attrs: attrs.compact, content: items)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.list_item(element, context:)
|
|
34
|
-
attrs = {}
|
|
35
|
-
attrs[:id] = SafeAttr.read(element, :id)
|
|
36
|
-
attrs[:checkbox] = SafeAttr.read(element, :checkbox)
|
|
37
|
-
attrs[:checkedcheckbox] = SafeAttr.read(element, :checkedcheckbox)
|
|
38
|
-
|
|
39
|
-
content = []
|
|
40
|
-
text = SafeAttr.read(element, :text)
|
|
41
|
-
if text.is_a?(Array)
|
|
42
|
-
text.each do |t|
|
|
43
|
-
next if t.is_a?(String) && t.strip.empty?
|
|
44
|
-
|
|
45
|
-
content << context.text_node(t.to_s)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
%i[paragraphs unordered_lists ordered_lists sourcecode figure example
|
|
50
|
-
note quote table].each do |attr|
|
|
51
|
-
collection = SafeAttr.read(element, attr)
|
|
52
|
-
next unless collection
|
|
53
|
-
|
|
54
|
-
collection.each do |child|
|
|
55
|
-
result = context.registry.handle(child, context: context)
|
|
56
|
-
result.append_to(content)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
Handlers.build_node("list_item", attrs: attrs.compact,
|
|
61
|
-
content: content)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def self.extract_items(element, context:)
|
|
65
|
-
Array(element.listitem).filter_map do |li|
|
|
66
|
-
result = context.registry.handle(li, context: context)
|
|
67
|
-
result.nodes
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def self.extract_definition_items(element, context:)
|
|
72
|
-
items = []
|
|
73
|
-
dts = Array(element.dt)
|
|
74
|
-
dds = Array(element.dd)
|
|
75
|
-
|
|
76
|
-
dts.each_with_index do |dt, idx|
|
|
77
|
-
dt_attrs = {}
|
|
78
|
-
dt_attrs[:id] = SafeAttr.read(dt, :id)
|
|
79
|
-
dt_content = Inline.extract_inline(dt, context:)
|
|
80
|
-
items << Handlers.build_node("dt", attrs: dt_attrs.compact,
|
|
81
|
-
content: dt_content)
|
|
82
|
-
|
|
83
|
-
dd = dds[idx]
|
|
84
|
-
next unless dd
|
|
85
|
-
|
|
86
|
-
dd_attrs = {}
|
|
87
|
-
dd_attrs[:id] = SafeAttr.read(dd, :id)
|
|
88
|
-
dd_content = context.extract_named_collections(dd,
|
|
89
|
-
%i[p ul ol
|
|
90
|
-
sourcecode figure example note table formula quote dl])
|
|
91
|
-
items << Handlers.build_node("dd", attrs: dd_attrs.compact,
|
|
92
|
-
content: dd_content)
|
|
93
|
-
end
|
|
94
|
-
items
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
def self.list_attrs(element)
|
|
98
|
-
attrs = {}
|
|
99
|
-
attrs[:id] = SafeAttr.read(element, :id)
|
|
100
|
-
attrs[:nobullet] = SafeAttr.read(element, :nobullet)
|
|
101
|
-
attrs[:bare] = SafeAttr.read(element, :bare)
|
|
102
|
-
attrs[:spacing] = SafeAttr.read(element, :spacing)
|
|
103
|
-
attrs[:indent] = SafeAttr.read(element, :indent)
|
|
104
|
-
attrs[:semx_id] = SafeAttr.read(element, :semx_id)
|
|
105
|
-
attrs.compact
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Note
|
|
7
|
-
EXTRA = { type_attr: :type_attr, remove_in_rfc: nil }.freeze
|
|
8
|
-
|
|
9
|
-
def self.call(element, context:)
|
|
10
|
-
attrs = Handlers.extract_attrs(element, extra_attrs: EXTRA)
|
|
11
|
-
|
|
12
|
-
content = []
|
|
13
|
-
element_content = SafeAttr.read(element, :content)
|
|
14
|
-
if element_content.is_a?(Array)
|
|
15
|
-
element_content.each do |p|
|
|
16
|
-
result = context.registry.handle(p, context: context)
|
|
17
|
-
result.append_to(content)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Handlers.build_node("note", attrs: attrs, content: content)
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Paragraph
|
|
7
|
-
EXTRA = { alignment: nil, keep_with_next: nil,
|
|
8
|
-
keep_with_previous: nil }.freeze
|
|
9
|
-
|
|
10
|
-
def self.call(element, context:)
|
|
11
|
-
attrs = Handlers.extract_attrs(element, extra_attrs: EXTRA)
|
|
12
|
-
content = Inline.extract_inline(element, context:)
|
|
13
|
-
|
|
14
|
-
Handlers.build_node("paragraph", attrs: attrs, content: content)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Quote
|
|
7
|
-
def self.call(element, context:)
|
|
8
|
-
attrs = Handlers.extract_attrs(element)
|
|
9
|
-
content = context.extract_blocks(element)
|
|
10
|
-
|
|
11
|
-
Handlers.build_node("quote", attrs: attrs, content: content)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Review
|
|
7
|
-
EXTRA = { date: nil, from: nil, to: nil, reviewer: nil,
|
|
8
|
-
display: nil }.freeze
|
|
9
|
-
|
|
10
|
-
def self.call(element, context:)
|
|
11
|
-
attrs = Handlers.extract_attrs(element, extra_attrs: EXTRA)
|
|
12
|
-
content = context.extract_blocks(element)
|
|
13
|
-
|
|
14
|
-
Handlers.build_node("review", attrs: attrs, content: content)
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Metanorma
|
|
4
|
-
module Mirror
|
|
5
|
-
module Handlers
|
|
6
|
-
module Section
|
|
7
|
-
def self.clause(element, context:)
|
|
8
|
-
attrs = section_attrs(element, context:)
|
|
9
|
-
content = context.extract_blocks(element)
|
|
10
|
-
|
|
11
|
-
Handlers.build_node("clause", attrs: attrs, content: content)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.annex(element, context:)
|
|
15
|
-
attrs = section_attrs(element, context:)
|
|
16
|
-
attrs[:commentary] = SafeAttr.read(element, :commentary)
|
|
17
|
-
attrs[:language] = SafeAttr.read(element, :language)
|
|
18
|
-
attrs[:script] = SafeAttr.read(element, :script)
|
|
19
|
-
|
|
20
|
-
content = context.extract_blocks(element)
|
|
21
|
-
|
|
22
|
-
Handlers.build_node("annex", attrs: attrs.compact, content: content)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.content_section(element, context:)
|
|
26
|
-
attrs = section_attrs(element, context:)
|
|
27
|
-
content = context.extract_blocks(element)
|
|
28
|
-
|
|
29
|
-
subsection = SafeAttr.read(element, :subsection)
|
|
30
|
-
subsection&.each do |sub|
|
|
31
|
-
result = context.registry.handle(sub, context: context)
|
|
32
|
-
result.append_to(content)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
Handlers.build_node("content_section", attrs: attrs, content: content)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def self.terms(element, context:)
|
|
39
|
-
attrs = section_attrs(element, context:)
|
|
40
|
-
content = context.extract_named_collections(element,
|
|
41
|
-
%i[p term dl example
|
|
42
|
-
admonition])
|
|
43
|
-
children = context.extract_section_children(element)
|
|
44
|
-
|
|
45
|
-
Handlers.build_node("terms", attrs: attrs,
|
|
46
|
-
content: content + children)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def self.definitions(element, context:)
|
|
50
|
-
attrs = section_attrs(element, context:)
|
|
51
|
-
content = context.extract_blocks(element)
|
|
52
|
-
|
|
53
|
-
Handlers.build_node("definitions", attrs: attrs, content: content)
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def self.references(element, context:)
|
|
57
|
-
attrs = section_attrs(element, context:)
|
|
58
|
-
attrs[:normative] = SafeAttr.read(element, :normative)
|
|
59
|
-
attrs[:hidden] = SafeAttr.read(element, :hidden)
|
|
60
|
-
|
|
61
|
-
# Prefatory paragraphs (e.g. "The following documents are referred to...")
|
|
62
|
-
content = context.extract_named_collections(element,
|
|
63
|
-
%i[p])
|
|
64
|
-
|
|
65
|
-
# Bibliographic items
|
|
66
|
-
refs = SafeAttr.read(element, :references)
|
|
67
|
-
refs&.each do |ref|
|
|
68
|
-
text = extract_biblio_text(ref)
|
|
69
|
-
next if text.strip.empty?
|
|
70
|
-
|
|
71
|
-
content << Handlers.build_node("paragraph",
|
|
72
|
-
attrs: { id: SafeAttr.read(ref,
|
|
73
|
-
:id) }.compact,
|
|
74
|
-
content: [context.text_node(text)])
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
Handlers.build_node("references", attrs: attrs, content: content)
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def self.extract_biblio_text(ref)
|
|
81
|
-
parts = []
|
|
82
|
-
|
|
83
|
-
tag = SafeAttr.read(ref, :biblio_tag)
|
|
84
|
-
if tag
|
|
85
|
-
tag_text = Inline.extract_formatted_text(tag).strip
|
|
86
|
-
parts << tag_text unless tag_text.empty?
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
formatted = SafeAttr.read(ref, :formatted_ref)
|
|
90
|
-
if formatted
|
|
91
|
-
fmt_text = Inline.extract_formatted_text(formatted).strip
|
|
92
|
-
parts << fmt_text unless fmt_text.empty?
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
return parts.join(" ") unless parts.empty?
|
|
96
|
-
|
|
97
|
-
docid = SafeAttr.read(ref, :docidentifier)
|
|
98
|
-
if docid
|
|
99
|
-
text = Inline.extract_formatted_text(docid)
|
|
100
|
-
return text unless text.strip.empty?
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
""
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def self.floating_title(element, context:)
|
|
107
|
-
attrs = {}
|
|
108
|
-
attrs[:id] = context.id_strategy.assign_id(element)
|
|
109
|
-
attrs[:depth] = SafeAttr.read(element, :depth)
|
|
110
|
-
attrs[:semx_id] = SafeAttr.read(element, :semx_id)
|
|
111
|
-
|
|
112
|
-
title = extract_title(element)
|
|
113
|
-
attrs[:title] = title if title
|
|
114
|
-
|
|
115
|
-
Handlers.build_node("floating_title", attrs: attrs.compact)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def self.section_attrs(element, context:)
|
|
119
|
-
attrs = {}
|
|
120
|
-
attrs[:id] = context.id_strategy.assign_id(element)
|
|
121
|
-
attrs[:number] = SafeAttr.read(element, :number)
|
|
122
|
-
attrs[:obligation] = SafeAttr.read(element, :obligation)
|
|
123
|
-
attrs[:unnumbered] = SafeAttr.read(element, :unnumbered)
|
|
124
|
-
attrs[:toc] = SafeAttr.read(element, :toc)
|
|
125
|
-
attrs[:type] = SafeAttr.read(element, :type)
|
|
126
|
-
attrs[:semx_id] = SafeAttr.read(element, :semx_id)
|
|
127
|
-
attrs[:autonum] = SafeAttr.read(element, :autonum)
|
|
128
|
-
attrs[:displayorder] = SafeAttr.read(element, :displayorder)
|
|
129
|
-
|
|
130
|
-
title = extract_title(element)
|
|
131
|
-
attrs[:title] = title if title
|
|
132
|
-
attrs.compact
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
def self.extract_title(element)
|
|
136
|
-
title = SafeAttr.read(element, :title)
|
|
137
|
-
return nil unless title
|
|
138
|
-
|
|
139
|
-
case title
|
|
140
|
-
when String then title
|
|
141
|
-
else
|
|
142
|
-
rich = Inline.extract_rich_html(title)
|
|
143
|
-
rich.empty? ? Inline.extract_element_text(title) : rich
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
end
|