metanorma-document 0.2.2 → 0.2.3
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 +12 -11
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/html/base_renderer.rb +222 -147
- data/lib/metanorma/html/iso_renderer.rb +14 -39
- data/lib/metanorma/html/standard_renderer.rb +13 -32
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c2f0bcb971c3831683b2786c9596f336f6c80597b8747ed05fb7f195eb6dc492
|
|
4
|
+
data.tar.gz: bf6154b258dda4bc3e5c6eb8073001d214ee6268f2b5747bb9f73683950f6fa7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 74d4cf3024d3096c93df42af04695cbf01581e82ef3e4ac5771900e1fc729bba43f53a5070f748d640755c69a4c54df4cc242558407e26ccad67be91ceac4faa
|
|
7
|
+
data.tar.gz: 821daad319b1f3a38457082d3719af6cc23c7f7843bae9eb50841784b9c4a4f8466b9b75ef61aaf3c0079f2081b91194292a3a574cf15b5e2f12f73a01d1f902
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on 2026-05-06
|
|
3
|
+
# on 2026-05-06 10:09:39 UTC using RuboCop version 1.86.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
@@ -54,7 +54,7 @@ Layout/ExtraSpacing:
|
|
|
54
54
|
- 'lib/metanorma/html/iho_renderer.rb'
|
|
55
55
|
- 'lib/metanorma/html/theme.rb'
|
|
56
56
|
|
|
57
|
-
# Offense count:
|
|
57
|
+
# Offense count: 809
|
|
58
58
|
# This cop supports safe autocorrection (--autocorrect).
|
|
59
59
|
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
60
60
|
# URISchemes: http, https
|
|
@@ -79,7 +79,7 @@ Lint/ConstantDefinitionInBlock:
|
|
|
79
79
|
Exclude:
|
|
80
80
|
- 'spec/metanorma/html/renderer/class_ownership_spec.rb'
|
|
81
81
|
|
|
82
|
-
# Offense count:
|
|
82
|
+
# Offense count: 1
|
|
83
83
|
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
|
|
84
84
|
Lint/DuplicateBranch:
|
|
85
85
|
Exclude:
|
|
@@ -118,7 +118,7 @@ Lint/UselessConstantScoping:
|
|
|
118
118
|
Exclude:
|
|
119
119
|
- 'lib/metanorma/html/base_renderer.rb'
|
|
120
120
|
|
|
121
|
-
# Offense count:
|
|
121
|
+
# Offense count: 80
|
|
122
122
|
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
|
|
123
123
|
Metrics/AbcSize:
|
|
124
124
|
Enabled: false
|
|
@@ -134,7 +134,7 @@ Metrics/BlockLength:
|
|
|
134
134
|
Metrics/BlockNesting:
|
|
135
135
|
Max: 4
|
|
136
136
|
|
|
137
|
-
# Offense count:
|
|
137
|
+
# Offense count: 60
|
|
138
138
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
139
139
|
Metrics/CyclomaticComplexity:
|
|
140
140
|
Exclude:
|
|
@@ -153,17 +153,17 @@ Metrics/CyclomaticComplexity:
|
|
|
153
153
|
- 'lib/metanorma/html/theme.rb'
|
|
154
154
|
- 'lib/metanorma/iso_document/metadata/iso_localized_title.rb'
|
|
155
155
|
|
|
156
|
-
# Offense count:
|
|
156
|
+
# Offense count: 85
|
|
157
157
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
158
158
|
Metrics/MethodLength:
|
|
159
|
-
Max:
|
|
159
|
+
Max: 75
|
|
160
160
|
|
|
161
161
|
# Offense count: 1
|
|
162
162
|
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
|
163
163
|
Metrics/ParameterLists:
|
|
164
164
|
Max: 7
|
|
165
165
|
|
|
166
|
-
# Offense count:
|
|
166
|
+
# Offense count: 54
|
|
167
167
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
168
168
|
Metrics/PerceivedComplexity:
|
|
169
169
|
Exclude:
|
|
@@ -190,7 +190,7 @@ Naming/BlockForwarding:
|
|
|
190
190
|
Exclude:
|
|
191
191
|
- 'lib/metanorma/html/component/footnote_collector.rb'
|
|
192
192
|
|
|
193
|
-
# Offense count:
|
|
193
|
+
# Offense count: 39
|
|
194
194
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
195
195
|
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
|
196
196
|
Naming/MethodParameterName:
|
|
@@ -219,7 +219,7 @@ Naming/PredicatePrefix:
|
|
|
219
219
|
Exclude:
|
|
220
220
|
- 'lib/metanorma/html/standard_renderer.rb'
|
|
221
221
|
|
|
222
|
-
# Offense count:
|
|
222
|
+
# Offense count: 14
|
|
223
223
|
# Configuration parameters: IgnoredMetadata.
|
|
224
224
|
RSpec/DescribeClass:
|
|
225
225
|
Exclude:
|
|
@@ -227,6 +227,7 @@ RSpec/DescribeClass:
|
|
|
227
227
|
- 'spec/metanorma/html/renderer/class_ownership_spec.rb'
|
|
228
228
|
- 'spec/metanorma/html/renderer/dead_code_removal_spec.rb'
|
|
229
229
|
- 'spec/metanorma/html/renderer/section_rendering_spec.rb'
|
|
230
|
+
- 'spec/metanorma/html/renderer/type_registry_spec.rb'
|
|
230
231
|
- 'spec/metanorma/iso_document/metadata/title_roundtrip_spec.rb'
|
|
231
232
|
- 'spec/metanorma/iso_document/roundtrip/bipm_roundtrip_spec.rb'
|
|
232
233
|
- 'spec/metanorma/iso_document/roundtrip/cc_roundtrip_spec.rb'
|
|
@@ -252,7 +253,7 @@ RSpec/MultipleDescribes:
|
|
|
252
253
|
Exclude:
|
|
253
254
|
- 'spec/metanorma/document_spec.rb'
|
|
254
255
|
|
|
255
|
-
# Offense count:
|
|
256
|
+
# Offense count: 303
|
|
256
257
|
# Configuration parameters: AllowedPatterns.
|
|
257
258
|
# AllowedPatterns: ^expect_, ^assert_
|
|
258
259
|
RSpec/NoExpectationExample:
|
|
@@ -49,6 +49,26 @@ module Metanorma
|
|
|
49
49
|
|
|
50
50
|
METANORMA_LOGO = "metanorma-logo.svg"
|
|
51
51
|
|
|
52
|
+
# Type-to-method registry for OCP dispatch.
|
|
53
|
+
# Each subclass gets its own hash; lookup traverses ancestors.
|
|
54
|
+
class << self
|
|
55
|
+
def render_registry
|
|
56
|
+
@render_registry ||= {}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def register_render(type_class, method_name)
|
|
60
|
+
render_registry[type_class] = method_name
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def inline_registry
|
|
64
|
+
@inline_registry ||= {}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def register_inline_render(type_class, method_name)
|
|
68
|
+
inline_registry[type_class] = method_name
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
52
72
|
def initialize
|
|
53
73
|
@output = +""
|
|
54
74
|
@toc_entries = []
|
|
@@ -469,54 +489,125 @@ module Metanorma
|
|
|
469
489
|
parts.join.strip.gsub("\u00A0", " ")
|
|
470
490
|
end
|
|
471
491
|
|
|
472
|
-
# Dispatch to the appropriate render method
|
|
492
|
+
# Dispatch to the appropriate render method via type registry.
|
|
493
|
+
# Lookups traverse the ancestor chain so subclasses inherit
|
|
494
|
+
# parent registrations and can override them independently.
|
|
473
495
|
def render(node, **)
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
render_example(node, **)
|
|
491
|
-
when Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock
|
|
492
|
-
render_sourcecode(node, **)
|
|
493
|
-
when Metanorma::Document::Components::AncillaryBlocks::FormulaBlock
|
|
494
|
-
render_formula(node, **)
|
|
495
|
-
when Metanorma::Document::Components::MultiParagraph::QuoteBlock
|
|
496
|
-
render_quote(node, **)
|
|
497
|
-
when Metanorma::Document::Components::MultiParagraph::AdmonitionBlock
|
|
498
|
-
render_admonition(node, **)
|
|
499
|
-
when Metanorma::Document::Components::Sections::HierarchicalSection
|
|
500
|
-
render_hierarchical_section(node, **)
|
|
501
|
-
when Metanorma::Document::Components::Sections::BasicSection
|
|
502
|
-
render_basic_section(node, **)
|
|
503
|
-
when Metanorma::Document::Components::Sections::ContentSection
|
|
504
|
-
render_content_section(node, **)
|
|
505
|
-
when Metanorma::Document::Components::EmptyElements::PageBreakElement
|
|
506
|
-
""
|
|
507
|
-
when Metanorma::Document::Components::IdElements::Bookmark
|
|
508
|
-
render_bookmark(node)
|
|
509
|
-
when Metanorma::Document::Components::Inline::SemxElement
|
|
510
|
-
render_semx_content(node)
|
|
511
|
-
when String
|
|
512
|
-
escape_html(node)
|
|
513
|
-
else
|
|
514
|
-
""
|
|
496
|
+
return escape_html(node) if node.is_a?(String)
|
|
497
|
+
|
|
498
|
+
method = lookup_dispatch(node.class, :render_registry)
|
|
499
|
+
method ? send(method, node, **) : ""
|
|
500
|
+
end
|
|
501
|
+
|
|
502
|
+
# Dispatch to the appropriate inline render method via type registry.
|
|
503
|
+
def render_inline_element(element, **)
|
|
504
|
+
return "" if element.nil?
|
|
505
|
+
return escape_html(element) if element.is_a?(String)
|
|
506
|
+
|
|
507
|
+
method = lookup_dispatch(element.class, :inline_registry)
|
|
508
|
+
if method
|
|
509
|
+
send(method, element)
|
|
510
|
+
elsif element.is_a?(Lutaml::Model::Serializable) && element.mixed?
|
|
511
|
+
render_mixed_inline(element)
|
|
515
512
|
end
|
|
516
513
|
end
|
|
517
514
|
|
|
515
|
+
# --- Type registrations (class-level, evaluated at class load time) ---
|
|
516
|
+
|
|
517
|
+
register_render Metanorma::Document::Components::Paragraphs::ParagraphBlock, :render_paragraph
|
|
518
|
+
register_render Metanorma::Document::Components::Tables::TableBlock, :render_table
|
|
519
|
+
register_render Metanorma::Document::Components::Lists::UnorderedList, :render_unordered_list
|
|
520
|
+
register_render Metanorma::Document::Components::Lists::OrderedList, :render_ordered_list
|
|
521
|
+
register_render Metanorma::Document::Components::Lists::DefinitionList, :render_definition_list
|
|
522
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::FigureBlock, :render_figure
|
|
523
|
+
register_render Metanorma::Document::Components::Blocks::NoteBlock, :render_note
|
|
524
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::ExampleBlock, :render_example
|
|
525
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock, :render_sourcecode
|
|
526
|
+
register_render Metanorma::Document::Components::AncillaryBlocks::FormulaBlock, :render_formula
|
|
527
|
+
register_render Metanorma::Document::Components::MultiParagraph::QuoteBlock, :render_quote
|
|
528
|
+
register_render Metanorma::Document::Components::MultiParagraph::AdmonitionBlock, :render_admonition
|
|
529
|
+
register_render Metanorma::Document::Components::Sections::HierarchicalSection, :render_hierarchical_section
|
|
530
|
+
register_render Metanorma::Document::Components::Sections::BasicSection, :render_basic_section
|
|
531
|
+
register_render Metanorma::Document::Components::Sections::ContentSection, :render_content_section
|
|
532
|
+
register_render Metanorma::Document::Components::EmptyElements::PageBreakElement, :render_noop
|
|
533
|
+
register_render Metanorma::Document::Components::IdElements::Bookmark, :render_bookmark
|
|
534
|
+
register_render Metanorma::Document::Components::Inline::SemxElement, :render_semx_content
|
|
535
|
+
|
|
536
|
+
register_inline_render Metanorma::Document::Components::Inline::EmRawElement, :render_em
|
|
537
|
+
register_inline_render Metanorma::Document::Components::Inline::StrongRawElement, :render_strong
|
|
538
|
+
register_inline_render Metanorma::Document::Components::Inline::TtElement, :render_tt
|
|
539
|
+
register_inline_render Metanorma::Document::Components::Inline::SubElement, :render_sub
|
|
540
|
+
register_inline_render Metanorma::Document::Components::Inline::SupElement, :render_sup
|
|
541
|
+
register_inline_render Metanorma::Document::Components::Inline::SmallCapElement, :render_small_caps
|
|
542
|
+
register_inline_render Metanorma::Document::Components::TextElements::UnderlineElement, :render_underline
|
|
543
|
+
register_inline_render Metanorma::Document::Components::TextElements::StrikeElement, :render_strike
|
|
544
|
+
register_inline_render Metanorma::Document::Components::Inline::BrElement, :render_br
|
|
545
|
+
register_inline_render Metanorma::Document::Components::Inline::TabElement, :render_tab
|
|
546
|
+
register_inline_render Metanorma::Document::Components::Inline::LinkElement, :render_link
|
|
547
|
+
register_inline_render Metanorma::Document::Components::Inline::XrefElement, :render_noop_inline
|
|
548
|
+
register_inline_render Metanorma::Document::Components::Inline::ErefElement, :render_noop_inline
|
|
549
|
+
register_inline_render Metanorma::Document::Components::Inline::SpanElement, :render_span
|
|
550
|
+
register_inline_render Metanorma::Document::Components::Inline::FnElement, :render_fn_inline
|
|
551
|
+
register_inline_render Metanorma::Document::Components::Inline::ConceptElement, :render_concept
|
|
552
|
+
register_inline_render Metanorma::Document::Components::Inline::StemInlineElement, :render_noop_inline
|
|
553
|
+
register_inline_render Metanorma::Document::Components::TextElements::StemElement, :render_stem
|
|
554
|
+
register_inline_render Metanorma::Document::Components::Inline::SemxElement, :render_semx_inline
|
|
555
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtXrefElement, :render_fmt_xref
|
|
556
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtStemElement, :render_fmt_stem
|
|
557
|
+
register_inline_render Metanorma::Document::Components::Inline::CommaElement, :render_comma
|
|
558
|
+
register_inline_render Metanorma::Document::Components::Inline::EnumCommaElement, :render_comma
|
|
559
|
+
register_inline_render Metanorma::Document::Components::IdElements::Bookmark, :render_bookmark
|
|
560
|
+
register_inline_render Metanorma::Document::Components::IdElements::Image, :render_image
|
|
561
|
+
register_inline_render Metanorma::Document::Components::Inline::MathElement, :render_math
|
|
562
|
+
register_inline_render Metanorma::Document::Components::Inline::AsciimathElement, :render_asciimath
|
|
563
|
+
register_inline_render Metanorma::Document::Components::EmptyElements::IndexElement, :render_index
|
|
564
|
+
register_inline_render Metanorma::Document::Components::ReferenceElements::IndexXrefElement, :render_index
|
|
565
|
+
register_inline_render Metanorma::Document::Components::Blocks::NoteBlock, :render_note_inline
|
|
566
|
+
# All Fmt* elements delegate to render_mixed_inline
|
|
567
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtNameElement, :render_mixed_inline
|
|
568
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtTitleElement, :render_mixed_inline
|
|
569
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtXrefLabelElement, :render_mixed_inline
|
|
570
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtFnLabelElement, :render_mixed_inline
|
|
571
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtConceptElement, :render_mixed_inline
|
|
572
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationStartElement, :render_mixed_inline
|
|
573
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationEndElement, :render_mixed_inline
|
|
574
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationBodyElement, :render_mixed_inline
|
|
575
|
+
register_inline_render Metanorma::Document::Components::Inline::VariantTitleElement, :render_mixed_inline
|
|
576
|
+
register_inline_render Metanorma::Document::Components::Inline::LocalizedStringElement, :render_mixed_inline
|
|
577
|
+
register_inline_render Metanorma::Document::Components::Inline::TitleWithAnnotationElement, :render_mixed_inline
|
|
578
|
+
register_inline_render Metanorma::Document::Components::Inline::BiblioTagElement, :render_mixed_inline
|
|
579
|
+
register_inline_render Metanorma::Document::Components::Inline::NameWithIdElement, :render_mixed_inline
|
|
580
|
+
register_inline_render Metanorma::Document::Components::Inline::DisplayTextElement, :render_mixed_inline
|
|
581
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtFootnoteContainerElement, :render_mixed_inline
|
|
582
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtFnBodyElement, :render_mixed_inline
|
|
583
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtPreferredElement, :render_mixed_inline
|
|
584
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtDefinitionElement, :render_mixed_inline
|
|
585
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtTermsourceElement, :render_mixed_inline
|
|
586
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtAdmittedElement, :render_mixed_inline
|
|
587
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtIdentifierElement, :render_mixed_inline
|
|
588
|
+
register_inline_render Metanorma::Document::Components::Inline::FmtSourcecodeElement, :render_mixed_inline
|
|
589
|
+
|
|
518
590
|
private
|
|
519
591
|
|
|
592
|
+
def lookup_dispatch(type_class, registry_method)
|
|
593
|
+
self.class.ancestors.each do |ancestor|
|
|
594
|
+
next unless ancestor.respond_to?(registry_method)
|
|
595
|
+
|
|
596
|
+
registry = ancestor.send(registry_method)
|
|
597
|
+
method_name = registry[type_class]
|
|
598
|
+
return method_name if method_name
|
|
599
|
+
end
|
|
600
|
+
nil
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
def render_noop(*)
|
|
604
|
+
""
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
def render_noop_inline(*)
|
|
608
|
+
nil
|
|
609
|
+
end
|
|
610
|
+
|
|
520
611
|
# --- Block-level rendering ---
|
|
521
612
|
|
|
522
613
|
def render_paragraph(p, **_opts)
|
|
@@ -801,7 +892,7 @@ module Metanorma
|
|
|
801
892
|
@output << render_liquid("_admonition.html.liquid", { "block" => drop })
|
|
802
893
|
end
|
|
803
894
|
|
|
804
|
-
def render_bookmark(bookmark)
|
|
895
|
+
def render_bookmark(bookmark, **_opts)
|
|
805
896
|
@output << %(<a id="#{escape_html(safe_attr(bookmark, :id).to_s)}"></a>)
|
|
806
897
|
end
|
|
807
898
|
|
|
@@ -1023,114 +1114,98 @@ module Metanorma
|
|
|
1023
1114
|
end
|
|
1024
1115
|
end
|
|
1025
1116
|
|
|
1026
|
-
|
|
1027
|
-
return "" if element.nil?
|
|
1117
|
+
# Inline adapter methods for registry dispatch
|
|
1028
1118
|
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
Metanorma::Document::Components::Inline::FmtDefinitionElement,
|
|
1094
|
-
Metanorma::Document::Components::Inline::FmtTermsourceElement,
|
|
1095
|
-
Metanorma::Document::Components::Inline::FmtAdmittedElement,
|
|
1096
|
-
Metanorma::Document::Components::Inline::FmtIdentifierElement,
|
|
1097
|
-
Metanorma::Document::Components::Inline::FmtSourcecodeElement
|
|
1098
|
-
render_mixed_inline(element)
|
|
1099
|
-
when Metanorma::Document::Components::Inline::FmtXrefElement
|
|
1100
|
-
target = safe_attr(element, :target) || safe_attr(element, :to_attr)
|
|
1101
|
-
if target
|
|
1102
|
-
attrs = element_attrs(href: "##{escape_html(target)}", class: "xref")
|
|
1103
|
-
tag("a", attrs) { render_mixed_inline(element) }
|
|
1104
|
-
else
|
|
1105
|
-
render_mixed_inline(element)
|
|
1106
|
-
end
|
|
1107
|
-
when Metanorma::Document::Components::Inline::FmtStemElement
|
|
1108
|
-
render_fmt_stem(element)
|
|
1109
|
-
when Metanorma::Document::Components::Inline::CommaElement,
|
|
1110
|
-
Metanorma::Document::Components::Inline::EnumCommaElement
|
|
1111
|
-
@output << ", "
|
|
1112
|
-
when Metanorma::Document::Components::IdElements::Bookmark
|
|
1113
|
-
render_bookmark(element)
|
|
1114
|
-
when Metanorma::Document::Components::IdElements::Image
|
|
1115
|
-
render_image(element)
|
|
1116
|
-
when Metanorma::Document::Components::Inline::MathElement
|
|
1117
|
-
@output << element.content.to_s
|
|
1118
|
-
when Metanorma::Document::Components::Inline::AsciimathElement
|
|
1119
|
-
@output << %(<span class="stem">#{escape_html(Array(element.text).join)}</span>)
|
|
1120
|
-
when Metanorma::Document::Components::EmptyElements::IndexElement,
|
|
1121
|
-
Metanorma::Document::Components::ReferenceElements::IndexXrefElement
|
|
1122
|
-
collect_index_term(element)
|
|
1123
|
-
""
|
|
1124
|
-
when Metanorma::Document::Components::Blocks::NoteBlock
|
|
1125
|
-
render_note(element)
|
|
1119
|
+
def render_em(el)
|
|
1120
|
+
render_inline_tag("em", el)
|
|
1121
|
+
end
|
|
1122
|
+
|
|
1123
|
+
def render_strong(el)
|
|
1124
|
+
render_inline_tag("strong", el)
|
|
1125
|
+
end
|
|
1126
|
+
|
|
1127
|
+
def render_tt(el)
|
|
1128
|
+
render_inline_tag("tt", el)
|
|
1129
|
+
end
|
|
1130
|
+
|
|
1131
|
+
def render_sub(el)
|
|
1132
|
+
render_inline_tag("sub", el)
|
|
1133
|
+
end
|
|
1134
|
+
|
|
1135
|
+
def render_sup(el)
|
|
1136
|
+
render_inline_tag("sup", el)
|
|
1137
|
+
end
|
|
1138
|
+
|
|
1139
|
+
def render_small_caps(el)
|
|
1140
|
+
render_inline_tag("span", el, class: "small-caps")
|
|
1141
|
+
end
|
|
1142
|
+
|
|
1143
|
+
def render_underline(el)
|
|
1144
|
+
render_inline_tag("u", el)
|
|
1145
|
+
end
|
|
1146
|
+
|
|
1147
|
+
def render_strike(el)
|
|
1148
|
+
render_inline_tag("s", el)
|
|
1149
|
+
end
|
|
1150
|
+
|
|
1151
|
+
def render_br(*)
|
|
1152
|
+
@output << "<br />"
|
|
1153
|
+
end
|
|
1154
|
+
|
|
1155
|
+
def render_tab(*)
|
|
1156
|
+
@output << "\u00a0\u00a0"
|
|
1157
|
+
end
|
|
1158
|
+
|
|
1159
|
+
def render_span(el)
|
|
1160
|
+
xml_class = safe_attr(el, :class_attr).to_s
|
|
1161
|
+
html_class = html_class_for_span(xml_class) unless xml_class.empty?
|
|
1162
|
+
attrs = element_attrs(style: safe_attr(el, :style), class: html_class)
|
|
1163
|
+
tag("span", attrs) { render_mixed_inline(el) }
|
|
1164
|
+
end
|
|
1165
|
+
|
|
1166
|
+
def render_fn_inline(el)
|
|
1167
|
+
render_fn(el)
|
|
1168
|
+
end
|
|
1169
|
+
|
|
1170
|
+
def render_stem(el)
|
|
1171
|
+
@output << render_stem_content(el)
|
|
1172
|
+
end
|
|
1173
|
+
|
|
1174
|
+
def render_semx_inline(el)
|
|
1175
|
+
render_semx_content(el)
|
|
1176
|
+
end
|
|
1177
|
+
|
|
1178
|
+
def render_fmt_xref(el)
|
|
1179
|
+
target = safe_attr(el, :target) || safe_attr(el, :to_attr)
|
|
1180
|
+
if target
|
|
1181
|
+
attrs = element_attrs(href: "##{escape_html(target)}", class: "xref")
|
|
1182
|
+
tag("a", attrs) { render_mixed_inline(el) }
|
|
1126
1183
|
else
|
|
1127
|
-
|
|
1128
|
-
if element.is_a?(Lutaml::Model::Serializable) && element.mixed?
|
|
1129
|
-
render_mixed_inline(element)
|
|
1130
|
-
end
|
|
1184
|
+
render_mixed_inline(el)
|
|
1131
1185
|
end
|
|
1132
1186
|
end
|
|
1133
1187
|
|
|
1188
|
+
def render_comma(*)
|
|
1189
|
+
@output << ", "
|
|
1190
|
+
end
|
|
1191
|
+
|
|
1192
|
+
def render_math(el)
|
|
1193
|
+
@output << el.content.to_s
|
|
1194
|
+
end
|
|
1195
|
+
|
|
1196
|
+
def render_asciimath(el)
|
|
1197
|
+
@output << %(<span class="stem">#{escape_html(Array(el.text).join)}</span>)
|
|
1198
|
+
end
|
|
1199
|
+
|
|
1200
|
+
def render_index(el)
|
|
1201
|
+
collect_index_term(el)
|
|
1202
|
+
""
|
|
1203
|
+
end
|
|
1204
|
+
|
|
1205
|
+
def render_note_inline(el)
|
|
1206
|
+
render_note(el)
|
|
1207
|
+
end
|
|
1208
|
+
|
|
1134
1209
|
def render_inline_collections(node)
|
|
1135
1210
|
# Fallback: render text and inline collections sequentially
|
|
1136
1211
|
texts = node.text
|
|
@@ -1164,7 +1239,7 @@ module Metanorma
|
|
|
1164
1239
|
# Render SemxElement display content only, skipping semantic linkage.
|
|
1165
1240
|
# semx wraps both semantic data (origin, xref, source, etc.) and
|
|
1166
1241
|
# display content (fmt-xref, span, strong, etc.). Only render display.
|
|
1167
|
-
def render_semx_content(element)
|
|
1242
|
+
def render_semx_content(element, **_opts)
|
|
1168
1243
|
display_attrs = %i[text fmt_xref fmt_link fmt_concept span strong em sup p semx
|
|
1169
1244
|
asciimath math sub_child tt_child br_child tab_child
|
|
1170
1245
|
stem_child figure_child formula_child sourcecode_child]
|
|
@@ -51,45 +51,20 @@ module Metanorma
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
when Metanorma::IsoDocument::Sections::IsoForewordSection
|
|
69
|
-
render_foreword(node, **)
|
|
70
|
-
when Metanorma::IsoDocument::Sections::IsoAbstractSection
|
|
71
|
-
render_abstract(node, **)
|
|
72
|
-
when Metanorma::IsoDocument::Terms::IsoTerm
|
|
73
|
-
render_term(node, **)
|
|
74
|
-
when Metanorma::IsoDocument::Terms::TermNote
|
|
75
|
-
render_term_note(node, **)
|
|
76
|
-
when Metanorma::IsoDocument::Terms::TermExample
|
|
77
|
-
render_term_example(node, **)
|
|
78
|
-
when Metanorma::IsoDocument::Boilerplate
|
|
79
|
-
render_boilerplate(node, **)
|
|
80
|
-
else
|
|
81
|
-
super
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def render_inline_element(element)
|
|
86
|
-
case element
|
|
87
|
-
when Metanorma::IsoDocument::Terms::TermOrigin
|
|
88
|
-
render_term_origin(element)
|
|
89
|
-
else
|
|
90
|
-
super
|
|
91
|
-
end
|
|
92
|
-
end
|
|
54
|
+
register_render Metanorma::IsoDocument::Root, :render_document
|
|
55
|
+
register_render Metanorma::IsoDocument::Sections::IsoPreface, :render_preface
|
|
56
|
+
register_render Metanorma::IsoDocument::Sections::IsoSections, :render_sections
|
|
57
|
+
register_render Metanorma::IsoDocument::Sections::IsoClauseSection, :render_clause
|
|
58
|
+
register_render Metanorma::IsoDocument::Sections::IsoAnnexSection, :render_annex
|
|
59
|
+
register_render Metanorma::IsoDocument::Sections::IsoTermsSection, :render_terms_section
|
|
60
|
+
register_render Metanorma::IsoDocument::Sections::IsoForewordSection, :render_foreword
|
|
61
|
+
register_render Metanorma::IsoDocument::Sections::IsoAbstractSection, :render_abstract
|
|
62
|
+
register_render Metanorma::IsoDocument::Terms::IsoTerm, :render_term
|
|
63
|
+
register_render Metanorma::IsoDocument::Terms::TermNote, :render_term_note
|
|
64
|
+
register_render Metanorma::IsoDocument::Terms::TermExample, :render_term_example
|
|
65
|
+
register_render Metanorma::IsoDocument::Boilerplate, :render_boilerplate
|
|
66
|
+
|
|
67
|
+
register_inline_render Metanorma::IsoDocument::Terms::TermOrigin, :render_term_origin
|
|
93
68
|
|
|
94
69
|
def render_term_origin(element)
|
|
95
70
|
text = extract_text_value(element)
|
|
@@ -5,38 +5,19 @@ 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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
render_clause_section(node, **)
|
|
22
|
-
when Metanorma::StandardDocument::Sections::AnnexSection
|
|
23
|
-
render_annex_section(node, **)
|
|
24
|
-
when Metanorma::StandardDocument::Sections::StandardSection
|
|
25
|
-
render_standard_section(node, **)
|
|
26
|
-
when Metanorma::StandardDocument::Sections::Abstract
|
|
27
|
-
render_abstract_section(node, **)
|
|
28
|
-
when Metanorma::StandardDocument::Sections::Foreword
|
|
29
|
-
render_foreword_section(node, **)
|
|
30
|
-
when Metanorma::StandardDocument::Sections::Introduction
|
|
31
|
-
render_introduction_section(node, **)
|
|
32
|
-
when Metanorma::StandardDocument::Sections::FloatingTitle
|
|
33
|
-
render_floating_title(node, **)
|
|
34
|
-
when Metanorma::StandardDocument::Blocks::AmendBlock
|
|
35
|
-
render_amend_block(node, **)
|
|
36
|
-
else
|
|
37
|
-
super
|
|
38
|
-
end
|
|
39
|
-
end
|
|
8
|
+
register_render Metanorma::StandardDocument::Root, :render_standard_document
|
|
9
|
+
register_render Metanorma::StandardDocument::Terms::Term, :render_term
|
|
10
|
+
register_render Metanorma::StandardDocument::Sections::TermsSection, :render_terms_section
|
|
11
|
+
register_render Metanorma::StandardDocument::Sections::StandardReferencesSection, :render_references_section
|
|
12
|
+
register_render Metanorma::StandardDocument::Sections::BibliographySection, :render_bibliography
|
|
13
|
+
register_render Metanorma::StandardDocument::Sections::ClauseSection, :render_clause_section
|
|
14
|
+
register_render Metanorma::StandardDocument::Sections::AnnexSection, :render_annex_section
|
|
15
|
+
register_render Metanorma::StandardDocument::Sections::StandardSection, :render_standard_section
|
|
16
|
+
register_render Metanorma::StandardDocument::Sections::Abstract, :render_abstract_section
|
|
17
|
+
register_render Metanorma::StandardDocument::Sections::Foreword, :render_foreword_section
|
|
18
|
+
register_render Metanorma::StandardDocument::Sections::Introduction, :render_introduction_section
|
|
19
|
+
register_render Metanorma::StandardDocument::Sections::FloatingTitle, :render_floating_title
|
|
20
|
+
register_render Metanorma::StandardDocument::Blocks::AmendBlock, :render_amend_block
|
|
40
21
|
|
|
41
22
|
private
|
|
42
23
|
|