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
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module Metanorma
|
|
4
4
|
module Html
|
|
5
|
+
# Renders StandardDocument components to HTML.
|
|
6
|
+
# Extends BaseRenderer with terms, bibliography, and standard sections.
|
|
5
7
|
class StandardRenderer < BaseRenderer
|
|
6
8
|
register_render Metanorma::StandardDocument::Root,
|
|
7
9
|
:render_standard_document
|
|
@@ -29,32 +31,46 @@ module Metanorma
|
|
|
29
31
|
register_render Metanorma::StandardDocument::Blocks::AmendBlock,
|
|
30
32
|
:render_amend_block
|
|
31
33
|
|
|
34
|
+
# --- Top-level document rendering ---
|
|
35
|
+
|
|
32
36
|
def render_standard_document(doc, **_opts)
|
|
33
|
-
|
|
37
|
+
render_coverpage(doc)
|
|
38
|
+
|
|
39
|
+
@output << "<main class=\"main-section\">"
|
|
40
|
+
|
|
41
|
+
# Preface sections
|
|
42
|
+
render(doc.preface) if doc.preface
|
|
43
|
+
|
|
44
|
+
# Document title line
|
|
45
|
+
render_doc_title(doc)
|
|
46
|
+
|
|
47
|
+
# Main sections
|
|
48
|
+
render(doc.sections) if doc.sections
|
|
34
49
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
content_parts << (render_doc_title(doc) || "")
|
|
38
|
-
content_parts << (render(doc.sections) || "") if doc.sections
|
|
39
|
-
doc.annex&.each { |annex| content_parts << (render(annex) || "") }
|
|
40
|
-
content_parts << (render(doc.bibliography) || "") if doc.bibliography
|
|
50
|
+
# Annexes
|
|
51
|
+
doc.annex&.each { |annex| render(annex) }
|
|
41
52
|
|
|
53
|
+
# Bibliography
|
|
54
|
+
render(doc.bibliography) if doc.bibliography
|
|
55
|
+
|
|
56
|
+
# Index section (from collected index terms)
|
|
42
57
|
unless @index_term_collector.empty?
|
|
43
58
|
index_component = Component::IndexSection.new(self)
|
|
44
|
-
|
|
59
|
+
index_component.render(@index_term_collector)
|
|
45
60
|
end
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
# Index section from indexsect element (presentation XML)
|
|
63
|
+
render(doc.indexsect) if doc.indexsect
|
|
64
|
+
|
|
65
|
+
# Footnotes section
|
|
66
|
+
render_footnotes_section
|
|
49
67
|
|
|
50
|
-
|
|
51
|
-
"content" => content_parts.join,
|
|
52
|
-
})
|
|
68
|
+
@output << "</main>"
|
|
53
69
|
end
|
|
54
70
|
|
|
55
71
|
def render_coverpage(doc)
|
|
56
72
|
bibdata = doc.bibdata
|
|
57
|
-
return
|
|
73
|
+
return unless bibdata
|
|
58
74
|
|
|
59
75
|
cover_id = nil
|
|
60
76
|
bibdata.doc_identifier&.each do |di|
|
|
@@ -67,46 +83,63 @@ module Metanorma
|
|
|
67
83
|
break
|
|
68
84
|
end
|
|
69
85
|
|
|
70
|
-
title_text =
|
|
86
|
+
title_text = nil
|
|
87
|
+
if bibdata.is_a?(Metanorma::IsoDocument::Metadata::IsoBibliographicItem)
|
|
88
|
+
en_title = bibdata.title_for("en")
|
|
89
|
+
title_text = en_title.to_s if en_title
|
|
90
|
+
elsif bibdata.is_a?(Metanorma::Document::Components::BibData::BibData)
|
|
91
|
+
titles = bibdata.title
|
|
92
|
+
if titles && !titles.empty?
|
|
93
|
+
en_title = titles.find { |t| t.language == "en" }
|
|
94
|
+
title_text = extract_text_value(en_title) if en_title
|
|
95
|
+
end
|
|
96
|
+
end
|
|
71
97
|
|
|
72
|
-
render_liquid("_cover.html.liquid", {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
@output << render_liquid("_cover.html.liquid", {
|
|
99
|
+
"doc_id" => cover_id,
|
|
100
|
+
"title" => title_text,
|
|
101
|
+
})
|
|
76
102
|
end
|
|
77
103
|
|
|
78
104
|
def render_doc_title(doc)
|
|
79
105
|
bibdata = doc.bibdata
|
|
80
|
-
return
|
|
106
|
+
return unless bibdata
|
|
81
107
|
|
|
82
|
-
|
|
83
|
-
|
|
108
|
+
if bibdata.is_a?(Metanorma::IsoDocument::Metadata::IsoBibliographicItem)
|
|
109
|
+
en_title = bibdata.title_for("en")
|
|
110
|
+
return unless en_title
|
|
111
|
+
elsif bibdata.is_a?(Metanorma::Document::Components::BibData::BibData)
|
|
112
|
+
titles = bibdata.title
|
|
113
|
+
return unless titles && !titles.empty?
|
|
84
114
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
115
|
+
en_title = titles.find { |t| t.language == "en" }
|
|
116
|
+
return unless en_title
|
|
117
|
+
|
|
118
|
+
en_title = extract_text_value(en_title)
|
|
119
|
+
else
|
|
120
|
+
return
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
@output << render_liquid("_doc_title.html.liquid", {
|
|
124
|
+
"title" => en_title,
|
|
125
|
+
})
|
|
88
126
|
end
|
|
89
127
|
|
|
128
|
+
# --- Section rendering ---
|
|
129
|
+
|
|
90
130
|
def render_section(section, level: 1, title_class: nil,
|
|
91
|
-
|
|
131
|
+
with_subsections: false, with_terms: false)
|
|
92
132
|
attrs = element_attrs(id: safe_attr(section, :id))
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if with_terms
|
|
103
|
-
section.terms&.each { |term| parts << (render_term(term) || "") }
|
|
133
|
+
tag("div", attrs) do
|
|
134
|
+
if title_class
|
|
135
|
+
render_standard_title(section, level, default_class: title_class)
|
|
136
|
+
else
|
|
137
|
+
render_standard_title(section, level)
|
|
138
|
+
end
|
|
139
|
+
render_standard_section_blocks(section, level)
|
|
140
|
+
render_subsections(section, level) if with_subsections
|
|
141
|
+
section.terms&.each { |term| render_term(term) } if with_terms
|
|
104
142
|
end
|
|
105
|
-
render_liquid("_element.html.liquid", {
|
|
106
|
-
"tag" => "div",
|
|
107
|
-
"extra_attrs" => attrs,
|
|
108
|
-
"content" => parts.join,
|
|
109
|
-
})
|
|
110
143
|
end
|
|
111
144
|
|
|
112
145
|
def render_clause_section(section, level: 1, **)
|
|
@@ -141,94 +174,70 @@ module Metanorma
|
|
|
141
174
|
level = safe_attr(title_node, :level) || 1
|
|
142
175
|
h = "h#{[[level, 6].min, 1].max}"
|
|
143
176
|
attrs = element_attrs(id: safe_attr(title_node, :id))
|
|
144
|
-
|
|
145
|
-
"tag" => h,
|
|
146
|
-
"class_attr" => attrs,
|
|
147
|
-
"content" => escape_html(title_node.text.to_s),
|
|
148
|
-
})
|
|
177
|
+
@output << "<#{h}#{attrs}>#{escape_html(title_node.text.to_s)}</#{h}>"
|
|
149
178
|
end
|
|
150
179
|
|
|
151
180
|
def render_amend_block(amend, **_opts)
|
|
152
181
|
attrs = element_attrs(id: safe_attr(amend, :id))
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"extra_attrs" => attrs,
|
|
157
|
-
"content" => content,
|
|
158
|
-
})
|
|
182
|
+
tag("div", attrs) do
|
|
183
|
+
render_mixed_inline(amend)
|
|
184
|
+
end
|
|
159
185
|
end
|
|
160
186
|
|
|
161
187
|
# --- Term rendering ---
|
|
162
188
|
|
|
163
189
|
def render_term(term, **_opts)
|
|
164
190
|
attrs = element_attrs(id: safe_attr(term, :id))
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
safe_attr(term.domain, :text).to_s
|
|
181
|
-
end
|
|
182
|
-
unless domain_text.to_s.empty?
|
|
183
|
-
parts << render_liquid("_term_domain.html.liquid", {
|
|
184
|
-
"text" => escape_html(domain_text),
|
|
185
|
-
}).to_s
|
|
191
|
+
tag("div", attrs) do
|
|
192
|
+
term.preferred&.each { |d| render_term_designation(d, "preferred") }
|
|
193
|
+
term.admitted&.each { |d| render_term_designation(d, "admitted") }
|
|
194
|
+
term.deprecates&.each { |d| render_term_designation(d, "deprecated") }
|
|
195
|
+
|
|
196
|
+
# Domain
|
|
197
|
+
if term.domain
|
|
198
|
+
domain_text = if term.domain.is_a?(String)
|
|
199
|
+
term.domain
|
|
200
|
+
else
|
|
201
|
+
safe_attr(
|
|
202
|
+
term.domain, :text
|
|
203
|
+
).to_s
|
|
204
|
+
end
|
|
205
|
+
@output << "<p class=\"term-domain\"><#{escape_html(domain_text)}></p>" unless domain_text.to_s.empty?
|
|
186
206
|
end
|
|
187
|
-
end
|
|
188
207
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
208
|
+
# Definitions
|
|
209
|
+
if term.definition
|
|
210
|
+
Array(term.definition).each do |defn|
|
|
211
|
+
render_term_definition(defn)
|
|
212
|
+
end
|
|
192
213
|
end
|
|
193
|
-
end
|
|
194
214
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
else
|
|
203
|
-
parts << (render_note(note) || "")
|
|
215
|
+
# Notes (mapped from <termnote>)
|
|
216
|
+
term.note&.each_with_index do |note, i|
|
|
217
|
+
if note.is_a?(String)
|
|
218
|
+
@output << "<div class=\"note-block\"><p><span class=\"term-note-label\">Note #{i + 1} to entry: </span>#{escape_html(note)}</p></div>"
|
|
219
|
+
else
|
|
220
|
+
render_note(note)
|
|
221
|
+
end
|
|
204
222
|
end
|
|
205
|
-
end
|
|
206
223
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
})
|
|
224
|
+
# Examples (mapped from <termexample>)
|
|
225
|
+
term.example&.each { |ex| render_paragraph(ex) }
|
|
226
|
+
|
|
227
|
+
# Source references
|
|
228
|
+
term.source&.each { |src| render_term_source(src) }
|
|
229
|
+
end
|
|
214
230
|
end
|
|
215
231
|
|
|
216
232
|
def render_term_designation(designation, _type)
|
|
217
233
|
name = extract_designation_name(designation)
|
|
218
|
-
return
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
{ "tag" => "b", "extra_attrs" => "",
|
|
226
|
-
"content" => dfn })
|
|
227
|
-
render_liquid("_element.html.liquid", {
|
|
228
|
-
"tag" => "p",
|
|
229
|
-
"extra_attrs" => " class=\"term-name\" style=\"text-align:left;\"",
|
|
230
|
-
"content" => bold,
|
|
231
|
-
})
|
|
234
|
+
return unless name
|
|
235
|
+
|
|
236
|
+
tag("p", " class=\"term-name\" style=\"text-align:left;\"") do
|
|
237
|
+
tag("b") do
|
|
238
|
+
tag("dfn") { @output << escape_html(name) }
|
|
239
|
+
end
|
|
240
|
+
end
|
|
232
241
|
end
|
|
233
242
|
|
|
234
243
|
def extract_designation_name(designation)
|
|
@@ -245,222 +254,143 @@ module Metanorma
|
|
|
245
254
|
end
|
|
246
255
|
|
|
247
256
|
def render_term_definition(definition)
|
|
248
|
-
return
|
|
249
|
-
return
|
|
257
|
+
return unless definition
|
|
258
|
+
return unless definition.is_a?(Metanorma::StandardDocument::Terms::TermDefinition)
|
|
250
259
|
|
|
251
260
|
ve = definition.verbalexpression
|
|
252
|
-
return
|
|
261
|
+
return unless ve
|
|
253
262
|
|
|
254
|
-
|
|
255
|
-
ve.paragraph&.each { |para| parts << (render_paragraph(para) || "") }
|
|
256
|
-
parts.join
|
|
263
|
+
ve.paragraph&.each { |para| render_paragraph(para) }
|
|
257
264
|
end
|
|
258
265
|
|
|
259
266
|
def render_term_note(note)
|
|
260
267
|
attrs = element_attrs(id: safe_attr(note, :id), class: "note-block")
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
tag("div", attrs) do
|
|
269
|
+
label = extract_termnote_label(note)
|
|
270
|
+
@output << "<p><span class=\"term-note-label\">#{escape_html(label)}: </span>"
|
|
271
|
+
note.p&.each { |para| render_mixed_inline(para) }
|
|
272
|
+
@output << "</p>"
|
|
273
|
+
note.ul&.each { |ul| render_unordered_list(ul) }
|
|
274
|
+
note.ol&.each { |ol| render_ordered_list(ol) }
|
|
275
|
+
note.dl&.then { |dl| render_definition_list(dl) }
|
|
266
276
|
end
|
|
267
|
-
note_content = note_content_parts.join
|
|
268
|
-
parts << render_liquid("_term_note.html.liquid", {
|
|
269
|
-
"label" => escape_html(label),
|
|
270
|
-
"content" => note_content,
|
|
271
|
-
})
|
|
272
|
-
note.ul&.each { |ul| parts << (render_unordered_list(ul) || "") }
|
|
273
|
-
note.ol&.each { |ol| parts << (render_ordered_list(ol) || "") }
|
|
274
|
-
note.dl&.then { |dl| parts << (render_definition_list(dl) || "") }
|
|
275
|
-
render_liquid("_element.html.liquid", {
|
|
276
|
-
"tag" => "div",
|
|
277
|
-
"extra_attrs" => attrs,
|
|
278
|
-
"content" => parts.join,
|
|
279
|
-
})
|
|
280
277
|
end
|
|
281
278
|
|
|
282
279
|
def render_term_example(example)
|
|
283
280
|
attrs = element_attrs(id: safe_attr(example, :id), class: "example")
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
281
|
+
tag("div", attrs) do
|
|
282
|
+
label = extract_block_label(example, "EXAMPLE")
|
|
283
|
+
@output << "<p><span class=\"example-label\">#{escape_html(label)}</span> "
|
|
284
|
+
example.p&.each { |para| render_mixed_inline(para) }
|
|
285
|
+
@output << "</p>"
|
|
286
|
+
example.ul&.each { |ul| render_unordered_list(ul) }
|
|
287
|
+
example.ol&.each { |ol| render_ordered_list(ol) }
|
|
288
|
+
example.dl&.then { |dl| render_definition_list(dl) }
|
|
289
289
|
end
|
|
290
|
-
ex_content = ex_content_parts.join
|
|
291
|
-
parts << render_liquid("_term_example.html.liquid", {
|
|
292
|
-
"label" => escape_html(label),
|
|
293
|
-
"content" => ex_content,
|
|
294
|
-
})
|
|
295
|
-
example.ul&.each { |ul| parts << (render_unordered_list(ul) || "") }
|
|
296
|
-
example.ol&.each { |ol| parts << (render_ordered_list(ol) || "") }
|
|
297
|
-
example.dl&.then { |dl| parts << (render_definition_list(dl) || "") }
|
|
298
|
-
render_liquid("_element.html.liquid", {
|
|
299
|
-
"tag" => "div",
|
|
300
|
-
"extra_attrs" => attrs,
|
|
301
|
-
"content" => parts.join,
|
|
302
|
-
})
|
|
303
290
|
end
|
|
304
291
|
|
|
305
292
|
def render_term_source(source)
|
|
306
|
-
return
|
|
293
|
+
return unless source
|
|
307
294
|
|
|
308
|
-
|
|
295
|
+
@output << "<p class=\"term-source\">[SOURCE: "
|
|
309
296
|
termsource = safe_attr(source, :termsource)
|
|
310
297
|
origin = safe_attr(source, :origin)
|
|
311
298
|
|
|
312
299
|
if termsource
|
|
313
|
-
|
|
300
|
+
render_mixed_inline(termsource)
|
|
314
301
|
elsif origin
|
|
315
302
|
citeas = safe_attr(origin, :citeas)
|
|
316
303
|
bibitemid = safe_attr(origin, :bibitemid)
|
|
317
304
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
escape_html(citeas.to_s)
|
|
328
|
-
end
|
|
329
|
-
else
|
|
330
|
-
render_mixed_inline(origin) || ""
|
|
331
|
-
end
|
|
305
|
+
if citeas && !citeas.to_s.empty?
|
|
306
|
+
@output << if bibitemid && !bibitemid.to_s.empty?
|
|
307
|
+
"<a href=\"##{escape_html(bibitemid.to_s)}\" class=\"bibref\">#{escape_html(citeas.to_s)}</a>"
|
|
308
|
+
else
|
|
309
|
+
escape_html(citeas.to_s)
|
|
310
|
+
end
|
|
311
|
+
else
|
|
312
|
+
render_mixed_inline(origin)
|
|
313
|
+
end
|
|
332
314
|
|
|
333
315
|
modification = safe_attr(source, :modification)
|
|
334
316
|
if modification && !modification.to_s.empty?
|
|
335
|
-
|
|
317
|
+
@output << ", modified — #{escape_html(modification.to_s)}"
|
|
336
318
|
end
|
|
337
319
|
else
|
|
338
|
-
|
|
320
|
+
render_mixed_inline(source)
|
|
339
321
|
end
|
|
340
|
-
|
|
341
|
-
render_liquid("_term_source.html.liquid", {
|
|
342
|
-
"content" => parts.join,
|
|
343
|
-
})
|
|
322
|
+
@output << "]</p>"
|
|
344
323
|
end
|
|
345
324
|
|
|
346
325
|
def render_term_source_element(element)
|
|
347
|
-
return
|
|
326
|
+
return unless element
|
|
348
327
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
"content" => content,
|
|
353
|
-
})
|
|
328
|
+
@output << "<p>"
|
|
329
|
+
render_mixed_inline(element)
|
|
330
|
+
@output << "</p>"
|
|
354
331
|
end
|
|
355
332
|
|
|
356
333
|
# --- Bibliography / References ---
|
|
357
334
|
|
|
358
335
|
def render_bibliography(bib, level: 1, **_opts)
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
336
|
+
tag("div", "") do
|
|
337
|
+
bib.references&.each do |ref|
|
|
338
|
+
render_references_section(ref, level: level)
|
|
339
|
+
end
|
|
340
|
+
bib.clause&.each { |cl| render(cl, level: level) }
|
|
362
341
|
end
|
|
363
|
-
bib.clause&.each { |cl| parts << (render(cl, level: level) || "") }
|
|
364
|
-
render_liquid("_element.html.liquid", {
|
|
365
|
-
"tag" => "div",
|
|
366
|
-
"extra_attrs" => "",
|
|
367
|
-
"content" => parts.join,
|
|
368
|
-
})
|
|
369
342
|
end
|
|
370
343
|
|
|
371
344
|
def render_references_section(section, level: 1, **_opts)
|
|
372
345
|
is_normative = safe_attr(section, :normative) == "true"
|
|
373
346
|
attrs = element_attrs(id: safe_attr(section, :id))
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
347
|
+
tag("div", attrs) do
|
|
348
|
+
render_standard_title(section, level,
|
|
349
|
+
default_class: is_normative ? "" : "section-sub")
|
|
350
|
+
section.p&.each { |para| render_paragraph(para) }
|
|
351
|
+
section.note&.each { |note| render_paragraph(note) }
|
|
352
|
+
section.references&.each_with_index do |bibitem, i|
|
|
353
|
+
render_bibitem(bibitem, i + 1, normative: is_normative)
|
|
354
|
+
end
|
|
355
|
+
section.table&.each { |t| render_table(t) }
|
|
382
356
|
end
|
|
383
|
-
section.table&.each { |t| parts << (render_table(t) || "") }
|
|
384
|
-
render_liquid("_element.html.liquid", {
|
|
385
|
-
"tag" => "div",
|
|
386
|
-
"extra_attrs" => attrs,
|
|
387
|
-
"content" => parts.join,
|
|
388
|
-
})
|
|
389
357
|
end
|
|
390
358
|
|
|
391
359
|
def render_bibitem(item, index, normative: false)
|
|
392
360
|
css_class = normative ? "norm-ref-entry" : "biblio-entry"
|
|
393
|
-
|
|
361
|
+
attrs = element_attrs(id: safe_attr(item, :id), class: css_class)
|
|
394
362
|
url = bibitem_url(item)
|
|
395
363
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
render_inline_element(child)
|
|
401
|
-
end&.join
|
|
402
|
-
else
|
|
403
|
-
ordinal_html = "[#{index}]"
|
|
404
|
-
pubid_html = nil
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
content_html = render_bibitem_content(item)
|
|
408
|
-
|
|
409
|
-
drop = Drops::BiblioEntryDrop.new(
|
|
410
|
-
id: item_id,
|
|
411
|
-
css_class: css_class,
|
|
412
|
-
ordinal_html: ordinal_html,
|
|
413
|
-
pubid_html: pubid_html,
|
|
414
|
-
url: url ? escape_html(url) : nil,
|
|
415
|
-
content_html: content_html,
|
|
416
|
-
)
|
|
417
|
-
render_liquid("_biblio_entry.html.liquid", { "entry" => drop })
|
|
418
|
-
end
|
|
364
|
+
tag("p", attrs) do
|
|
365
|
+
if url
|
|
366
|
+
@output << "<a href=\"#{escape_html(url)}\" target=\"_blank\" rel=\"noopener\" class=\"biblio-link\">"
|
|
367
|
+
end
|
|
419
368
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
369
|
+
# Use biblio-tag from presentation XML if available
|
|
370
|
+
if item.biblio_tag
|
|
371
|
+
render_mixed_inline(item.biblio_tag)
|
|
372
|
+
@output << " "
|
|
373
|
+
else
|
|
374
|
+
@output << "[#{index}] "
|
|
375
|
+
end
|
|
423
376
|
|
|
424
|
-
|
|
425
|
-
rest = []
|
|
426
|
-
found_boundary = false
|
|
377
|
+
render_bibitem_content(item)
|
|
427
378
|
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
rest << child
|
|
431
|
-
else
|
|
432
|
-
case child
|
|
433
|
-
when Metanorma::Document::Components::Inline::TabElement
|
|
434
|
-
found_boundary = true
|
|
435
|
-
next
|
|
436
|
-
when String
|
|
437
|
-
stripped = child.strip
|
|
438
|
-
if stripped.match?(/\A\[\d+\]\z/)
|
|
439
|
-
prefix << child
|
|
440
|
-
elsif child.match?(/\A\s*\z/)
|
|
441
|
-
prefix << child
|
|
442
|
-
else
|
|
443
|
-
found_boundary = true
|
|
444
|
-
rest << child
|
|
445
|
-
end
|
|
446
|
-
else
|
|
447
|
-
found_boundary = true
|
|
448
|
-
rest << child
|
|
449
|
-
end
|
|
379
|
+
if url
|
|
380
|
+
@output << "</a>"
|
|
450
381
|
end
|
|
451
382
|
end
|
|
452
|
-
|
|
453
|
-
prefix_text = prefix.strip
|
|
454
|
-
[prefix_text, rest.empty? ? nil : rest]
|
|
455
383
|
end
|
|
456
384
|
|
|
457
385
|
def bibitem_url(item)
|
|
458
386
|
links = Array(item.link)
|
|
459
387
|
return nil if links.empty?
|
|
460
388
|
|
|
389
|
+
# Prefer src or citation type, skip RSS feeds
|
|
461
390
|
preferred = links.find { |l| ["src", "citation"].include?(l.type) }
|
|
462
391
|
return preferred.content.to_s if preferred && !preferred.content.to_s.empty?
|
|
463
392
|
|
|
393
|
+
# Fallback: first non-RSS link
|
|
464
394
|
non_rss = links.find do |l|
|
|
465
395
|
!l.content.to_s.include?(".rss") && !l.content.to_s.empty?
|
|
466
396
|
end
|
|
@@ -468,15 +398,25 @@ module Metanorma
|
|
|
468
398
|
end
|
|
469
399
|
|
|
470
400
|
def render_bibitem_content(item)
|
|
471
|
-
|
|
401
|
+
# Use formatted reference if available (presentation XML)
|
|
472
402
|
if item.formatted_ref
|
|
473
|
-
|
|
474
|
-
return
|
|
403
|
+
render_mixed_inline(item.formatted_ref)
|
|
404
|
+
return
|
|
475
405
|
end
|
|
476
406
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
407
|
+
# Fallback: construct from parts
|
|
408
|
+
if item.docidentifier && !item.docidentifier.empty?
|
|
409
|
+
docids = Array(item.docidentifier)
|
|
410
|
+
# Skip bracket-number identifiers (e.g. "[1]") and iso-reference/URN variants;
|
|
411
|
+
# render only the primary doc identifier
|
|
412
|
+
primary = docids.find do |di|
|
|
413
|
+
val = extract_text_value(di).to_s
|
|
414
|
+
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:iso-reference|URN)\s/)
|
|
415
|
+
end
|
|
416
|
+
if primary
|
|
417
|
+
id_val = extract_text_value(primary)
|
|
418
|
+
@output << "<span class=\"ref-doc-number\">#{escape_html(id_val)}</span>" unless id_val.to_s.empty?
|
|
419
|
+
end
|
|
480
420
|
end
|
|
481
421
|
|
|
482
422
|
if item.date && !item.date.empty?
|
|
@@ -484,10 +424,7 @@ module Metanorma
|
|
|
484
424
|
date_on = date.is_a?(Metanorma::Document::Relaton::BibliographicDate) ? date.on : nil
|
|
485
425
|
date_val = extract_text_value(date_on || safe_attr(date, :text))
|
|
486
426
|
if date_val && !date_val.to_s.empty?
|
|
487
|
-
|
|
488
|
-
"prefix" => ":",
|
|
489
|
-
"year" => escape_html(date_val.to_s),
|
|
490
|
-
})
|
|
427
|
+
@output << ":<span class=\"ref-year\">#{escape_html(date_val.to_s)}</span>"
|
|
491
428
|
end
|
|
492
429
|
end
|
|
493
430
|
end
|
|
@@ -498,51 +435,11 @@ module Metanorma
|
|
|
498
435
|
safe_attr(t, :type) == "main"
|
|
499
436
|
end || titles.first
|
|
500
437
|
if main_title
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
})
|
|
438
|
+
@output << ", <i>"
|
|
439
|
+
render_mixed_inline(main_title)
|
|
440
|
+
@output << "</i>"
|
|
505
441
|
end
|
|
506
442
|
end
|
|
507
|
-
parts.join
|
|
508
|
-
end
|
|
509
|
-
|
|
510
|
-
def render_pubid_identifier(item)
|
|
511
|
-
return nil unless item.docidentifier && !item.docidentifier.empty?
|
|
512
|
-
|
|
513
|
-
docids = Array(item.docidentifier)
|
|
514
|
-
primary = docids.find do |di|
|
|
515
|
-
val = extract_text_value(di).to_s
|
|
516
|
-
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:iso-reference|URN)\s/)
|
|
517
|
-
end
|
|
518
|
-
return nil unless primary
|
|
519
|
-
|
|
520
|
-
id_string = extract_text_value(primary).to_s
|
|
521
|
-
return nil if id_string.empty?
|
|
522
|
-
|
|
523
|
-
identifier = parse_pubid(id_string)
|
|
524
|
-
return nil unless identifier
|
|
525
|
-
|
|
526
|
-
pubid_to_html(identifier)
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
def render_docidentifier_fallback_into(parts, item)
|
|
530
|
-
return unless item.docidentifier && !item.docidentifier.empty?
|
|
531
|
-
|
|
532
|
-
docids = Array(item.docidentifier)
|
|
533
|
-
primary = docids.find do |di|
|
|
534
|
-
val = extract_text_value(di).to_s
|
|
535
|
-
val.match?(/\A\[?\d+\]?\z/) ? false : !val.match?(/\A(?:iso-reference|URN)\s/)
|
|
536
|
-
end
|
|
537
|
-
return unless primary
|
|
538
|
-
|
|
539
|
-
id_val = extract_text_value(primary)
|
|
540
|
-
unless id_val.to_s.empty?
|
|
541
|
-
parts << render_liquid("_inline_span.html.liquid", {
|
|
542
|
-
"attrs" => " class=\"ref-doc-number\"",
|
|
543
|
-
"content" => escape_html(id_val),
|
|
544
|
-
})
|
|
545
|
-
end
|
|
546
443
|
end
|
|
547
444
|
|
|
548
445
|
# --- Standard section helpers ---
|
|
@@ -550,10 +447,9 @@ module Metanorma
|
|
|
550
447
|
def render_standard_title(section, level, default_class: "")
|
|
551
448
|
title_element = safe_attr(section,
|
|
552
449
|
:fmt_title) || safe_attr(section, :title)
|
|
553
|
-
return
|
|
450
|
+
return unless title_element
|
|
554
451
|
|
|
555
452
|
section_id = safe_attr(section, :id)
|
|
556
|
-
title_content = render_mixed_inline(title_element)
|
|
557
453
|
title_text = extract_plain_text(title_element)
|
|
558
454
|
register_toc_entry(id: section_id, level: level, text: title_text)
|
|
559
455
|
|
|
@@ -562,67 +458,58 @@ module Metanorma
|
|
|
562
458
|
|
|
563
459
|
h = "h#{[[level, 6].min, 1].max}"
|
|
564
460
|
title_class = default_class.empty? ? "" : " class=\"#{default_class}\""
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
"content" => title_content,
|
|
569
|
-
})
|
|
461
|
+
@output << "<#{h}#{title_class}>"
|
|
462
|
+
render_mixed_inline(title_element)
|
|
463
|
+
@output << "</#{h}>"
|
|
570
464
|
end
|
|
571
465
|
|
|
572
466
|
def render_standard_section_blocks(section, level)
|
|
573
467
|
if section.is_a?(Lutaml::Model::Serializable) && section.mixed?
|
|
574
|
-
parts = []
|
|
575
468
|
section.each_mixed_content do |node|
|
|
576
469
|
next if node.is_a?(String)
|
|
577
470
|
next if is_title_element?(node, section)
|
|
578
471
|
|
|
579
|
-
|
|
472
|
+
render(node, level: level + 1)
|
|
580
473
|
end
|
|
581
|
-
parts.join
|
|
582
474
|
else
|
|
583
475
|
render_section_block_collections(section, level)
|
|
584
476
|
end
|
|
585
477
|
end
|
|
586
478
|
|
|
587
479
|
def render_section_block_collections(section, level)
|
|
588
|
-
|
|
480
|
+
# Paragraphs
|
|
589
481
|
paragraphs = safe_attr(section, :paragraphs) || safe_attr(section, :p)
|
|
590
|
-
if paragraphs
|
|
591
|
-
Array(paragraphs).each do |p|
|
|
592
|
-
parts << (render_paragraph(p) || "")
|
|
593
|
-
end
|
|
594
|
-
end
|
|
482
|
+
Array(paragraphs).each { |p| render_paragraph(p) } if paragraphs
|
|
595
483
|
|
|
484
|
+
# Lists
|
|
596
485
|
%i[unordered_lists ordered_lists definition_lists].each do |attr|
|
|
597
486
|
values = safe_attr(section, attr)
|
|
598
|
-
if values
|
|
599
|
-
Array(values).each do |v|
|
|
600
|
-
parts << (render(v, level: level + 1) || "")
|
|
601
|
-
end
|
|
602
|
-
end
|
|
487
|
+
Array(values).each { |v| render(v, level: level + 1) } if values
|
|
603
488
|
end
|
|
604
489
|
|
|
490
|
+
# Block elements
|
|
605
491
|
%i[tables figures formulas examples notes admonitions sourcecode_blocks
|
|
606
492
|
quote_blocks].each do |attr|
|
|
607
493
|
values = safe_attr(section, attr)
|
|
608
|
-
if values
|
|
609
|
-
Array(values).each do |v|
|
|
610
|
-
parts << (render(v, level: level + 1) || "")
|
|
611
|
-
end
|
|
612
|
-
end
|
|
494
|
+
Array(values).each { |v| render(v, level: level + 1) } if values
|
|
613
495
|
end
|
|
614
|
-
parts.join
|
|
615
496
|
end
|
|
616
497
|
|
|
617
498
|
def render_subsections(section, level)
|
|
618
499
|
clauses = safe_attr(section,
|
|
619
500
|
:clause) || safe_attr(section, :subsections)
|
|
620
|
-
|
|
501
|
+
Array(clauses).each { |cl| render(cl, level: level + 1) } if clauses
|
|
502
|
+
end
|
|
503
|
+
|
|
504
|
+
def is_title_element?(node, section)
|
|
505
|
+
title = safe_attr(section, :title)
|
|
506
|
+
return false unless title
|
|
621
507
|
|
|
622
|
-
|
|
508
|
+
node.equal?(title)
|
|
623
509
|
end
|
|
624
510
|
|
|
625
511
|
def extract_termnote_label(note)
|
|
512
|
+
# Presentation XML: <name>Note 1 to entry</name>
|
|
626
513
|
names = safe_attr(note, :name)
|
|
627
514
|
if names && !names.empty?
|
|
628
515
|
name = names.is_a?(Array) ? names.first : names
|
|
@@ -630,6 +517,7 @@ module Metanorma
|
|
|
630
517
|
return text unless text.to_s.strip.empty?
|
|
631
518
|
end
|
|
632
519
|
|
|
520
|
+
# Fallback: autonum attribute
|
|
633
521
|
autonum = safe_attr(note, :autonum)
|
|
634
522
|
return "Note #{autonum} to entry" if autonum && !autonum.to_s.empty?
|
|
635
523
|
|