metanorma-document 0.2.6 → 0.2.8
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/.rubocop_todo.yml +41 -168
- data/Gemfile +2 -0
- data/lib/metanorma/basic_document/ancillary_blocks/figure_block.rb +3 -1
- data/lib/metanorma/basic_document/blocks/basic_block.rb +5 -1
- data/lib/metanorma/basic_document/blocks/note_block.rb +5 -0
- data/lib/metanorma/basic_document/blocks.rb +3 -24
- data/lib/metanorma/basic_document/lists/list.rb +2 -1
- data/lib/metanorma/basic_document/lists/list_item.rb +17 -0
- data/lib/metanorma/basic_document/lists.rb +1 -0
- data/lib/metanorma/basic_document/paragraphs/paragraph_with_footnote.rb +3 -1
- data/lib/metanorma/basic_document/reference_elements/callout.rb +1 -1
- data/lib/metanorma/basic_document/reference_elements/footnote.rb +1 -1
- data/lib/metanorma/basic_document/text_elements/mathml.rb +1 -1
- data/lib/metanorma/bipm_document/root.rb +10 -50
- data/lib/metanorma/bipm_document.rb +0 -2
- data/lib/metanorma/bsi_document/metadata/bsi_bib_data_extension_type.rb +10 -0
- data/lib/metanorma/bsi_document/metadata/bsi_bibliographic_item.rb +15 -0
- data/lib/metanorma/bsi_document/metadata.rb +12 -0
- data/lib/metanorma/bsi_document/root.rb +29 -0
- data/lib/metanorma/bsi_document/sections/bsi_annex_section.rb +25 -0
- data/lib/metanorma/bsi_document/sections/bsi_clause_section.rb +25 -0
- data/lib/metanorma/bsi_document/sections/bsi_sections.rb +27 -0
- data/lib/metanorma/bsi_document/sections.rb +11 -0
- data/lib/metanorma/bsi_document.rb +11 -0
- data/lib/metanorma/cc_document/root.rb +10 -50
- data/lib/metanorma/cc_document.rb +0 -2
- data/lib/metanorma/collection.rb +0 -2
- data/lib/metanorma/document/components/ancillary_blocks/example_block.rb +3 -3
- data/lib/metanorma/document/components/ancillary_blocks/figure_block.rb +2 -0
- data/lib/metanorma/document/components/ancillary_blocks/sourcecode_block.rb +2 -0
- data/lib/metanorma/document/components/blocks/passthrough.rb +21 -0
- data/lib/metanorma/document/components/blocks/requirement_model.rb +159 -0
- data/lib/metanorma/document/components/blocks.rb +10 -0
- data/lib/metanorma/document/components/contrib_metadata/contribution_element_metadata.rb +3 -1
- data/lib/metanorma/document/components/id_elements/image.rb +2 -0
- data/lib/metanorma/document/components/inline/xref_element.rb +8 -0
- data/lib/metanorma/document/components/lists/definition_list.rb +6 -0
- data/lib/metanorma/document/components/lists/list_item.rb +1 -1
- data/lib/metanorma/document/components/lists/ordered_list.rb +6 -0
- data/lib/metanorma/document/components/lists/unordered_list.rb +8 -0
- data/lib/metanorma/document/components/multi_paragraph/admonition_block.rb +8 -0
- data/lib/metanorma/document/components/multi_paragraph/review_block.rb +3 -0
- data/lib/metanorma/document/components/paragraphs/paragraph_block.rb +6 -2
- data/lib/metanorma/document/components/reference_elements/source_element.rb +57 -0
- data/lib/metanorma/document/components/reference_elements.rb +6 -0
- data/lib/metanorma/document/components/sections/references_section.rb +1 -1
- data/lib/metanorma/document/components/tables/table_block.rb +10 -0
- data/lib/metanorma/document/components/tables/table_cell.rb +2 -1
- data/lib/metanorma/document/data_types.rb +0 -4
- data/lib/metanorma/document/elements/add.rb +18 -0
- data/lib/metanorma/document/elements/del.rb +18 -0
- data/lib/metanorma/document/elements.rb +10 -0
- data/lib/metanorma/document/relaton/address.rb +16 -0
- data/lib/metanorma/document/root.rb +1 -3
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/document.rb +11 -2
- data/lib/metanorma/gb_document/metadata/gb_bib_data_extension_type.rb +10 -0
- data/lib/metanorma/gb_document/metadata/gb_bibliographic_item.rb +15 -0
- data/lib/metanorma/gb_document/metadata.rb +12 -0
- data/lib/metanorma/gb_document/root.rb +29 -0
- data/lib/metanorma/gb_document.rb +10 -0
- data/lib/metanorma/generic_document/root.rb +31 -0
- data/lib/metanorma/generic_document.rb +7 -0
- data/lib/metanorma/html/base_renderer.rb +206 -120
- data/lib/metanorma/html/bipm_renderer.rb +16 -8
- data/lib/metanorma/html/cc_renderer.rb +0 -1
- data/lib/metanorma/html/component/base.rb +5 -1
- data/lib/metanorma/html/component/footnote_collector.rb +3 -3
- data/lib/metanorma/html/component/index_section.rb +27 -9
- data/lib/metanorma/html/component/index_term_collector.rb +8 -3
- data/lib/metanorma/html/component.rb +2 -1
- data/lib/metanorma/html/drops/figure_drop.rb +14 -5
- data/lib/metanorma/html/drops/formula_drop.rb +7 -2
- data/lib/metanorma/html/drops/sourcecode_drop.rb +6 -2
- data/lib/metanorma/html/drops.rb +2 -1
- data/lib/metanorma/html/generator.rb +16 -6
- data/lib/metanorma/html/iec_renderer.rb +0 -1
- data/lib/metanorma/html/ieee_renderer.rb +0 -1
- data/lib/metanorma/html/ietf_renderer.rb +0 -1
- data/lib/metanorma/html/iho_renderer.rb +1 -2
- data/lib/metanorma/html/iso_renderer.rb +68 -23
- data/lib/metanorma/html/itu_renderer.rb +0 -1
- data/lib/metanorma/html/ogc_renderer.rb +0 -1
- data/lib/metanorma/html/oiml_renderer.rb +0 -1
- data/lib/metanorma/html/pdfa_renderer.rb +0 -1
- data/lib/metanorma/html/ribose_renderer.rb +0 -1
- data/lib/metanorma/html/standard_renderer.rb +61 -28
- data/lib/metanorma/html/theme.rb +2 -2
- data/lib/metanorma/html.rb +48 -1
- data/lib/metanorma/iec_document/root.rb +8 -47
- data/lib/metanorma/iec_document.rb +2 -3
- data/lib/metanorma/ieee_document/root.rb +14 -50
- data/lib/metanorma/ieee_document/sections/ieee_sections.rb +31 -0
- data/lib/metanorma/ieee_document/sections.rb +9 -0
- data/lib/metanorma/ieee_document.rb +3 -3
- data/lib/metanorma/ietf_document/metadata/ietf_bib_data_extension_type.rb +0 -2
- data/lib/metanorma/ietf_document/metadata/ietf_bibliographic_item.rb +0 -2
- data/lib/metanorma/ietf_document/root.rb +14 -50
- data/lib/metanorma/ietf_document/sections/ietf_annex_section.rb +26 -0
- data/lib/metanorma/ietf_document/sections/ietf_clause_section.rb +26 -0
- data/lib/metanorma/ietf_document/sections/ietf_content_section.rb +25 -0
- data/lib/metanorma/ietf_document/sections/ietf_sections.rb +35 -0
- data/lib/metanorma/ietf_document/sections.rb +4 -23
- data/lib/metanorma/ietf_document.rb +4 -3
- data/lib/metanorma/iho_document/metadata/iho_bib_data_extension_type.rb +0 -2
- data/lib/metanorma/iho_document/root.rb +10 -50
- data/lib/metanorma/iho_document.rb +0 -3
- data/lib/metanorma/iso_document/annotation_container.rb +1 -10
- data/lib/metanorma/iso_document/boilerplate.rb +1 -11
- data/lib/metanorma/iso_document/metadata/iso_bibliographic_item.rb +2 -2
- data/lib/metanorma/iso_document/metadata/iso_localized_title.rb +4 -3
- data/lib/metanorma/iso_document/metadata/metanorma_extension.rb +1 -12
- data/lib/metanorma/iso_document/root.rb +7 -73
- data/lib/metanorma/iso_document/sections/colophon.rb +1 -16
- data/lib/metanorma/iso_document/sections/iso_annex_section.rb +11 -133
- data/lib/metanorma/iso_document/sections/iso_clause_section.rb +9 -166
- data/lib/metanorma/iso_document/sections/iso_foreword_section.rb +5 -90
- data/lib/metanorma/iso_document/sections/iso_preface.rb +15 -21
- data/lib/metanorma/iso_document/sections/iso_sections.rb +19 -29
- data/lib/metanorma/iso_document/sections/iso_terms_section.rb +9 -22
- data/lib/metanorma/iso_document/terms/term_expression.rb +2 -47
- data/lib/metanorma/iso_document/terms/term_origin.rb +2 -24
- data/lib/metanorma/iso_document/terms/term_source.rb +4 -32
- data/lib/metanorma/iso_document.rb +2 -2
- data/lib/metanorma/itu_document/root.rb +10 -50
- data/lib/metanorma/itu_document.rb +0 -2
- data/lib/metanorma/jis_document/metadata/jis_bib_data_extension_type.rb +10 -0
- data/lib/metanorma/jis_document/metadata/jis_bibliographic_item.rb +15 -0
- data/lib/metanorma/jis_document/metadata.rb +12 -0
- data/lib/metanorma/jis_document/root.rb +29 -0
- data/lib/metanorma/jis_document/sections/jis_annex_section.rb +20 -0
- data/lib/metanorma/jis_document/sections.rb +9 -0
- data/lib/metanorma/jis_document.rb +11 -0
- data/lib/metanorma/m3d_document/metadata/m3d_bib_data_extension_type.rb +10 -0
- data/lib/metanorma/m3d_document/metadata/m3d_bibliographic_item.rb +15 -0
- data/lib/metanorma/m3d_document/metadata.rb +12 -0
- data/lib/metanorma/m3d_document/root.rb +29 -0
- data/lib/metanorma/m3d_document.rb +10 -0
- data/lib/metanorma/nist_document/metadata/nist_bib_data_extension_type.rb +10 -0
- data/lib/metanorma/nist_document/metadata/nist_bibliographic_item.rb +15 -0
- data/lib/metanorma/nist_document/metadata.rb +12 -0
- data/lib/metanorma/nist_document/root.rb +29 -0
- data/lib/metanorma/nist_document/sections/errata.rb +16 -0
- data/lib/metanorma/nist_document/sections/errata_clause.rb +20 -0
- data/lib/metanorma/nist_document/sections/errata_row.rb +22 -0
- data/lib/metanorma/nist_document/sections/nist_preface.rb +30 -0
- data/lib/metanorma/nist_document/sections.rb +12 -0
- data/lib/metanorma/nist_document.rb +11 -0
- data/lib/metanorma/ogc_document/root.rb +10 -50
- data/lib/metanorma/ogc_document.rb +0 -2
- data/lib/metanorma/oiml_document/root.rb +8 -47
- data/lib/metanorma/oiml_document.rb +2 -3
- data/lib/metanorma/plateau_document/metadata/plateau_bibliographic_item.rb +13 -0
- data/lib/metanorma/plateau_document/metadata.rb +10 -0
- data/lib/metanorma/plateau_document/root.rb +29 -0
- data/lib/metanorma/plateau_document.rb +10 -0
- data/lib/metanorma/registers/setup.rb +162 -0
- data/lib/metanorma/registers.rb +7 -0
- data/lib/metanorma/ribose_document/root.rb +10 -52
- data/lib/metanorma/ribose_document.rb +0 -2
- data/lib/metanorma/standard_document/annotation_container.rb +14 -0
- data/lib/metanorma/standard_document/block_attributes.rb +268 -0
- data/lib/metanorma/standard_document/blocks/passthrough.rb +1 -18
- data/lib/metanorma/standard_document/blocks/requirement_model.rb +18 -163
- data/lib/metanorma/standard_document/boilerplate.rb +14 -0
- data/lib/metanorma/standard_document/elements/add.rb +1 -17
- data/lib/metanorma/standard_document/elements/del.rb +1 -17
- data/lib/metanorma/standard_document/metadata/metanorma_extension.rb +16 -0
- data/lib/metanorma/standard_document/metadata.rb +2 -0
- data/lib/metanorma/standard_document/refs/reference_to_term.rb +2 -1
- data/lib/metanorma/standard_document/root_attributes.rb +78 -0
- data/lib/metanorma/standard_document/sections/abstract.rb +1 -3
- data/lib/metanorma/standard_document/sections/acknowledgements.rb +1 -3
- data/lib/metanorma/standard_document/sections/annex_section.rb +56 -19
- data/lib/metanorma/standard_document/sections/bibliography_section.rb +1 -2
- data/lib/metanorma/standard_document/sections/clause_section.rb +75 -13
- data/lib/metanorma/standard_document/sections/colophon.rb +16 -0
- data/lib/metanorma/standard_document/sections/definition_section.rb +43 -46
- data/lib/metanorma/standard_document/sections/floating_section_title.rb +23 -0
- data/lib/metanorma/standard_document/sections/foreword.rb +1 -3
- data/lib/metanorma/standard_document/sections/introduction.rb +1 -4
- data/lib/metanorma/standard_document/sections/misc_container.rb +5 -2
- data/lib/metanorma/standard_document/sections/preface.rb +36 -0
- data/lib/metanorma/standard_document/sections/sections.rb +40 -0
- data/lib/metanorma/standard_document/sections/standard_content_section.rb +26 -12
- data/lib/metanorma/standard_document/sections/terms_section.rb +45 -13
- data/lib/metanorma/standard_document/sections.rb +6 -2
- data/lib/metanorma/standard_document/terms/designation.rb +1 -1
- data/lib/metanorma/standard_document/terms/term_expression.rb +51 -0
- data/lib/metanorma/standard_document/terms.rb +1 -0
- data/lib/metanorma/standard_document.rb +10 -2
- data/lib/metanorma/un_document/metadata/un_bib_data_extension_type.rb +10 -0
- data/lib/metanorma/un_document/metadata/un_bibliographic_item.rb +15 -0
- data/lib/metanorma/un_document/metadata.rb +12 -0
- data/lib/metanorma/un_document/root.rb +29 -0
- data/lib/metanorma/un_document/sections/un_preface.rb +23 -0
- data/lib/metanorma/un_document/sections/un_sections.rb +24 -0
- data/lib/metanorma/un_document/sections.rb +10 -0
- data/lib/metanorma/un_document.rb +11 -0
- metadata +77 -3
- data/lib/metanorma/html/whitespace_patch.rb +0 -47
|
@@ -3,14 +3,9 @@
|
|
|
3
3
|
require "liquid"
|
|
4
4
|
require "nokogiri"
|
|
5
5
|
require "cgi"
|
|
6
|
-
require_relative "drops/footnote_drop"
|
|
7
6
|
|
|
8
7
|
module Metanorma
|
|
9
8
|
module Html
|
|
10
|
-
TEMPLATES_ROOT = File.join(__dir__, "templates")
|
|
11
|
-
|
|
12
|
-
Liquid::Environment.default.file_system = Liquid::LocalFileSystem.new(TEMPLATES_ROOT, "_%s.html.liquid")
|
|
13
|
-
|
|
14
9
|
# Renders BasicDocument components to HTML.
|
|
15
10
|
# Subclassed by StandardRenderer and flavor-specific renderers.
|
|
16
11
|
# Owns the full HTML document generation pipeline: body content, header,
|
|
@@ -107,9 +102,9 @@ module Metanorma
|
|
|
107
102
|
|
|
108
103
|
private
|
|
109
104
|
|
|
110
|
-
def method_missing(method_name,
|
|
105
|
+
def method_missing(method_name, ...)
|
|
111
106
|
if DELEGATED_METHODS.include?(method_name)
|
|
112
|
-
@renderer.public_send(method_name,
|
|
107
|
+
@renderer.public_send(method_name, ...)
|
|
113
108
|
else
|
|
114
109
|
super
|
|
115
110
|
end
|
|
@@ -166,7 +161,7 @@ module Metanorma
|
|
|
166
161
|
|
|
167
162
|
# --- Document Assembly ---
|
|
168
163
|
|
|
169
|
-
TEMPLATE_CACHE = {}
|
|
164
|
+
TEMPLATE_CACHE = {} # rubocop:disable Style/MutableConstant
|
|
170
165
|
TEMPLATE_CACHE_MUTEX = Mutex.new
|
|
171
166
|
|
|
172
167
|
def render_liquid(template_name, assigns)
|
|
@@ -249,7 +244,8 @@ module Metanorma
|
|
|
249
244
|
svg = svg.sub(/<path[^>]*style="fill:#e3000f[^"]*"[^>]*\/>/, "")
|
|
250
245
|
svg = svg.sub(/<svg\s/, '<svg class="header-logo" ')
|
|
251
246
|
svg = if svg.match?(/<svg[^>]*\sheight="[^"]*"/)
|
|
252
|
-
svg.sub(/(<svg[^>]*?)(\sheight="[^"]*")/,
|
|
247
|
+
svg.sub(/(<svg[^>]*?)(\sheight="[^"]*")/,
|
|
248
|
+
"\\1 height=\"#{height}\"")
|
|
253
249
|
else
|
|
254
250
|
svg.sub(/(<svg\b)/, "\\1 height=\"#{height}\"")
|
|
255
251
|
end
|
|
@@ -325,23 +321,18 @@ module Metanorma
|
|
|
325
321
|
end
|
|
326
322
|
|
|
327
323
|
if node.is_a?(Lutaml::Model::Serializable)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
nil
|
|
324
|
+
node_attrs = node.class.attributes
|
|
325
|
+
if node_attrs.key?(:fmt_title) && node.fmt_title
|
|
326
|
+
return true
|
|
332
327
|
end
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
rescue StandardError
|
|
336
|
-
nil
|
|
328
|
+
if node_attrs.key?(:displayorder) && node.displayorder
|
|
329
|
+
return true
|
|
337
330
|
end
|
|
338
331
|
|
|
339
332
|
%i[preface sections annex bibliography].each do |attr|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
nil
|
|
344
|
-
end
|
|
333
|
+
next unless node_attrs.key?(attr)
|
|
334
|
+
|
|
335
|
+
val = node.public_send(attr)
|
|
345
336
|
next unless val
|
|
346
337
|
|
|
347
338
|
Array(val).each { |v| return true if check_presentation_markers(v) }
|
|
@@ -494,78 +485,148 @@ module Metanorma
|
|
|
494
485
|
|
|
495
486
|
# --- Type registrations (class-level, evaluated at class load time) ---
|
|
496
487
|
|
|
497
|
-
register_render Metanorma::Document::Components::Paragraphs::ParagraphBlock,
|
|
498
|
-
|
|
499
|
-
register_render Metanorma::Document::Components::
|
|
500
|
-
|
|
501
|
-
register_render Metanorma::Document::Components::Lists::
|
|
502
|
-
|
|
503
|
-
register_render Metanorma::Document::Components::
|
|
504
|
-
|
|
505
|
-
register_render Metanorma::Document::Components::
|
|
506
|
-
|
|
507
|
-
register_render Metanorma::Document::Components::
|
|
508
|
-
|
|
509
|
-
register_render Metanorma::Document::Components::
|
|
510
|
-
|
|
511
|
-
register_render Metanorma::Document::Components::
|
|
512
|
-
|
|
513
|
-
register_render Metanorma::Document::Components::
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
535
|
-
|
|
536
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
537
|
-
|
|
538
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
539
|
-
|
|
540
|
-
register_inline_render Metanorma::Document::Components::
|
|
541
|
-
|
|
542
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
543
|
-
|
|
544
|
-
register_inline_render Metanorma::Document::Components::
|
|
545
|
-
|
|
488
|
+
register_render Metanorma::Document::Components::Paragraphs::ParagraphBlock,
|
|
489
|
+
:render_paragraph
|
|
490
|
+
register_render Metanorma::Document::Components::Tables::TableBlock,
|
|
491
|
+
:render_table
|
|
492
|
+
register_render Metanorma::Document::Components::Lists::UnorderedList,
|
|
493
|
+
:render_unordered_list
|
|
494
|
+
register_render Metanorma::Document::Components::Lists::OrderedList,
|
|
495
|
+
:render_ordered_list
|
|
496
|
+
register_render Metanorma::Document::Components::Lists::DefinitionList,
|
|
497
|
+
:render_definition_list
|
|
498
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::FigureBlock,
|
|
499
|
+
:render_figure
|
|
500
|
+
register_render Metanorma::Document::Components::Blocks::NoteBlock,
|
|
501
|
+
:render_note
|
|
502
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
|
|
503
|
+
:render_example
|
|
504
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock,
|
|
505
|
+
:render_sourcecode
|
|
506
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::FormulaBlock,
|
|
507
|
+
:render_formula
|
|
508
|
+
register_render Metanorma::Document::Components::MultiParagraph::QuoteBlock,
|
|
509
|
+
:render_quote
|
|
510
|
+
register_render Metanorma::Document::Components::MultiParagraph::AdmonitionBlock,
|
|
511
|
+
:render_admonition
|
|
512
|
+
register_render Metanorma::Document::Components::Sections::HierarchicalSection,
|
|
513
|
+
:render_hierarchical_section
|
|
514
|
+
register_render Metanorma::Document::Components::Sections::BasicSection,
|
|
515
|
+
:render_basic_section
|
|
516
|
+
register_render Metanorma::Document::Components::Sections::ContentSection,
|
|
517
|
+
:render_content_section
|
|
518
|
+
register_render Metanorma::Document::Components::EmptyElements::PageBreakElement,
|
|
519
|
+
:render_noop
|
|
520
|
+
register_render Metanorma::Document::Components::IdElements::Bookmark,
|
|
521
|
+
:render_bookmark
|
|
522
|
+
register_render Metanorma::Document::Components::Inline::SemxElement,
|
|
523
|
+
:render_semx_content
|
|
524
|
+
|
|
525
|
+
register_inline_render Metanorma::Document::Components::Inline::EmRawElement,
|
|
526
|
+
:render_em
|
|
527
|
+
register_inline_render Metanorma::Document::Components::Inline::StrongRawElement,
|
|
528
|
+
:render_strong
|
|
529
|
+
register_inline_render Metanorma::Document::Components::Inline::TtElement,
|
|
530
|
+
:render_tt
|
|
531
|
+
register_inline_render Metanorma::Document::Components::Inline::SubElement,
|
|
532
|
+
:render_sub
|
|
533
|
+
register_inline_render Metanorma::Document::Components::Inline::SupElement,
|
|
534
|
+
:render_sup
|
|
535
|
+
register_inline_render Metanorma::Document::Components::Inline::SmallCapElement,
|
|
536
|
+
:render_small_caps
|
|
537
|
+
register_inline_render Metanorma::Document::Components::TextElements::UnderlineElement,
|
|
538
|
+
:render_underline
|
|
539
|
+
register_inline_render Metanorma::Document::Components::TextElements::StrikeElement,
|
|
540
|
+
:render_strike
|
|
541
|
+
register_inline_render Metanorma::Document::Components::Inline::BrElement,
|
|
542
|
+
:render_br
|
|
543
|
+
register_inline_render Metanorma::Document::Components::Inline::TabElement,
|
|
544
|
+
:render_tab
|
|
545
|
+
register_inline_render Metanorma::Document::Components::Inline::LinkElement,
|
|
546
|
+
:render_link
|
|
547
|
+
register_inline_render Metanorma::Document::Components::Inline::XrefElement,
|
|
548
|
+
:render_noop_inline
|
|
549
|
+
register_inline_render Metanorma::Document::Components::Inline::ErefElement,
|
|
550
|
+
:render_noop_inline
|
|
551
|
+
register_inline_render Metanorma::Document::Components::Inline::SpanElement,
|
|
552
|
+
:render_span
|
|
553
|
+
register_inline_render Metanorma::Document::Components::Inline::FnElement,
|
|
554
|
+
:render_fn_inline
|
|
555
|
+
register_inline_render Metanorma::Document::Components::Inline::ConceptElement,
|
|
556
|
+
:render_concept
|
|
557
|
+
register_inline_render Metanorma::Document::Components::Inline::StemInlineElement,
|
|
558
|
+
:render_noop_inline
|
|
559
|
+
register_inline_render Metanorma::Document::Components::TextElements::StemElement,
|
|
560
|
+
:render_stem
|
|
561
|
+
register_inline_render Metanorma::Document::Components::Inline::SemxElement,
|
|
562
|
+
:render_semx_inline
|
|
563
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtXrefElement,
|
|
564
|
+
:render_fmt_xref
|
|
565
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtStemElement,
|
|
566
|
+
:render_fmt_stem
|
|
567
|
+
register_inline_render Metanorma::Document::Components::Inline::CommaElement,
|
|
568
|
+
:render_comma
|
|
569
|
+
register_inline_render Metanorma::Document::Components::Inline::EnumCommaElement,
|
|
570
|
+
:render_comma
|
|
571
|
+
register_inline_render Metanorma::Document::Components::IdElements::Bookmark,
|
|
572
|
+
:render_bookmark
|
|
573
|
+
register_inline_render Metanorma::Document::Components::IdElements::Image,
|
|
574
|
+
:render_image
|
|
575
|
+
register_inline_render Metanorma::Document::Components::Inline::MathElement,
|
|
576
|
+
:render_math
|
|
577
|
+
register_inline_render Metanorma::Document::Components::Inline::AsciimathElement,
|
|
578
|
+
:render_asciimath
|
|
579
|
+
register_inline_render Metanorma::Document::Components::EmptyElements::IndexElement,
|
|
580
|
+
:render_index
|
|
581
|
+
register_inline_render Metanorma::Document::Components::ReferenceElements::IndexXrefElement,
|
|
582
|
+
:render_index
|
|
583
|
+
register_inline_render Metanorma::Document::Components::Blocks::NoteBlock,
|
|
584
|
+
:render_note_inline
|
|
546
585
|
# All Fmt* elements delegate to render_mixed_inline
|
|
547
|
-
register_inline_render Metanorma::Document::Components::Inline::FmtNameElement,
|
|
548
|
-
|
|
549
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
550
|
-
|
|
551
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
552
|
-
|
|
553
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
554
|
-
|
|
555
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
556
|
-
|
|
557
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
558
|
-
|
|
559
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
560
|
-
|
|
561
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
562
|
-
|
|
563
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
564
|
-
|
|
565
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
566
|
-
|
|
567
|
-
register_inline_render Metanorma::Document::Components::Inline::
|
|
568
|
-
|
|
586
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtNameElement,
|
|
587
|
+
:render_mixed_inline
|
|
588
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtTitleElement,
|
|
589
|
+
:render_mixed_inline
|
|
590
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtXrefLabelElement,
|
|
591
|
+
:render_mixed_inline
|
|
592
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtFnLabelElement,
|
|
593
|
+
:render_mixed_inline
|
|
594
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtConceptElement,
|
|
595
|
+
:render_mixed_inline
|
|
596
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationStartElement,
|
|
597
|
+
:render_mixed_inline
|
|
598
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationEndElement,
|
|
599
|
+
:render_mixed_inline
|
|
600
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationBodyElement,
|
|
601
|
+
:render_mixed_inline
|
|
602
|
+
register_inline_render Metanorma::Document::Components::Inline::VariantTitleElement,
|
|
603
|
+
:render_mixed_inline
|
|
604
|
+
register_inline_render Metanorma::Document::Components::Inline::LocalizedStringElement,
|
|
605
|
+
:render_mixed_inline
|
|
606
|
+
register_inline_render Metanorma::Document::Components::Inline::TitleWithAnnotationElement,
|
|
607
|
+
:render_mixed_inline
|
|
608
|
+
register_inline_render Metanorma::Document::Components::Inline::BiblioTagElement,
|
|
609
|
+
:render_mixed_inline
|
|
610
|
+
register_inline_render Metanorma::Document::Components::Inline::NameWithIdElement,
|
|
611
|
+
:render_mixed_inline
|
|
612
|
+
register_inline_render Metanorma::Document::Components::Inline::DisplayTextElement,
|
|
613
|
+
:render_mixed_inline
|
|
614
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtFootnoteContainerElement,
|
|
615
|
+
:render_mixed_inline
|
|
616
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtFnBodyElement,
|
|
617
|
+
:render_mixed_inline
|
|
618
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtPreferredElement,
|
|
619
|
+
:render_mixed_inline
|
|
620
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtDefinitionElement,
|
|
621
|
+
:render_mixed_inline
|
|
622
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtTermsourceElement,
|
|
623
|
+
:render_mixed_inline
|
|
624
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAdmittedElement,
|
|
625
|
+
:render_mixed_inline
|
|
626
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtIdentifierElement,
|
|
627
|
+
:render_mixed_inline
|
|
628
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtSourcecodeElement,
|
|
629
|
+
:render_mixed_inline
|
|
569
630
|
|
|
570
631
|
def lookup_dispatch(type_class, registry_method)
|
|
571
632
|
self.class.ancestors.each do |ancestor|
|
|
@@ -589,7 +650,10 @@ module Metanorma
|
|
|
589
650
|
# --- Block-level rendering ---
|
|
590
651
|
|
|
591
652
|
def render_paragraph(p, **_opts)
|
|
592
|
-
attrs = element_attrs(id: safe_attr(p, :id),
|
|
653
|
+
attrs = element_attrs(id: safe_attr(p, :id),
|
|
654
|
+
style: alignment_style(safe_attr(
|
|
655
|
+
p, :alignment
|
|
656
|
+
)))
|
|
593
657
|
tag("p", attrs) { render_mixed_inline(p) }
|
|
594
658
|
end
|
|
595
659
|
|
|
@@ -641,8 +705,12 @@ module Metanorma
|
|
|
641
705
|
|
|
642
706
|
sec.tr.each do |tr|
|
|
643
707
|
cols = 0
|
|
644
|
-
Array(tr.th).each
|
|
645
|
-
|
|
708
|
+
Array(tr.th).each do |th|
|
|
709
|
+
cols += th.colspan && th.colspan > 1 ? th.colspan : 1
|
|
710
|
+
end
|
|
711
|
+
Array(tr.td).each do |td|
|
|
712
|
+
cols += td.colspan && td.colspan > 1 ? td.colspan : 1
|
|
713
|
+
end
|
|
646
714
|
max_cols = cols if cols > max_cols
|
|
647
715
|
end
|
|
648
716
|
end
|
|
@@ -699,7 +767,8 @@ module Metanorma
|
|
|
699
767
|
end
|
|
700
768
|
|
|
701
769
|
def render_ordered_list(ol, **_opts)
|
|
702
|
-
attrs = element_attrs(id: safe_attr(ol, :id),
|
|
770
|
+
attrs = element_attrs(id: safe_attr(ol, :id),
|
|
771
|
+
start: safe_attr(ol, :start), type: safe_attr(ol, :type_attr))
|
|
703
772
|
tag("ol", attrs) do
|
|
704
773
|
ol.listitem&.each { |li| render_list_item(li) }
|
|
705
774
|
end
|
|
@@ -771,11 +840,10 @@ module Metanorma
|
|
|
771
840
|
|
|
772
841
|
def sort_by_displayorder(children)
|
|
773
842
|
children.sort_by do |node|
|
|
774
|
-
order =
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
end
|
|
843
|
+
order = if node.is_a?(Lutaml::Model::Serializable) &&
|
|
844
|
+
node.class.attributes.key?(:displayorder)
|
|
845
|
+
node.displayorder
|
|
846
|
+
end
|
|
779
847
|
order &&= order.to_i
|
|
780
848
|
order || Float::INFINITY
|
|
781
849
|
end
|
|
@@ -837,7 +905,8 @@ module Metanorma
|
|
|
837
905
|
end
|
|
838
906
|
|
|
839
907
|
def render_example(example, **_opts)
|
|
840
|
-
drop = Drops::ExampleDrop.from_model(example,
|
|
908
|
+
drop = Drops::ExampleDrop.from_model(example,
|
|
909
|
+
renderer: renderer_context)
|
|
841
910
|
@output << render_liquid("_example.html.liquid", { "block" => drop })
|
|
842
911
|
end
|
|
843
912
|
|
|
@@ -847,7 +916,8 @@ module Metanorma
|
|
|
847
916
|
end
|
|
848
917
|
|
|
849
918
|
def render_formula(formula, **_opts)
|
|
850
|
-
drop = Drops::FormulaDrop.from_model(formula,
|
|
919
|
+
drop = Drops::FormulaDrop.from_model(formula,
|
|
920
|
+
renderer: renderer_context)
|
|
851
921
|
@output << render_liquid("_formula.html.liquid", { "block" => drop })
|
|
852
922
|
end
|
|
853
923
|
|
|
@@ -866,7 +936,8 @@ module Metanorma
|
|
|
866
936
|
end
|
|
867
937
|
|
|
868
938
|
def render_admonition(admonition, **_opts)
|
|
869
|
-
drop = Drops::AdmonitionDrop.from_model(admonition,
|
|
939
|
+
drop = Drops::AdmonitionDrop.from_model(admonition,
|
|
940
|
+
renderer: renderer_context)
|
|
870
941
|
@output << render_liquid("_admonition.html.liquid", { "block" => drop })
|
|
871
942
|
end
|
|
872
943
|
|
|
@@ -1257,7 +1328,8 @@ module Metanorma
|
|
|
1257
1328
|
stem_child figure_child formula_child sourcecode_child]
|
|
1258
1329
|
label_stripped = false
|
|
1259
1330
|
|
|
1260
|
-
walked = walk_ordered(element,
|
|
1331
|
+
walked = walk_ordered(element,
|
|
1332
|
+
allow_filter: display_attrs) do |type, obj|
|
|
1261
1333
|
case type
|
|
1262
1334
|
when :text
|
|
1263
1335
|
text = obj
|
|
@@ -1308,7 +1380,9 @@ module Metanorma
|
|
|
1308
1380
|
end
|
|
1309
1381
|
|
|
1310
1382
|
def render_inline_tag(tag_name, element, **extra_attrs)
|
|
1311
|
-
tag(tag_name, element_attrs(**extra_attrs))
|
|
1383
|
+
tag(tag_name, element_attrs(**extra_attrs)) do
|
|
1384
|
+
render_mixed_inline(element)
|
|
1385
|
+
end
|
|
1312
1386
|
end
|
|
1313
1387
|
|
|
1314
1388
|
# Process raw XML content from map_all_content models (e.g. RawParagraph).
|
|
@@ -1349,13 +1423,17 @@ module Metanorma
|
|
|
1349
1423
|
end
|
|
1350
1424
|
# Remap XML class names to HTML-specific class names
|
|
1351
1425
|
doc.css("[class]").each do |el|
|
|
1352
|
-
el["class"] = el["class"].split(/\s+/).map
|
|
1426
|
+
el["class"] = el["class"].split(/\s+/).map do |c|
|
|
1427
|
+
html_class_for_span(c)
|
|
1428
|
+
end.join(" ")
|
|
1353
1429
|
end
|
|
1354
1430
|
doc.inner_html
|
|
1355
1431
|
end
|
|
1356
1432
|
|
|
1357
1433
|
def deduplicate_semx_label(source_node, semx_node)
|
|
1358
|
-
first_text = semx_node.children.find
|
|
1434
|
+
first_text = semx_node.children.find do |c|
|
|
1435
|
+
c.text? && !c.text.strip.empty?
|
|
1436
|
+
end
|
|
1359
1437
|
return unless first_text
|
|
1360
1438
|
|
|
1361
1439
|
semx_prefix = first_text.text[/\A(\s*\S+)/, 1]
|
|
@@ -1369,7 +1447,9 @@ module Metanorma
|
|
|
1369
1447
|
return unless prev_text.end_with?(label)
|
|
1370
1448
|
|
|
1371
1449
|
prev.content = prev_text.sub(/#{Regexp.escape(label)}\s*\z/, "")
|
|
1372
|
-
first_text.content = first_text.text.sub(
|
|
1450
|
+
first_text.content = first_text.text.sub(
|
|
1451
|
+
/\A\s*#{Regexp.escape(label)}\s*/, ""
|
|
1452
|
+
)
|
|
1373
1453
|
end
|
|
1374
1454
|
|
|
1375
1455
|
def render_link(link)
|
|
@@ -1388,7 +1468,9 @@ module Metanorma
|
|
|
1388
1468
|
|
|
1389
1469
|
def render_xref(xref)
|
|
1390
1470
|
target = safe_attr(xref, :target) || safe_attr(xref, :to_attr)
|
|
1391
|
-
attrs = element_attrs(href: "##{escape_html(target)}",
|
|
1471
|
+
attrs = element_attrs(href: "##{escape_html(target)}",
|
|
1472
|
+
id: safe_attr(xref,
|
|
1473
|
+
:id))
|
|
1392
1474
|
tag("a", attrs) { render_mixed_inline(xref) }
|
|
1393
1475
|
end
|
|
1394
1476
|
|
|
@@ -1472,14 +1554,13 @@ module Metanorma
|
|
|
1472
1554
|
# TextElements::StemElement — block math (no fmt- counterpart for display formulas)
|
|
1473
1555
|
if stem.is_a?(Metanorma::Document::Components::TextElements::StemElement)
|
|
1474
1556
|
if stem.math
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
if stem.asciimath
|
|
1557
|
+
math_val = stem.math
|
|
1558
|
+
return math_val.to_xml if math_val.is_a?(Nokogiri::XML::Node)
|
|
1559
|
+
return math_val.to_xml if defined?(Moxml::Document) && math_val.is_a?(Moxml::Document)
|
|
1560
|
+
|
|
1561
|
+
math_items = Array(math_val)
|
|
1562
|
+
math_items.join
|
|
1563
|
+
elsif stem.asciimath
|
|
1483
1564
|
text = extract_text_value(stem.asciimath)
|
|
1484
1565
|
return %(<span class="stem">#{escape_html(text)}</span>)
|
|
1485
1566
|
end
|
|
@@ -1538,6 +1619,10 @@ module Metanorma
|
|
|
1538
1619
|
end
|
|
1539
1620
|
|
|
1540
1621
|
def safe_attr(obj, method_name)
|
|
1622
|
+
if obj.is_a?(Lutaml::Model::Serializable) && !obj.class.attributes.key?(method_name)
|
|
1623
|
+
return nil
|
|
1624
|
+
end
|
|
1625
|
+
|
|
1541
1626
|
obj.public_send(method_name)
|
|
1542
1627
|
rescue NoMethodError
|
|
1543
1628
|
nil
|
|
@@ -1636,7 +1721,8 @@ module Metanorma
|
|
|
1636
1721
|
Drops::FootnoteDrop.new(entry, content_html)
|
|
1637
1722
|
end
|
|
1638
1723
|
|
|
1639
|
-
@output << render_liquid("_footnotes.html.liquid",
|
|
1724
|
+
@output << render_liquid("_footnotes.html.liquid",
|
|
1725
|
+
{ "footnotes" => drops })
|
|
1640
1726
|
end
|
|
1641
1727
|
|
|
1642
1728
|
def capture_output
|
|
@@ -5,7 +5,6 @@ module Metanorma
|
|
|
5
5
|
# Renders BipmDocument components to HTML.
|
|
6
6
|
# Extends IsoRenderer with BIPM-specific branding (institutional navy, scientific precision).
|
|
7
7
|
class BipmRenderer < IsoRenderer
|
|
8
|
-
|
|
9
8
|
def flavor_publishers(_doc_id)
|
|
10
9
|
["BIPM"]
|
|
11
10
|
end
|
|
@@ -27,7 +26,7 @@ module Metanorma
|
|
|
27
26
|
# BIPM logo: white fill for dark header
|
|
28
27
|
def load_logo_svg(filename, **opts)
|
|
29
28
|
svg = super
|
|
30
|
-
svg = svg.gsub(
|
|
29
|
+
svg = svg.gsub("fill:#0f3c80", "fill:white") if svg
|
|
31
30
|
svg
|
|
32
31
|
end
|
|
33
32
|
|
|
@@ -50,12 +49,16 @@ module Metanorma
|
|
|
50
49
|
logos = publisher_logos_html(doc)
|
|
51
50
|
if logos && !logos.empty?
|
|
52
51
|
@output << "<div class=\"cover-publishers\">"
|
|
53
|
-
logos.each
|
|
52
|
+
logos.each do |svg|
|
|
53
|
+
@output << "<span class=\"cover-logo\">#{svg}</span>"
|
|
54
|
+
end
|
|
54
55
|
@output << "</div>"
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
identifiers = Array(bibdata.doc_identifier).compact
|
|
58
|
-
cover_ids = identifiers.select
|
|
59
|
+
cover_ids = identifiers.select do |di|
|
|
60
|
+
safe_attr(di, :type) == "iso-reference"
|
|
61
|
+
end
|
|
59
62
|
cover_ids = [identifiers.first].compact if cover_ids.empty?
|
|
60
63
|
|
|
61
64
|
cover_ids.each do |di|
|
|
@@ -66,8 +69,13 @@ module Metanorma
|
|
|
66
69
|
end
|
|
67
70
|
|
|
68
71
|
bibdata.date&.each do |date|
|
|
69
|
-
date_type = extract_text_value(safe_attr(date,
|
|
70
|
-
|
|
72
|
+
date_type = extract_text_value(safe_attr(date,
|
|
73
|
+
:type_attr) || safe_attr(
|
|
74
|
+
date, :type
|
|
75
|
+
))
|
|
76
|
+
date_val = extract_text_value(date.is_a?(Metanorma::Document::Relaton::BibliographicDate) ? date.on : safe_attr(
|
|
77
|
+
date, :text
|
|
78
|
+
))
|
|
71
79
|
if date_type == "published" && date_val
|
|
72
80
|
@output << "<p class=\"cover-date\">#{escape_html(date_val)}</p>"
|
|
73
81
|
end
|
|
@@ -81,7 +89,7 @@ module Metanorma
|
|
|
81
89
|
@output << "<div class=\"cover-title\"><span>#{escape_html(title_text)}</span></div>"
|
|
82
90
|
end
|
|
83
91
|
|
|
84
|
-
if bibdata.status
|
|
92
|
+
if bibdata.status&.stage
|
|
85
93
|
stages = Array(bibdata.status.stage)
|
|
86
94
|
stage_text = stages.map { |s| Array(s.value).join }.join(" ")
|
|
87
95
|
unless stage_text.empty?
|
|
@@ -121,7 +129,7 @@ module Metanorma
|
|
|
121
129
|
t.example_bg = "#f5f0e8"
|
|
122
130
|
t.example_color = "#7a6952"
|
|
123
131
|
t.admonition_border = "#7a6952"
|
|
124
|
-
t.admonition_bg
|
|
132
|
+
t.admonition_bg = "#f5f0e8"
|
|
125
133
|
t.admonition_color = "#7a6952"
|
|
126
134
|
t.footer_border_color = "#3d7ec7"
|
|
127
135
|
t.cover_separator_color = "rgba(61,126,199,0.25)"
|
|
@@ -50,7 +50,11 @@ module Metanorma
|
|
|
50
50
|
def safe_attr(obj, method_name) = renderer.safe_attr(obj, method_name)
|
|
51
51
|
def extract_plain_text(node) = renderer.extract_plain_text(node)
|
|
52
52
|
def extract_text_value(val) = renderer.extract_text_value(val)
|
|
53
|
-
|
|
53
|
+
|
|
54
|
+
def extract_block_label(block,
|
|
55
|
+
default)
|
|
56
|
+
renderer.extract_block_label(block, default)
|
|
57
|
+
end
|
|
54
58
|
|
|
55
59
|
def self.register_in(registry)
|
|
56
60
|
handled_classes.each do |klass|
|
|
@@ -32,7 +32,7 @@ module Metanorma
|
|
|
32
32
|
number: number,
|
|
33
33
|
reference: ref,
|
|
34
34
|
content: fn.p,
|
|
35
|
-
fmt_label: fn.fmt_fn_label
|
|
35
|
+
fmt_label: fn.fmt_fn_label,
|
|
36
36
|
)
|
|
37
37
|
number
|
|
38
38
|
end
|
|
@@ -41,8 +41,8 @@ module Metanorma
|
|
|
41
41
|
@footnotes.empty?
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def each(&
|
|
45
|
-
@footnotes.each(&
|
|
44
|
+
def each(&)
|
|
45
|
+
@footnotes.each(&)
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def to_a
|