metanorma-document 0.2.6 → 0.2.7
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 +321 -45
- 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 +198 -111
- 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 +33 -16
- 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 +15 -89
- 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 +6 -9
- 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 +226 -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 +81 -16
- data/lib/metanorma/standard_document/sections/bibliography_section.rb +1 -2
- data/lib/metanorma/standard_document/sections/clause_section.rb +102 -10
- data/lib/metanorma/standard_document/sections/colophon.rb +16 -0
- data/lib/metanorma/standard_document/sections/definition_section.rb +45 -42
- 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 +42 -9
- data/lib/metanorma/standard_document/sections/terms_section.rb +52 -10
- 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 +7 -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
|
@@ -17,7 +17,7 @@ module Metanorma
|
|
|
17
17
|
see: see,
|
|
18
18
|
see_also: see_also,
|
|
19
19
|
target_id: target_id,
|
|
20
|
-
target_text: target_text
|
|
20
|
+
target_text: target_text,
|
|
21
21
|
)
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -67,7 +67,7 @@ module Metanorma
|
|
|
67
67
|
keyword_init: true)
|
|
68
68
|
|
|
69
69
|
IndexEntry = Struct.new(:term, :locators, :see, :see_also_entries, :children,
|
|
70
|
-
|
|
70
|
+
keyword_init: true) do
|
|
71
71
|
def initialize(*)
|
|
72
72
|
super
|
|
73
73
|
self.locators ||= []
|
|
@@ -76,7 +76,12 @@ module Metanorma
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def add_locator(id, text)
|
|
79
|
-
|
|
79
|
+
if id && locators.none? do |l|
|
|
80
|
+
l.id == id
|
|
81
|
+
end
|
|
82
|
+
locators << IndexLocator.new(id: id,
|
|
83
|
+
text: text)
|
|
84
|
+
end
|
|
80
85
|
end
|
|
81
86
|
|
|
82
87
|
def add_see_also(term)
|
|
@@ -4,7 +4,8 @@ module Metanorma
|
|
|
4
4
|
module Html
|
|
5
5
|
module Component
|
|
6
6
|
autoload :Base, "metanorma/html/component/base"
|
|
7
|
-
autoload :IndexTermCollector,
|
|
7
|
+
autoload :IndexTermCollector,
|
|
8
|
+
"metanorma/html/component/index_term_collector"
|
|
8
9
|
autoload :IndexSection, "metanorma/html/component/index_section"
|
|
9
10
|
autoload :FootnoteCollector, "metanorma/html/component/footnote_collector"
|
|
10
11
|
end
|
|
@@ -8,9 +8,13 @@ module Metanorma
|
|
|
8
8
|
|
|
9
9
|
def self.from_model(figure, renderer:)
|
|
10
10
|
id = renderer.safe_attr(figure, :id)
|
|
11
|
-
fig_name = renderer.safe_attr(figure,
|
|
11
|
+
fig_name = renderer.safe_attr(figure,
|
|
12
|
+
:fmt_name) || renderer.safe_attr(
|
|
13
|
+
figure, :name
|
|
14
|
+
)
|
|
12
15
|
if id && fig_name
|
|
13
|
-
renderer.register_figure_entry(id: id,
|
|
16
|
+
renderer.register_figure_entry(id: id,
|
|
17
|
+
text: renderer.extract_plain_text(fig_name))
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
image_html = renderer.capture_output do
|
|
@@ -24,7 +28,8 @@ module Metanorma
|
|
|
24
28
|
|
|
25
29
|
caption_html = if fig_name || renderer.safe_attr(figure, :name)
|
|
26
30
|
renderer.capture_output do
|
|
27
|
-
el = renderer.safe_attr(figure,
|
|
31
|
+
el = renderer.safe_attr(figure,
|
|
32
|
+
:fmt_name) || figure.name
|
|
28
33
|
renderer.render_inline_element(el)
|
|
29
34
|
end
|
|
30
35
|
end
|
|
@@ -34,8 +39,12 @@ module Metanorma
|
|
|
34
39
|
end
|
|
35
40
|
|
|
36
41
|
key_html = renderer.capture_output do
|
|
37
|
-
renderer.safe_attr(figure, :note)&.each
|
|
38
|
-
|
|
42
|
+
renderer.safe_attr(figure, :note)&.each do |n|
|
|
43
|
+
renderer.render_note(n)
|
|
44
|
+
end
|
|
45
|
+
renderer.safe_attr(figure, :dl)&.then do |dl|
|
|
46
|
+
renderer.render_definition_list(dl)
|
|
47
|
+
end
|
|
39
48
|
end
|
|
40
49
|
|
|
41
50
|
new(
|
|
@@ -25,9 +25,14 @@ module Metanorma
|
|
|
25
25
|
formula.dl&.then { |dl| renderer.render_definition_list(dl) }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
name_el = renderer.safe_attr(formula,
|
|
28
|
+
name_el = renderer.safe_attr(formula,
|
|
29
|
+
:fmt_name) || renderer.safe_attr(
|
|
30
|
+
formula, :name
|
|
31
|
+
)
|
|
29
32
|
number_html = if name_el
|
|
30
|
-
renderer.capture_output
|
|
33
|
+
renderer.capture_output do
|
|
34
|
+
renderer.render_inline_element(name_el)
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
new(
|
|
@@ -11,7 +11,9 @@ module Metanorma
|
|
|
11
11
|
lang = renderer.safe_attr(sc, :lang)
|
|
12
12
|
|
|
13
13
|
name_html = if sc.name
|
|
14
|
-
renderer.capture_output
|
|
14
|
+
renderer.capture_output do
|
|
15
|
+
renderer.render_inline_element(sc.name)
|
|
16
|
+
end
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
code_text = if sc.body&.content
|
|
@@ -21,7 +23,9 @@ module Metanorma
|
|
|
21
23
|
else
|
|
22
24
|
""
|
|
23
25
|
end
|
|
24
|
-
raw_text = code_text.gsub("<", "<").gsub(">", ">").gsub("&", "&").gsub(
|
|
26
|
+
raw_text = code_text.gsub("<", "<").gsub(">", ">").gsub("&", "&").gsub(
|
|
27
|
+
""", "\""
|
|
28
|
+
)
|
|
25
29
|
|
|
26
30
|
new(
|
|
27
31
|
id: id,
|
data/lib/metanorma/html/drops.rb
CHANGED
|
@@ -12,7 +12,8 @@ module Metanorma
|
|
|
12
12
|
autoload :FormulaDrop, "metanorma/html/drops/formula_drop"
|
|
13
13
|
autoload :FigureDrop, "metanorma/html/drops/figure_drop"
|
|
14
14
|
autoload :TocEntryDrop, "metanorma/html/drops/toc_entry_drop"
|
|
15
|
-
autoload :FigureListEntryDrop,
|
|
15
|
+
autoload :FigureListEntryDrop,
|
|
16
|
+
"metanorma/html/drops/figure_list_entry_drop"
|
|
16
17
|
end
|
|
17
18
|
end
|
|
18
19
|
end
|
|
@@ -19,7 +19,7 @@ module Metanorma
|
|
|
19
19
|
@tastes << [model_class, publisher_abbrev, renderer_class]
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def generate(document, **
|
|
22
|
+
def generate(document, **_options)
|
|
23
23
|
setup! unless @setup
|
|
24
24
|
renderer_for(document).new.generate_full_document(document)
|
|
25
25
|
end
|
|
@@ -43,7 +43,8 @@ module Metanorma
|
|
|
43
43
|
def find_taste(document)
|
|
44
44
|
@tastes.each do |model_class, publisher_abbrev, renderer_class|
|
|
45
45
|
next unless document.is_a?(model_class)
|
|
46
|
-
return renderer_class if taste_publisher?(document,
|
|
46
|
+
return renderer_class if taste_publisher?(document,
|
|
47
|
+
publisher_abbrev)
|
|
47
48
|
end
|
|
48
49
|
nil
|
|
49
50
|
end
|
|
@@ -51,25 +52,39 @@ module Metanorma
|
|
|
51
52
|
def taste_publisher?(document, abbrev)
|
|
52
53
|
bibdata = document.bibdata if document.is_a?(Lutaml::Model::Serializable)
|
|
53
54
|
return false unless bibdata
|
|
55
|
+
|
|
54
56
|
contributors = bibdata.contributor
|
|
55
57
|
return false unless contributors
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
|
|
59
|
+
begin
|
|
60
|
+
contributors.any? do |c|
|
|
61
|
+
begin
|
|
62
|
+
next false unless c.role&.any? do |r|
|
|
63
|
+
r&.type == "author"
|
|
64
|
+
end
|
|
65
|
+
rescue StandardError
|
|
66
|
+
false
|
|
67
|
+
end
|
|
68
|
+
org = c.organization
|
|
69
|
+
next false unless org
|
|
70
|
+
|
|
71
|
+
org_abbrev = org.abbreviation
|
|
72
|
+
if org_abbrev.is_a?(String)
|
|
73
|
+
org_abbrev == abbrev
|
|
74
|
+
elsif org_abbrev.is_a?(Lutaml::Model::Serializable)
|
|
75
|
+
safe_attr(org_abbrev, :content) == abbrev
|
|
76
|
+
else
|
|
77
|
+
org_abbrev.to_s == abbrev
|
|
78
|
+
end
|
|
67
79
|
end
|
|
68
|
-
|
|
80
|
+
rescue StandardError
|
|
81
|
+
false
|
|
82
|
+
end
|
|
69
83
|
end
|
|
70
84
|
|
|
71
85
|
def setup!
|
|
72
86
|
return if @setup
|
|
87
|
+
|
|
73
88
|
@setup = true
|
|
74
89
|
|
|
75
90
|
# Trigger autoloads by referencing constants
|
|
@@ -105,8 +120,10 @@ module Metanorma
|
|
|
105
120
|
register Metanorma::RiboseDocument::Root, RiboseRenderer
|
|
106
121
|
|
|
107
122
|
# Register tastes (publisher-based dispatch within same model)
|
|
108
|
-
register_taste Metanorma::IsoDocument::Root, "ICC",
|
|
109
|
-
|
|
123
|
+
register_taste Metanorma::IsoDocument::Root, "ICC",
|
|
124
|
+
IccRenderer
|
|
125
|
+
register_taste Metanorma::RiboseDocument::Root, "PDF Association",
|
|
126
|
+
PdfaRenderer
|
|
110
127
|
end
|
|
111
128
|
end
|
|
112
129
|
end
|
|
@@ -4,7 +4,6 @@ module Metanorma
|
|
|
4
4
|
module Html
|
|
5
5
|
# IHO brand: #00AAA9 teal + #05164D navy + #FEDC5B gold from logo
|
|
6
6
|
class IhoRenderer < IsoRenderer
|
|
7
|
-
|
|
8
7
|
def flavor_publishers(_doc_id)
|
|
9
8
|
["IHO"]
|
|
10
9
|
end
|
|
@@ -44,7 +43,7 @@ module Metanorma
|
|
|
44
43
|
t.example_bg = "#eaf5f5"
|
|
45
44
|
t.example_color = "#008887"
|
|
46
45
|
t.admonition_border = "#FEDC5B"
|
|
47
|
-
t.admonition_bg
|
|
46
|
+
t.admonition_bg = "#fff9e6"
|
|
48
47
|
t.admonition_color = "#b8860b"
|
|
49
48
|
t.footer_border_color = "#00AAA9"
|
|
50
49
|
t.cover_separator_color = "rgba(0,170,169,0.3)"
|
|
@@ -52,19 +52,28 @@ module Metanorma
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
register_render Metanorma::IsoDocument::Root, :render_document
|
|
55
|
-
register_render Metanorma::IsoDocument::Sections::IsoPreface,
|
|
56
|
-
|
|
57
|
-
register_render Metanorma::IsoDocument::Sections::
|
|
58
|
-
|
|
59
|
-
register_render Metanorma::IsoDocument::Sections::
|
|
60
|
-
|
|
61
|
-
register_render Metanorma::IsoDocument::Sections::
|
|
55
|
+
register_render Metanorma::IsoDocument::Sections::IsoPreface,
|
|
56
|
+
:render_preface
|
|
57
|
+
register_render Metanorma::IsoDocument::Sections::IsoSections,
|
|
58
|
+
:render_sections
|
|
59
|
+
register_render Metanorma::IsoDocument::Sections::IsoClauseSection,
|
|
60
|
+
:render_clause
|
|
61
|
+
register_render Metanorma::IsoDocument::Sections::IsoAnnexSection,
|
|
62
|
+
:render_annex
|
|
63
|
+
register_render Metanorma::IsoDocument::Sections::IsoTermsSection,
|
|
64
|
+
:render_terms_section
|
|
65
|
+
register_render Metanorma::IsoDocument::Sections::IsoForewordSection,
|
|
66
|
+
:render_foreword
|
|
67
|
+
register_render Metanorma::IsoDocument::Sections::IsoAbstractSection,
|
|
68
|
+
:render_abstract
|
|
62
69
|
register_render Metanorma::IsoDocument::Terms::IsoTerm, :render_term
|
|
63
70
|
register_render Metanorma::IsoDocument::Terms::TermNote, :render_term_note
|
|
64
|
-
register_render Metanorma::IsoDocument::Terms::TermExample,
|
|
71
|
+
register_render Metanorma::IsoDocument::Terms::TermExample,
|
|
72
|
+
:render_term_example
|
|
65
73
|
register_render Metanorma::IsoDocument::Boilerplate, :render_boilerplate
|
|
66
74
|
|
|
67
|
-
register_inline_render Metanorma::IsoDocument::Terms::TermOrigin,
|
|
75
|
+
register_inline_render Metanorma::IsoDocument::Terms::TermOrigin,
|
|
76
|
+
:render_term_origin
|
|
68
77
|
|
|
69
78
|
def render_term_origin(element)
|
|
70
79
|
text = extract_text_value(element)
|
|
@@ -82,7 +91,9 @@ module Metanorma
|
|
|
82
91
|
return result if result && !result.empty?
|
|
83
92
|
|
|
84
93
|
if titles.is_a?(Metanorma::IsoDocument::Metadata::TitleCollection) && !titles.items.empty?
|
|
85
|
-
raw = titles.items.find
|
|
94
|
+
raw = titles.items.find do |t|
|
|
95
|
+
t.language == "en"
|
|
96
|
+
end || titles.items.first
|
|
86
97
|
return raw.value.to_s if raw&.value
|
|
87
98
|
end
|
|
88
99
|
nil
|
|
@@ -195,8 +206,13 @@ module Metanorma
|
|
|
195
206
|
|
|
196
207
|
pub_date = nil
|
|
197
208
|
bibdata.date&.each do |date|
|
|
198
|
-
date_type = extract_text_value(safe_attr(date,
|
|
199
|
-
|
|
209
|
+
date_type = extract_text_value(safe_attr(date,
|
|
210
|
+
:type_attr) || safe_attr(
|
|
211
|
+
date, :type
|
|
212
|
+
))
|
|
213
|
+
date_val = extract_text_value(date.is_a?(Metanorma::Document::Relaton::BibliographicDate) ? date.on : safe_attr(
|
|
214
|
+
date, :text
|
|
215
|
+
))
|
|
200
216
|
if date_type == "published" && date_val
|
|
201
217
|
pub_date = date_val
|
|
202
218
|
end
|
|
@@ -350,8 +366,14 @@ module Metanorma
|
|
|
350
366
|
term_name = extract_term_name(term)
|
|
351
367
|
term_def = extract_term_definition(term)
|
|
352
368
|
data_attrs = {}
|
|
353
|
-
|
|
354
|
-
|
|
369
|
+
if term_name && !term_name.empty?
|
|
370
|
+
data_attrs["data-term-name"] =
|
|
371
|
+
term_name
|
|
372
|
+
end
|
|
373
|
+
if term_def && !term_def.empty?
|
|
374
|
+
data_attrs["data-term-definition"] =
|
|
375
|
+
term_def
|
|
376
|
+
end
|
|
355
377
|
attrs = element_attrs(id: safe_attr(term, :id), **data_attrs)
|
|
356
378
|
tag("div", attrs) do
|
|
357
379
|
# In presentation mode, use fmt_* elements
|
|
@@ -372,23 +394,37 @@ module Metanorma
|
|
|
372
394
|
|
|
373
395
|
# Preferred designations — use fmt-preferred if available
|
|
374
396
|
if term.fmt_preferred && !term.fmt_preferred.empty?
|
|
375
|
-
term.fmt_preferred.each
|
|
397
|
+
term.fmt_preferred.each do |fp|
|
|
398
|
+
fp.p&.each do |para|
|
|
399
|
+
render_paragraph(para)
|
|
400
|
+
end
|
|
401
|
+
end
|
|
376
402
|
elsif term.preferred && !term.preferred.empty?
|
|
377
|
-
term.preferred&.each
|
|
403
|
+
term.preferred&.each do |designation|
|
|
404
|
+
render_term_designation(designation, "preferred")
|
|
405
|
+
end
|
|
378
406
|
end
|
|
379
407
|
|
|
380
408
|
# Admitted designations — use fmt-admitted if available
|
|
381
409
|
if term.fmt_admitted && !term.fmt_admitted.empty?
|
|
382
|
-
term.fmt_admitted.each
|
|
410
|
+
term.fmt_admitted.each do |fa|
|
|
411
|
+
fa.p&.each do |para|
|
|
412
|
+
render_paragraph(para)
|
|
413
|
+
end
|
|
414
|
+
end
|
|
383
415
|
elsif term.admitted && !term.admitted.empty?
|
|
384
|
-
term.admitted&.each
|
|
416
|
+
term.admitted&.each do |designation|
|
|
417
|
+
render_term_designation(designation, "admitted")
|
|
418
|
+
end
|
|
385
419
|
end
|
|
386
420
|
|
|
387
421
|
# Deprecated designations — use fmt-deprecates if available
|
|
388
422
|
if term.fmt_deprecates
|
|
389
423
|
term.fmt_deprecates.p&.each { |para| render_paragraph(para) }
|
|
390
424
|
elsif term.deprecates && !term.deprecates.empty?
|
|
391
|
-
term.deprecates&.each
|
|
425
|
+
term.deprecates&.each do |designation|
|
|
426
|
+
render_term_designation(designation, "deprecated")
|
|
427
|
+
end
|
|
392
428
|
end
|
|
393
429
|
|
|
394
430
|
# Domain — only render separately when fmt-definition is absent
|
|
@@ -450,11 +486,17 @@ module Metanorma
|
|
|
450
486
|
|
|
451
487
|
def extract_term_definition(term)
|
|
452
488
|
if term.fmt_definition
|
|
453
|
-
rendered = capture_output
|
|
489
|
+
rendered = capture_output do
|
|
490
|
+
render_ordered_content(term.fmt_definition)
|
|
491
|
+
end
|
|
454
492
|
return strip_html(rendered).gsub(/\s+/, " ").strip
|
|
455
493
|
end
|
|
456
494
|
if term.p && !term.p.empty?
|
|
457
|
-
rendered = capture_output
|
|
495
|
+
rendered = capture_output do
|
|
496
|
+
term.p.each do |para|
|
|
497
|
+
render_paragraph(para)
|
|
498
|
+
end
|
|
499
|
+
end
|
|
458
500
|
return strip_html(rendered).gsub(/\s+/, " ").strip
|
|
459
501
|
end
|
|
460
502
|
nil
|
|
@@ -564,7 +606,9 @@ module Metanorma
|
|
|
564
606
|
# Remap XML class names to HTML-specific class names
|
|
565
607
|
boilerplate_doc = Nokogiri::HTML::DocumentFragment.parse(clean)
|
|
566
608
|
boilerplate_doc.css("[class]").each do |el|
|
|
567
|
-
el["class"] = el["class"].split(/\s+/).map
|
|
609
|
+
el["class"] = el["class"].split(/\s+/).map do |c|
|
|
610
|
+
html_class_for_span(c)
|
|
611
|
+
end.join(" ")
|
|
568
612
|
end
|
|
569
613
|
|
|
570
614
|
@output << boilerplate_doc.inner_html.strip
|
|
@@ -603,7 +647,8 @@ module Metanorma
|
|
|
603
647
|
# --- Helpers ---
|
|
604
648
|
|
|
605
649
|
def render_title(section, level)
|
|
606
|
-
title_element = safe_attr(section,
|
|
650
|
+
title_element = safe_attr(section,
|
|
651
|
+
:fmt_title) || safe_attr(section, :title)
|
|
607
652
|
return unless title_element
|
|
608
653
|
|
|
609
654
|
section_id = safe_attr(section, :id)
|
|
@@ -5,19 +5,31 @@ module Metanorma
|
|
|
5
5
|
# Renders StandardDocument components to HTML.
|
|
6
6
|
# Extends BaseRenderer with terms, bibliography, and standard sections.
|
|
7
7
|
class StandardRenderer < BaseRenderer
|
|
8
|
-
register_render Metanorma::StandardDocument::Root,
|
|
8
|
+
register_render Metanorma::StandardDocument::Root,
|
|
9
|
+
:render_standard_document
|
|
9
10
|
register_render Metanorma::StandardDocument::Terms::Term, :render_term
|
|
10
|
-
register_render Metanorma::StandardDocument::Sections::TermsSection,
|
|
11
|
-
|
|
12
|
-
register_render Metanorma::StandardDocument::Sections::
|
|
13
|
-
|
|
14
|
-
register_render Metanorma::StandardDocument::Sections::
|
|
15
|
-
|
|
16
|
-
register_render Metanorma::StandardDocument::Sections::
|
|
17
|
-
|
|
18
|
-
register_render Metanorma::StandardDocument::Sections::
|
|
19
|
-
|
|
20
|
-
register_render Metanorma::StandardDocument::
|
|
11
|
+
register_render Metanorma::StandardDocument::Sections::TermsSection,
|
|
12
|
+
:render_terms_section
|
|
13
|
+
register_render Metanorma::StandardDocument::Sections::StandardReferencesSection,
|
|
14
|
+
:render_references_section
|
|
15
|
+
register_render Metanorma::StandardDocument::Sections::BibliographySection,
|
|
16
|
+
:render_bibliography
|
|
17
|
+
register_render Metanorma::StandardDocument::Sections::ClauseSection,
|
|
18
|
+
:render_clause_section
|
|
19
|
+
register_render Metanorma::StandardDocument::Sections::AnnexSection,
|
|
20
|
+
:render_annex_section
|
|
21
|
+
register_render Metanorma::StandardDocument::Sections::StandardSection,
|
|
22
|
+
:render_standard_section
|
|
23
|
+
register_render Metanorma::StandardDocument::Sections::Abstract,
|
|
24
|
+
:render_abstract_section
|
|
25
|
+
register_render Metanorma::StandardDocument::Sections::Foreword,
|
|
26
|
+
:render_foreword_section
|
|
27
|
+
register_render Metanorma::StandardDocument::Sections::Introduction,
|
|
28
|
+
:render_introduction_section
|
|
29
|
+
register_render Metanorma::StandardDocument::Sections::FloatingTitle,
|
|
30
|
+
:render_floating_title
|
|
31
|
+
register_render Metanorma::StandardDocument::Blocks::AmendBlock,
|
|
32
|
+
:render_amend_block
|
|
21
33
|
|
|
22
34
|
# --- Top-level document rendering ---
|
|
23
35
|
|
|
@@ -48,9 +60,7 @@ module Metanorma
|
|
|
48
60
|
end
|
|
49
61
|
|
|
50
62
|
# Index section from indexsect element (presentation XML)
|
|
51
|
-
|
|
52
|
-
render(doc.indexsect)
|
|
53
|
-
end
|
|
63
|
+
render(doc.indexsect) if doc.indexsect
|
|
54
64
|
|
|
55
65
|
# Footnotes section
|
|
56
66
|
render_footnotes_section
|
|
@@ -117,7 +127,8 @@ module Metanorma
|
|
|
117
127
|
|
|
118
128
|
# --- Section rendering ---
|
|
119
129
|
|
|
120
|
-
def render_section(section, level: 1, title_class: nil,
|
|
130
|
+
def render_section(section, level: 1, title_class: nil,
|
|
131
|
+
with_subsections: false, with_terms: false)
|
|
121
132
|
attrs = element_attrs(id: safe_attr(section, :id))
|
|
122
133
|
tag("div", attrs) do
|
|
123
134
|
if title_class
|
|
@@ -184,12 +195,22 @@ module Metanorma
|
|
|
184
195
|
|
|
185
196
|
# Domain
|
|
186
197
|
if term.domain
|
|
187
|
-
domain_text = term.domain.is_a?(String)
|
|
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
|
|
188
205
|
@output << "<p class=\"term-domain\"><#{escape_html(domain_text)}></p>" unless domain_text.to_s.empty?
|
|
189
206
|
end
|
|
190
207
|
|
|
191
208
|
# Definitions
|
|
192
|
-
|
|
209
|
+
if term.definition
|
|
210
|
+
Array(term.definition).each do |defn|
|
|
211
|
+
render_term_definition(defn)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
193
214
|
|
|
194
215
|
# Notes (mapped from <termnote>)
|
|
195
216
|
term.note&.each_with_index do |note, i|
|
|
@@ -222,10 +243,10 @@ module Metanorma
|
|
|
222
243
|
def extract_designation_name(designation)
|
|
223
244
|
if designation.is_a?(Metanorma::StandardDocument::Terms::Designation) && designation.expression
|
|
224
245
|
expr = designation.expression
|
|
225
|
-
if expr.is_a?(Metanorma::
|
|
246
|
+
if expr.is_a?(Metanorma::StandardDocument::Terms::TermExpression) && expr.name
|
|
226
247
|
Array(expr.name).join
|
|
227
248
|
end
|
|
228
|
-
elsif designation.is_a?(Metanorma::
|
|
249
|
+
elsif designation.is_a?(Metanorma::StandardDocument::Terms::TermExpression) && designation.name
|
|
229
250
|
Array(designation.name).join
|
|
230
251
|
else
|
|
231
252
|
extract_text_value(designation)
|
|
@@ -313,7 +334,9 @@ module Metanorma
|
|
|
313
334
|
|
|
314
335
|
def render_bibliography(bib, level: 1, **_opts)
|
|
315
336
|
tag("div", "") do
|
|
316
|
-
bib.references&.each
|
|
337
|
+
bib.references&.each do |ref|
|
|
338
|
+
render_references_section(ref, level: level)
|
|
339
|
+
end
|
|
317
340
|
bib.clause&.each { |cl| render(cl, level: level) }
|
|
318
341
|
end
|
|
319
342
|
end
|
|
@@ -322,10 +345,13 @@ module Metanorma
|
|
|
322
345
|
is_normative = safe_attr(section, :normative) == "true"
|
|
323
346
|
attrs = element_attrs(id: safe_attr(section, :id))
|
|
324
347
|
tag("div", attrs) do
|
|
325
|
-
render_standard_title(section, level,
|
|
348
|
+
render_standard_title(section, level,
|
|
349
|
+
default_class: is_normative ? "" : "section-sub")
|
|
326
350
|
section.p&.each { |para| render_paragraph(para) }
|
|
327
351
|
section.note&.each { |note| render_paragraph(note) }
|
|
328
|
-
section.references&.each_with_index
|
|
352
|
+
section.references&.each_with_index do |bibitem, i|
|
|
353
|
+
render_bibitem(bibitem, i + 1, normative: is_normative)
|
|
354
|
+
end
|
|
329
355
|
section.table&.each { |t| render_table(t) }
|
|
330
356
|
end
|
|
331
357
|
end
|
|
@@ -365,7 +391,9 @@ module Metanorma
|
|
|
365
391
|
return preferred.content.to_s if preferred && !preferred.content.to_s.empty?
|
|
366
392
|
|
|
367
393
|
# Fallback: first non-RSS link
|
|
368
|
-
non_rss = links.find
|
|
394
|
+
non_rss = links.find do |l|
|
|
395
|
+
!l.content.to_s.include?(".rss") && !l.content.to_s.empty?
|
|
396
|
+
end
|
|
369
397
|
non_rss&.content&.to_s
|
|
370
398
|
end
|
|
371
399
|
|
|
@@ -403,7 +431,9 @@ module Metanorma
|
|
|
403
431
|
|
|
404
432
|
if item.title && !item.title.empty?
|
|
405
433
|
titles = Array(item.title)
|
|
406
|
-
main_title = titles.find
|
|
434
|
+
main_title = titles.find do |t|
|
|
435
|
+
safe_attr(t, :type) == "main"
|
|
436
|
+
end || titles.first
|
|
407
437
|
if main_title
|
|
408
438
|
@output << ", <i>"
|
|
409
439
|
render_mixed_inline(main_title)
|
|
@@ -415,7 +445,8 @@ module Metanorma
|
|
|
415
445
|
# --- Standard section helpers ---
|
|
416
446
|
|
|
417
447
|
def render_standard_title(section, level, default_class: "")
|
|
418
|
-
title_element = safe_attr(section,
|
|
448
|
+
title_element = safe_attr(section,
|
|
449
|
+
:fmt_title) || safe_attr(section, :title)
|
|
419
450
|
return unless title_element
|
|
420
451
|
|
|
421
452
|
section_id = safe_attr(section, :id)
|
|
@@ -457,14 +488,16 @@ module Metanorma
|
|
|
457
488
|
end
|
|
458
489
|
|
|
459
490
|
# Block elements
|
|
460
|
-
%i[tables figures formulas examples notes admonitions sourcecode_blocks
|
|
491
|
+
%i[tables figures formulas examples notes admonitions sourcecode_blocks
|
|
492
|
+
quote_blocks].each do |attr|
|
|
461
493
|
values = safe_attr(section, attr)
|
|
462
494
|
Array(values).each { |v| render(v, level: level + 1) } if values
|
|
463
495
|
end
|
|
464
496
|
end
|
|
465
497
|
|
|
466
498
|
def render_subsections(section, level)
|
|
467
|
-
clauses = safe_attr(section,
|
|
499
|
+
clauses = safe_attr(section,
|
|
500
|
+
:clause) || safe_attr(section, :subsections)
|
|
468
501
|
Array(clauses).each { |cl| render(cl, level: level + 1) } if clauses
|
|
469
502
|
end
|
|
470
503
|
|