metanorma-document 0.2.2 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d03f7b4977f3220a59c871eb1e62e2f00042fd2b56164a41ed6361b18ddb1fd2
4
- data.tar.gz: 274a96e49ab7923362edbcf4733214f7fdca6aa75699623da8c065c8958d5cb3
3
+ metadata.gz: afb9ddd75c55018b0ff15fb41d06a1eddc5fe7448a3841a5a7fd4d4061965756
4
+ data.tar.gz: 52550547f425bbcab7fb88b940eda4798ae842240ec9b53e8c7052737128cfcd
5
5
  SHA512:
6
- metadata.gz: 06a95eb083a619c0eb43c0acd394e171fa812d2e9eb9b592fa0f551568f6eae25f5ec824e787354d8e1c2bb95ad10aedaa10615e0bcb31b2a022bde8f212025a
7
- data.tar.gz: da8eb0c5a86def7f9cd05e173957404a1ca047270d4ee12043cf696687e9ae9a38b01c91fbec7097af074ed3df697e75bf46d934d9a22d1ed0b74a957ee29b1d
6
+ metadata.gz: effae9a6cd899788ea8f22a3fe78583a18094001d38e322f96c0a99cd8c78c1b24084f7ceb7514158474117dea01e471325a78c2ad0ffef30314ce2eca1f7157
7
+ data.tar.gz: bdbd96deb4acee546290fbb5f3fbbb2ea7a2a9a608d0d34800c8fe6dfffc57b9063ac8ec00c7bdec5cedc5b1bccb7bfe0e5593f5ca642c3bc6aca19eaa4bc279
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 04:06:53 UTC using RuboCop version 1.86.1.
3
+ # on 2026-05-06 16:15:52 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
@@ -11,13 +11,14 @@ Gemspec/RequiredRubyVersion:
11
11
  Exclude:
12
12
  - 'metanorma-document.gemspec'
13
13
 
14
- # Offense count: 1
14
+ # Offense count: 5
15
15
  # This cop supports safe autocorrection (--autocorrect).
16
16
  # Configuration parameters: EnforcedStyle, IndentationWidth.
17
17
  # SupportedStyles: with_first_argument, with_fixed_indentation
18
18
  Layout/ArgumentAlignment:
19
19
  Exclude:
20
20
  - 'lib/metanorma/html/component/index_term_collector.rb'
21
+ - 'spec/metanorma/html/renderer/architecture_spec.rb'
21
22
 
22
23
  # Offense count: 5
23
24
  # This cop supports safe autocorrection (--autocorrect).
@@ -54,7 +55,7 @@ Layout/ExtraSpacing:
54
55
  - 'lib/metanorma/html/iho_renderer.rb'
55
56
  - 'lib/metanorma/html/theme.rb'
56
57
 
57
- # Offense count: 718
58
+ # Offense count: 801
58
59
  # This cop supports safe autocorrection (--autocorrect).
59
60
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
60
61
  # URISchemes: http, https
@@ -79,7 +80,7 @@ Lint/ConstantDefinitionInBlock:
79
80
  Exclude:
80
81
  - 'spec/metanorma/html/renderer/class_ownership_spec.rb'
81
82
 
82
- # Offense count: 4
83
+ # Offense count: 1
83
84
  # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
84
85
  Lint/DuplicateBranch:
85
86
  Exclude:
@@ -92,12 +93,14 @@ Lint/EmptyBlock:
92
93
  - 'lib/metanorma/html/drops/formula_drop.rb'
93
94
  - 'spec/metanorma/iso_document/metadata/title_roundtrip_spec.rb'
94
95
 
95
- # Offense count: 2
96
+ # Offense count: 4
96
97
  # Configuration parameters: AllowedParentClasses.
97
98
  Lint/MissingSuper:
98
99
  Exclude:
99
100
  - 'lib/metanorma/html/drops/block_element_drop.rb'
101
+ - 'lib/metanorma/html/drops/figure_list_entry_drop.rb'
100
102
  - 'lib/metanorma/html/drops/footnote_drop.rb'
103
+ - 'lib/metanorma/html/drops/toc_entry_drop.rb'
101
104
 
102
105
  # Offense count: 1
103
106
  Lint/StructNewOverride:
@@ -118,7 +121,7 @@ Lint/UselessConstantScoping:
118
121
  Exclude:
119
122
  - 'lib/metanorma/html/base_renderer.rb'
120
123
 
121
- # Offense count: 85
124
+ # Offense count: 78
122
125
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
123
126
  Metrics/AbcSize:
124
127
  Enabled: false
@@ -134,7 +137,7 @@ Metrics/BlockLength:
134
137
  Metrics/BlockNesting:
135
138
  Max: 4
136
139
 
137
- # Offense count: 64
140
+ # Offense count: 58
138
141
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
139
142
  Metrics/CyclomaticComplexity:
140
143
  Exclude:
@@ -153,17 +156,17 @@ Metrics/CyclomaticComplexity:
153
156
  - 'lib/metanorma/html/theme.rb'
154
157
  - 'lib/metanorma/iso_document/metadata/iso_localized_title.rb'
155
158
 
156
- # Offense count: 89
159
+ # Offense count: 84
157
160
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
158
161
  Metrics/MethodLength:
159
- Max: 104
162
+ Max: 75
160
163
 
161
164
  # Offense count: 1
162
165
  # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
163
166
  Metrics/ParameterLists:
164
167
  Max: 7
165
168
 
166
- # Offense count: 55
169
+ # Offense count: 53
167
170
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
168
171
  Metrics/PerceivedComplexity:
169
172
  Exclude:
@@ -182,15 +185,16 @@ Metrics/PerceivedComplexity:
182
185
  - 'lib/metanorma/html/theme.rb'
183
186
  - 'lib/metanorma/iso_document/metadata/iso_localized_title.rb'
184
187
 
185
- # Offense count: 2
188
+ # Offense count: 4
186
189
  # This cop supports safe autocorrection (--autocorrect).
187
190
  # Configuration parameters: EnforcedStyle, BlockForwardingName.
188
191
  # SupportedStyles: anonymous, explicit
189
192
  Naming/BlockForwarding:
190
193
  Exclude:
194
+ - 'lib/metanorma/html/base_renderer.rb'
191
195
  - 'lib/metanorma/html/component/footnote_collector.rb'
192
196
 
193
- # Offense count: 22
197
+ # Offense count: 28
194
198
  # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
195
199
  # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
196
200
  Naming/MethodParameterName:
@@ -219,14 +223,16 @@ Naming/PredicatePrefix:
219
223
  Exclude:
220
224
  - 'lib/metanorma/html/standard_renderer.rb'
221
225
 
222
- # Offense count: 13
226
+ # Offense count: 15
223
227
  # Configuration parameters: IgnoredMetadata.
224
228
  RSpec/DescribeClass:
225
229
  Exclude:
226
230
  - 'spec/metanorma/document_spec.rb'
231
+ - 'spec/metanorma/html/renderer/architecture_spec.rb'
227
232
  - 'spec/metanorma/html/renderer/class_ownership_spec.rb'
228
233
  - 'spec/metanorma/html/renderer/dead_code_removal_spec.rb'
229
234
  - 'spec/metanorma/html/renderer/section_rendering_spec.rb'
235
+ - 'spec/metanorma/html/renderer/type_registry_spec.rb'
230
236
  - 'spec/metanorma/iso_document/metadata/title_roundtrip_spec.rb'
231
237
  - 'spec/metanorma/iso_document/roundtrip/bipm_roundtrip_spec.rb'
232
238
  - 'spec/metanorma/iso_document/roundtrip/cc_roundtrip_spec.rb'
@@ -252,7 +258,12 @@ RSpec/MultipleDescribes:
252
258
  Exclude:
253
259
  - 'spec/metanorma/document_spec.rb'
254
260
 
255
- # Offense count: 286
261
+ # Offense count: 1
262
+ # Configuration parameters: AllowSubject.
263
+ RSpec/MultipleMemoizedHelpers:
264
+ Max: 7
265
+
266
+ # Offense count: 322
256
267
  # Configuration parameters: AllowedPatterns.
257
268
  # AllowedPatterns: ^expect_, ^assert_
258
269
  RSpec/NoExpectationExample:
@@ -264,7 +275,7 @@ RSpec/NoExpectationExample:
264
275
  RSpec/SpecFilePathFormat:
265
276
  Enabled: false
266
277
 
267
- # Offense count: 2
278
+ # Offense count: 4
268
279
  # This cop supports safe autocorrection (--autocorrect).
269
280
  # Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames.
270
281
  # RedundantRestArgumentNames: args, arguments
@@ -272,6 +283,7 @@ RSpec/SpecFilePathFormat:
272
283
  # RedundantBlockArgumentNames: blk, block, proc
273
284
  Style/ArgumentsForwarding:
274
285
  Exclude:
286
+ - 'lib/metanorma/html/base_renderer.rb'
275
287
  - 'lib/metanorma/html/component/footnote_collector.rb'
276
288
 
277
289
  # Offense count: 1
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Metanorma
4
4
  module Document
5
- VERSION = "0.2.2"
5
+ VERSION = "0.2.4"
6
6
  Version = VERSION
7
7
  end
8
8
  end
@@ -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 = []
@@ -63,33 +83,37 @@ module Metanorma
63
83
  # --- Public API ---
64
84
 
65
85
  # Facade object for Drops to call renderer methods without exposing
66
- # the full private interface. Delegates to the renderer internally.
86
+ # the full private interface. Delegates via method_missing with an
87
+ # explicit allowlist — adding new delegations only requires updating
88
+ # DELEGATED_METHODS, not writing a new one-liner.
67
89
  class RendererContext
90
+ DELEGATED_METHODS = %i[
91
+ safe_attr escape_html extract_block_label extract_plain_text
92
+ capture_output render_paragraph render_mixed_inline
93
+ render_inline_element render_unordered_list render_ordered_list
94
+ render_definition_list render_sourcecode render_table
95
+ render_figure render_quote render_formula render_note
96
+ render_image render_stem_content register_figure_entry
97
+ render_liquid
98
+ ].freeze
99
+
68
100
  def initialize(renderer)
69
101
  @renderer = renderer
70
102
  end
71
103
 
72
- def safe_attr(obj, method_name) = @renderer.send(:safe_attr, obj, method_name)
73
- def escape_html(text) = @renderer.send(:escape_html, text)
74
- def extract_block_label(block, default) = @renderer.send(:extract_block_label, block, default)
75
- def extract_plain_text(node) = @renderer.send(:extract_plain_text, node)
76
- def capture_output(&) = @renderer.send(:capture_output, &)
77
- def render_paragraph(p) = @renderer.send(:render_paragraph, p)
78
- def render_mixed_inline(node) = @renderer.send(:render_mixed_inline, node)
79
- def render_inline_element(el) = @renderer.send(:render_inline_element, el)
80
- def render_unordered_list(ul) = @renderer.send(:render_unordered_list, ul)
81
- def render_ordered_list(ol) = @renderer.send(:render_ordered_list, ol)
82
- def render_definition_list(dl) = @renderer.send(:render_definition_list, dl)
83
- def render_sourcecode(sc) = @renderer.send(:render_sourcecode, sc)
84
- def render_table(t) = @renderer.send(:render_table, t)
85
- def render_figure(f) = @renderer.send(:render_figure, f)
86
- def render_quote(q) = @renderer.send(:render_quote, q)
87
- def render_formula(f) = @renderer.send(:render_formula, f)
88
- def render_note(n) = @renderer.send(:render_note, n)
89
- def render_image(img) = @renderer.send(:render_image, img)
90
- def render_stem_content(stem) = @renderer.send(:render_stem_content, stem)
91
- def register_figure_entry(...) = @renderer.send(:register_figure_entry, ...)
92
- def render_liquid(template_name, assigns) = @renderer.send(:render_liquid, template_name, assigns)
104
+ def respond_to_missing?(method_name, include_private = false)
105
+ DELEGATED_METHODS.include?(method_name) || super
106
+ end
107
+
108
+ private
109
+
110
+ def method_missing(method_name, *args, **kwargs, &block)
111
+ if DELEGATED_METHODS.include?(method_name)
112
+ @renderer.send(method_name, *args, **kwargs, &block)
113
+ else
114
+ super
115
+ end
116
+ end
93
117
  end
94
118
 
95
119
  def renderer_context
@@ -245,41 +269,17 @@ module Metanorma
245
269
  # --- ToC generation ---
246
270
 
247
271
  def build_toc_html(entries)
248
- top_lines = []
249
- main_lines = if entries.empty?
250
- ["<li class=\"toc-empty\">No entries</li>"]
251
- else
252
- entries.map do |e|
253
- id = e[:id].to_s
254
- text = escape_html(e[:text].to_s)
255
- lvl = e[:level]
256
- "<li class=\"toc-level-#{lvl}\"><a href=\"##{id}\" class=\"toc-link\" data-target=\"#{id}\">#{text}</a></li>"
257
- end
258
- end
259
-
260
- # List of Figures — at top of sidebar
261
- unless @figure_entries.empty?
262
- top_lines << "<li class=\"toc-list-header\" data-list=\"figures\"><button class=\"toc-list-toggle\" aria-expanded=\"false\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"><rect x=\"1\" y=\"2\" width=\"14\" height=\"12\" rx=\"1\"/><circle cx=\"5\" cy=\"6.5\" r=\"1.5\"/><path d=\"M1 12l4-4 2 2 3-3 5 5\"/></svg> Figures <span class=\"toc-list-count\">(#{@figure_entries.size})</span></button></li>"
263
- @figure_entries.each do |f|
264
- id = f[:id].to_s
265
- text = escape_html(f[:text].to_s)
266
- top_lines << "<li class=\"toc-list-item toc-figures\" style=\"display:none\"><a href=\"##{id}\" class=\"toc-link\" data-target=\"#{id}\">#{text}</a></li>"
267
- end
268
- end
269
-
270
- # List of Tables — at top of sidebar
271
- unless @table_entries.empty?
272
- top_lines << "<li class=\"toc-list-header\" data-list=\"tables\"><button class=\"toc-list-toggle\" aria-expanded=\"false\"><svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\"><rect x=\"1\" y=\"2\" width=\"14\" height=\"12\" rx=\"1\"/><line x1=\"1\" y1=\"6\" x2=\"15\" y2=\"6\"/><line x1=\"1\" y1=\"10\" x2=\"15\" y2=\"10\"/><line x1=\"7\" y1=\"2\" x2=\"7\" y2=\"14\"/></svg> Tables <span class=\"toc-list-count\">(#{@table_entries.size})</span></button></li>"
273
- @table_entries.each do |t|
274
- id = t[:id].to_s
275
- text = escape_html(t[:text].to_s)
276
- top_lines << "<li class=\"toc-list-item toc-tables\" style=\"display:none\"><a href=\"##{id}\" class=\"toc-link\" data-target=\"#{id}\">#{text}</a></li>"
277
- end
278
- end
279
-
280
- top_lines << "<li class=\"toc-divider\"></li>" unless top_lines.empty?
281
-
282
- (top_lines + main_lines).join("\n")
272
+ entry_drops = entries.map { |e| Drops::TocEntryDrop.new(e) }
273
+ figure_drops = @figure_entries.map { |f| Drops::FigureListEntryDrop.new(f) }
274
+ table_drops = @table_entries.map { |t| Drops::FigureListEntryDrop.new(t) }
275
+ has_special_lists = !@figure_entries.empty? || !@table_entries.empty?
276
+
277
+ render_liquid("_toc.html.liquid", {
278
+ "entries" => entry_drops,
279
+ "figures" => figure_drops,
280
+ "tables" => table_drops,
281
+ "has_special_lists" => has_special_lists,
282
+ })
283
283
  end
284
284
 
285
285
  # --- Scripts ---
@@ -469,54 +469,125 @@ module Metanorma
469
469
  parts.join.strip.gsub("\u00A0", " ")
470
470
  end
471
471
 
472
- # Dispatch to the appropriate render method based on node class.
472
+ # Dispatch to the appropriate render method via type registry.
473
+ # Lookups traverse the ancestor chain so subclasses inherit
474
+ # parent registrations and can override them independently.
473
475
  def render(node, **)
474
- case node
475
- when Metanorma::Document::Components::Paragraphs::ParagraphBlock
476
- render_paragraph(node, **)
477
- when Metanorma::Document::Components::Tables::TableBlock
478
- render_table(node, **)
479
- when Metanorma::Document::Components::Lists::UnorderedList
480
- render_unordered_list(node, **)
481
- when Metanorma::Document::Components::Lists::OrderedList
482
- render_ordered_list(node, **)
483
- when Metanorma::Document::Components::Lists::DefinitionList
484
- render_definition_list(node, **)
485
- when Metanorma::Document::Components::AncillaryBlocks::FigureBlock
486
- render_figure(node, **)
487
- when Metanorma::Document::Components::Blocks::NoteBlock
488
- render_note(node, **)
489
- when Metanorma::Document::Components::AncillaryBlocks::ExampleBlock
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
- ""
476
+ return escape_html(node) if node.is_a?(String)
477
+
478
+ method = lookup_dispatch(node.class, :render_registry)
479
+ method ? send(method, node, **) : ""
480
+ end
481
+
482
+ # Dispatch to the appropriate inline render method via type registry.
483
+ def render_inline_element(element, **)
484
+ return "" if element.nil?
485
+ return escape_html(element) if element.is_a?(String)
486
+
487
+ method = lookup_dispatch(element.class, :inline_registry)
488
+ if method
489
+ send(method, element)
490
+ elsif element.is_a?(Lutaml::Model::Serializable) && element.mixed?
491
+ render_mixed_inline(element)
515
492
  end
516
493
  end
517
494
 
495
+ # --- Type registrations (class-level, evaluated at class load time) ---
496
+
497
+ register_render Metanorma::Document::Components::Paragraphs::ParagraphBlock, :render_paragraph
498
+ register_render Metanorma::Document::Components::Tables::TableBlock, :render_table
499
+ register_render Metanorma::Document::Components::Lists::UnorderedList, :render_unordered_list
500
+ register_render Metanorma::Document::Components::Lists::OrderedList, :render_ordered_list
501
+ register_render Metanorma::Document::Components::Lists::DefinitionList, :render_definition_list
502
+ register_render Metanorma::Document::Components::AncillaryBlocks::FigureBlock, :render_figure
503
+ register_render Metanorma::Document::Components::Blocks::NoteBlock, :render_note
504
+ register_render Metanorma::Document::Components::AncillaryBlocks::ExampleBlock, :render_example
505
+ register_render Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock, :render_sourcecode
506
+ register_render Metanorma::Document::Components::AncillaryBlocks::FormulaBlock, :render_formula
507
+ register_render Metanorma::Document::Components::MultiParagraph::QuoteBlock, :render_quote
508
+ register_render Metanorma::Document::Components::MultiParagraph::AdmonitionBlock, :render_admonition
509
+ register_render Metanorma::Document::Components::Sections::HierarchicalSection, :render_hierarchical_section
510
+ register_render Metanorma::Document::Components::Sections::BasicSection, :render_basic_section
511
+ register_render Metanorma::Document::Components::Sections::ContentSection, :render_content_section
512
+ register_render Metanorma::Document::Components::EmptyElements::PageBreakElement, :render_noop
513
+ register_render Metanorma::Document::Components::IdElements::Bookmark, :render_bookmark
514
+ register_render Metanorma::Document::Components::Inline::SemxElement, :render_semx_content
515
+
516
+ register_inline_render Metanorma::Document::Components::Inline::EmRawElement, :render_em
517
+ register_inline_render Metanorma::Document::Components::Inline::StrongRawElement, :render_strong
518
+ register_inline_render Metanorma::Document::Components::Inline::TtElement, :render_tt
519
+ register_inline_render Metanorma::Document::Components::Inline::SubElement, :render_sub
520
+ register_inline_render Metanorma::Document::Components::Inline::SupElement, :render_sup
521
+ register_inline_render Metanorma::Document::Components::Inline::SmallCapElement, :render_small_caps
522
+ register_inline_render Metanorma::Document::Components::TextElements::UnderlineElement, :render_underline
523
+ register_inline_render Metanorma::Document::Components::TextElements::StrikeElement, :render_strike
524
+ register_inline_render Metanorma::Document::Components::Inline::BrElement, :render_br
525
+ register_inline_render Metanorma::Document::Components::Inline::TabElement, :render_tab
526
+ register_inline_render Metanorma::Document::Components::Inline::LinkElement, :render_link
527
+ register_inline_render Metanorma::Document::Components::Inline::XrefElement, :render_noop_inline
528
+ register_inline_render Metanorma::Document::Components::Inline::ErefElement, :render_noop_inline
529
+ register_inline_render Metanorma::Document::Components::Inline::SpanElement, :render_span
530
+ register_inline_render Metanorma::Document::Components::Inline::FnElement, :render_fn_inline
531
+ register_inline_render Metanorma::Document::Components::Inline::ConceptElement, :render_concept
532
+ register_inline_render Metanorma::Document::Components::Inline::StemInlineElement, :render_noop_inline
533
+ register_inline_render Metanorma::Document::Components::TextElements::StemElement, :render_stem
534
+ register_inline_render Metanorma::Document::Components::Inline::SemxElement, :render_semx_inline
535
+ register_inline_render Metanorma::Document::Components::Inline::FmtXrefElement, :render_fmt_xref
536
+ register_inline_render Metanorma::Document::Components::Inline::FmtStemElement, :render_fmt_stem
537
+ register_inline_render Metanorma::Document::Components::Inline::CommaElement, :render_comma
538
+ register_inline_render Metanorma::Document::Components::Inline::EnumCommaElement, :render_comma
539
+ register_inline_render Metanorma::Document::Components::IdElements::Bookmark, :render_bookmark
540
+ register_inline_render Metanorma::Document::Components::IdElements::Image, :render_image
541
+ register_inline_render Metanorma::Document::Components::Inline::MathElement, :render_math
542
+ register_inline_render Metanorma::Document::Components::Inline::AsciimathElement, :render_asciimath
543
+ register_inline_render Metanorma::Document::Components::EmptyElements::IndexElement, :render_index
544
+ register_inline_render Metanorma::Document::Components::ReferenceElements::IndexXrefElement, :render_index
545
+ register_inline_render Metanorma::Document::Components::Blocks::NoteBlock, :render_note_inline
546
+ # All Fmt* elements delegate to render_mixed_inline
547
+ register_inline_render Metanorma::Document::Components::Inline::FmtNameElement, :render_mixed_inline
548
+ register_inline_render Metanorma::Document::Components::Inline::FmtTitleElement, :render_mixed_inline
549
+ register_inline_render Metanorma::Document::Components::Inline::FmtXrefLabelElement, :render_mixed_inline
550
+ register_inline_render Metanorma::Document::Components::Inline::FmtFnLabelElement, :render_mixed_inline
551
+ register_inline_render Metanorma::Document::Components::Inline::FmtConceptElement, :render_mixed_inline
552
+ register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationStartElement, :render_mixed_inline
553
+ register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationEndElement, :render_mixed_inline
554
+ register_inline_render Metanorma::Document::Components::Inline::FmtAnnotationBodyElement, :render_mixed_inline
555
+ register_inline_render Metanorma::Document::Components::Inline::VariantTitleElement, :render_mixed_inline
556
+ register_inline_render Metanorma::Document::Components::Inline::LocalizedStringElement, :render_mixed_inline
557
+ register_inline_render Metanorma::Document::Components::Inline::TitleWithAnnotationElement, :render_mixed_inline
558
+ register_inline_render Metanorma::Document::Components::Inline::BiblioTagElement, :render_mixed_inline
559
+ register_inline_render Metanorma::Document::Components::Inline::NameWithIdElement, :render_mixed_inline
560
+ register_inline_render Metanorma::Document::Components::Inline::DisplayTextElement, :render_mixed_inline
561
+ register_inline_render Metanorma::Document::Components::Inline::FmtFootnoteContainerElement, :render_mixed_inline
562
+ register_inline_render Metanorma::Document::Components::Inline::FmtFnBodyElement, :render_mixed_inline
563
+ register_inline_render Metanorma::Document::Components::Inline::FmtPreferredElement, :render_mixed_inline
564
+ register_inline_render Metanorma::Document::Components::Inline::FmtDefinitionElement, :render_mixed_inline
565
+ register_inline_render Metanorma::Document::Components::Inline::FmtTermsourceElement, :render_mixed_inline
566
+ register_inline_render Metanorma::Document::Components::Inline::FmtAdmittedElement, :render_mixed_inline
567
+ register_inline_render Metanorma::Document::Components::Inline::FmtIdentifierElement, :render_mixed_inline
568
+ register_inline_render Metanorma::Document::Components::Inline::FmtSourcecodeElement, :render_mixed_inline
569
+
518
570
  private
519
571
 
572
+ def lookup_dispatch(type_class, registry_method)
573
+ self.class.ancestors.each do |ancestor|
574
+ next unless ancestor.respond_to?(registry_method)
575
+
576
+ registry = ancestor.send(registry_method)
577
+ method_name = registry[type_class]
578
+ return method_name if method_name
579
+ end
580
+ nil
581
+ end
582
+
583
+ def render_noop(*)
584
+ ""
585
+ end
586
+
587
+ def render_noop_inline(*)
588
+ nil
589
+ end
590
+
520
591
  # --- Block-level rendering ---
521
592
 
522
593
  def render_paragraph(p, **_opts)
@@ -801,7 +872,7 @@ module Metanorma
801
872
  @output << render_liquid("_admonition.html.liquid", { "block" => drop })
802
873
  end
803
874
 
804
- def render_bookmark(bookmark)
875
+ def render_bookmark(bookmark, **_opts)
805
876
  @output << %(<a id="#{escape_html(safe_attr(bookmark, :id).to_s)}"></a>)
806
877
  end
807
878
 
@@ -1012,137 +1083,109 @@ module Metanorma
1012
1083
  end
1013
1084
  end
1014
1085
  end
1015
- rescue StandardError
1016
- node.each_mixed_content do |child|
1017
- case child
1018
- when String
1019
- @output << escape_html(child)
1020
- else
1021
- render_inline_element(child)
1022
- end
1023
- end
1024
1086
  end
1025
1087
 
1026
- def render_inline_element(element)
1027
- return "" if element.nil?
1088
+ # Inline adapter methods for registry dispatch
1028
1089
 
1029
- case element
1030
- when String
1031
- @output << escape_html(element)
1032
- when Metanorma::Document::Components::Inline::EmRawElement
1033
- render_inline_tag("em", element)
1034
- when Metanorma::Document::Components::Inline::StrongRawElement
1035
- render_inline_tag("strong", element)
1036
- when Metanorma::Document::Components::Inline::TtElement
1037
- render_inline_tag("tt", element)
1038
- when Metanorma::Document::Components::Inline::SubElement
1039
- render_inline_tag("sub", element)
1040
- when Metanorma::Document::Components::Inline::SupElement
1041
- render_inline_tag("sup", element)
1042
- when Metanorma::Document::Components::Inline::SmallCapElement
1043
- render_inline_tag("span", element, class: "small-caps")
1044
- when Metanorma::Document::Components::TextElements::UnderlineElement
1045
- render_inline_tag("u", element)
1046
- when Metanorma::Document::Components::TextElements::StrikeElement
1047
- render_inline_tag("s", element)
1048
- when Metanorma::Document::Components::Inline::BrElement
1049
- @output << "<br />"
1050
- when Metanorma::Document::Components::Inline::TabElement
1051
- @output << "\u00a0\u00a0"
1052
- when Metanorma::Document::Components::Inline::LinkElement
1053
- render_link(element)
1054
- when Metanorma::Document::Components::Inline::XrefElement
1055
- # Source element — skip; rendered via fmt-xref in semx wrapper
1056
- nil
1057
- when Metanorma::Document::Components::Inline::ErefElement
1058
- # Source element — skip; rendered via fmt-xref in semx wrapper
1059
- nil
1060
- when Metanorma::Document::Components::Inline::SpanElement
1061
- xml_class = safe_attr(element, :class_attr).to_s
1062
- html_class = html_class_for_span(xml_class) unless xml_class.empty?
1063
- attrs = element_attrs(style: safe_attr(element, :style), class: html_class)
1064
- tag("span", attrs) { render_mixed_inline(element) }
1065
- when Metanorma::Document::Components::Inline::FnElement
1066
- render_fn(element)
1067
- when Metanorma::Document::Components::Inline::ConceptElement
1068
- render_concept(element)
1069
- when Metanorma::Document::Components::Inline::StemInlineElement
1070
- # Source element — skip; rendered via FmtStemElement
1071
- nil
1072
- when Metanorma::Document::Components::TextElements::StemElement
1073
- @output << render_stem_content(element)
1074
- when Metanorma::Document::Components::Inline::SemxElement
1075
- render_semx_content(element)
1076
- when Metanorma::Document::Components::Inline::FmtNameElement,
1077
- Metanorma::Document::Components::Inline::FmtTitleElement,
1078
- Metanorma::Document::Components::Inline::FmtXrefLabelElement,
1079
- Metanorma::Document::Components::Inline::FmtFnLabelElement,
1080
- Metanorma::Document::Components::Inline::FmtConceptElement,
1081
- Metanorma::Document::Components::Inline::FmtAnnotationStartElement,
1082
- Metanorma::Document::Components::Inline::FmtAnnotationEndElement,
1083
- Metanorma::Document::Components::Inline::FmtAnnotationBodyElement,
1084
- Metanorma::Document::Components::Inline::VariantTitleElement,
1085
- Metanorma::Document::Components::Inline::LocalizedStringElement,
1086
- Metanorma::Document::Components::Inline::TitleWithAnnotationElement,
1087
- Metanorma::Document::Components::Inline::BiblioTagElement,
1088
- Metanorma::Document::Components::Inline::NameWithIdElement,
1089
- Metanorma::Document::Components::Inline::DisplayTextElement,
1090
- Metanorma::Document::Components::Inline::FmtFootnoteContainerElement,
1091
- Metanorma::Document::Components::Inline::FmtFnBodyElement,
1092
- Metanorma::Document::Components::Inline::FmtPreferredElement,
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)
1090
+ def render_em(el)
1091
+ render_inline_tag("em", el)
1092
+ end
1093
+
1094
+ def render_strong(el)
1095
+ render_inline_tag("strong", el)
1096
+ end
1097
+
1098
+ def render_tt(el)
1099
+ render_inline_tag("tt", el)
1100
+ end
1101
+
1102
+ def render_sub(el)
1103
+ render_inline_tag("sub", el)
1104
+ end
1105
+
1106
+ def render_sup(el)
1107
+ render_inline_tag("sup", el)
1108
+ end
1109
+
1110
+ def render_small_caps(el)
1111
+ render_inline_tag("span", el, class: "small-caps")
1112
+ end
1113
+
1114
+ def render_underline(el)
1115
+ render_inline_tag("u", el)
1116
+ end
1117
+
1118
+ def render_strike(el)
1119
+ render_inline_tag("s", el)
1120
+ end
1121
+
1122
+ def render_br(*)
1123
+ @output << "<br />"
1124
+ end
1125
+
1126
+ def render_tab(*)
1127
+ @output << "\u00a0\u00a0"
1128
+ end
1129
+
1130
+ def render_span(el)
1131
+ xml_class = safe_attr(el, :class_attr).to_s
1132
+ html_class = html_class_for_span(xml_class) unless xml_class.empty?
1133
+ attrs = element_attrs(style: safe_attr(el, :style), class: html_class)
1134
+ tag("span", attrs) { render_mixed_inline(el) }
1135
+ end
1136
+
1137
+ def render_fn_inline(el)
1138
+ render_fn(el)
1139
+ end
1140
+
1141
+ def render_stem(el)
1142
+ @output << render_stem_content(el)
1143
+ end
1144
+
1145
+ def render_semx_inline(el)
1146
+ render_semx_content(el)
1147
+ end
1148
+
1149
+ def render_fmt_xref(el)
1150
+ target = safe_attr(el, :target) || safe_attr(el, :to_attr)
1151
+ if target
1152
+ attrs = element_attrs(href: "##{escape_html(target)}", class: "xref")
1153
+ tag("a", attrs) { render_mixed_inline(el) }
1126
1154
  else
1127
- # Attempt generic mixed content rendering for unknown inline types
1128
- if element.is_a?(Lutaml::Model::Serializable) && element.mixed?
1129
- render_mixed_inline(element)
1130
- end
1155
+ render_mixed_inline(el)
1131
1156
  end
1132
1157
  end
1133
1158
 
1159
+ def render_comma(*)
1160
+ @output << ", "
1161
+ end
1162
+
1163
+ def render_math(el)
1164
+ @output << el.content.to_s
1165
+ end
1166
+
1167
+ def render_asciimath(el)
1168
+ @output << %(<span class="stem">#{escape_html(Array(el.text).join)}</span>)
1169
+ end
1170
+
1171
+ def render_index(el)
1172
+ collect_index_term(el)
1173
+ ""
1174
+ end
1175
+
1176
+ def render_note_inline(el)
1177
+ render_note(el)
1178
+ end
1179
+
1134
1180
  def render_inline_collections(node)
1135
- # Fallback: render text and inline collections sequentially
1136
1181
  texts = node.text
1137
1182
  if texts.is_a?(Array)
1138
1183
  texts.each do |t|
1139
- @output << if t.is_a?(Metanorma::Document::Components::Inline::MathElement)
1140
- t.content.to_s
1141
- elsif t.is_a?(Metanorma::Document::Components::Inline::AsciimathElement)
1142
- %(<span class="stem">#{escape_html(Array(t.text).join)}</span>)
1143
- else
1144
- escape_html(t.to_s)
1145
- end
1184
+ if t.is_a?(String)
1185
+ @output << escape_html(t)
1186
+ else
1187
+ render_inline_element(t)
1188
+ end
1146
1189
  end
1147
1190
  elsif texts.is_a?(String)
1148
1191
  @output << escape_html(texts)
@@ -1164,7 +1207,7 @@ module Metanorma
1164
1207
  # Render SemxElement display content only, skipping semantic linkage.
1165
1208
  # semx wraps both semantic data (origin, xref, source, etc.) and
1166
1209
  # display content (fmt-xref, span, strong, etc.). Only render display.
1167
- def render_semx_content(element)
1210
+ def render_semx_content(element, **_opts)
1168
1211
  display_attrs = %i[text fmt_xref fmt_link fmt_concept span strong em sup p semx
1169
1212
  asciimath math sub_child tt_child br_child tab_child
1170
1213
  stem_child figure_child formula_child sourcecode_child]
@@ -1389,7 +1432,7 @@ module Metanorma
1389
1432
  return stem.math.to_xml
1390
1433
  rescue StandardError
1391
1434
  math_items = Array(stem.math)
1392
- return math_items.map { |m| m.respond_to?(:content) ? m.content.to_s : m.to_s }.join
1435
+ return math_items.map { |m| m.is_a?(Lutaml::Model::Serializable) ? m.content.to_s : m.to_s }.join
1393
1436
  end
1394
1437
  end
1395
1438
  if stem.asciimath
@@ -1424,30 +1467,30 @@ module Metanorma
1424
1467
  parts.join
1425
1468
  end
1426
1469
 
1427
- BLOCK_TYPES = Set[
1428
- Metanorma::Document::Components::Paragraphs::ParagraphBlock,
1429
- Metanorma::Document::Components::Tables::TableBlock,
1430
- Metanorma::Document::Components::Lists::UnorderedList,
1431
- Metanorma::Document::Components::Lists::OrderedList,
1432
- Metanorma::Document::Components::Lists::DefinitionList,
1433
- Metanorma::Document::Components::AncillaryBlocks::FigureBlock,
1434
- Metanorma::Document::Components::Blocks::NoteBlock,
1435
- Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
1436
- Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock,
1437
- Metanorma::Document::Components::AncillaryBlocks::FormulaBlock,
1438
- Metanorma::Document::Components::MultiParagraph::QuoteBlock,
1439
- Metanorma::Document::Components::MultiParagraph::AdmonitionBlock,
1440
- Metanorma::Document::Components::Sections::HierarchicalSection,
1441
- Metanorma::Document::Components::Sections::BasicSection,
1442
- Metanorma::Document::Components::Sections::ContentSection,
1443
- ].freeze
1470
+ BLOCK_TYPES = {
1471
+ Metanorma::Document::Components::Paragraphs::ParagraphBlock => true,
1472
+ Metanorma::Document::Components::Tables::TableBlock => true,
1473
+ Metanorma::Document::Components::Lists::UnorderedList => true,
1474
+ Metanorma::Document::Components::Lists::OrderedList => true,
1475
+ Metanorma::Document::Components::Lists::DefinitionList => true,
1476
+ Metanorma::Document::Components::AncillaryBlocks::FigureBlock => true,
1477
+ Metanorma::Document::Components::Blocks::NoteBlock => true,
1478
+ Metanorma::Document::Components::AncillaryBlocks::ExampleBlock => true,
1479
+ Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock => true,
1480
+ Metanorma::Document::Components::AncillaryBlocks::FormulaBlock => true,
1481
+ Metanorma::Document::Components::MultiParagraph::QuoteBlock => true,
1482
+ Metanorma::Document::Components::MultiParagraph::AdmonitionBlock => true,
1483
+ Metanorma::Document::Components::Sections::HierarchicalSection => true,
1484
+ Metanorma::Document::Components::Sections::BasicSection => true,
1485
+ Metanorma::Document::Components::Sections::ContentSection => true,
1486
+ }.freeze
1444
1487
 
1445
1488
  def html_class_for_span(xml_class)
1446
1489
  SPAN_ROLE_CLASSES[xml_class] || "span-#{xml_class}"
1447
1490
  end
1448
1491
 
1449
1492
  def block_element?(obj)
1450
- BLOCK_TYPES.any? { |type| obj.is_a?(type) }
1493
+ BLOCK_TYPES[obj.class] || BLOCK_TYPES.any? { |type, _| obj.is_a?(type) }
1451
1494
  end
1452
1495
 
1453
1496
  def safe_attr(obj, method_name)
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module Html
5
+ module Drops
6
+ class FigureListEntryDrop < Liquid::Drop
7
+ def initialize(entry)
8
+ @entry = entry
9
+ end
10
+
11
+ def id = @entry[:id]
12
+ def text = @entry[:text]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Metanorma
4
+ module Html
5
+ module Drops
6
+ class TocEntryDrop < Liquid::Drop
7
+ def initialize(entry)
8
+ @entry = entry
9
+ end
10
+
11
+ def id = @entry[:id]
12
+ def text = @entry[:text]
13
+ def level = @entry[:level]
14
+ end
15
+ end
16
+ end
17
+ end
@@ -11,6 +11,8 @@ module Metanorma
11
11
  autoload :SourcecodeDrop, "metanorma/html/drops/sourcecode_drop"
12
12
  autoload :FormulaDrop, "metanorma/html/drops/formula_drop"
13
13
  autoload :FigureDrop, "metanorma/html/drops/figure_drop"
14
+ autoload :TocEntryDrop, "metanorma/html/drops/toc_entry_drop"
15
+ autoload :FigureListEntryDrop, "metanorma/html/drops/figure_list_entry_drop"
14
16
  end
15
17
  end
16
18
  end
@@ -51,45 +51,20 @@ module Metanorma
51
51
  end
52
52
  end
53
53
 
54
- def render(node, **)
55
- case node
56
- when Metanorma::IsoDocument::Root
57
- render_document(node, **)
58
- when Metanorma::IsoDocument::Sections::IsoPreface
59
- render_preface(node, **)
60
- when Metanorma::IsoDocument::Sections::IsoSections
61
- render_sections(node, **)
62
- when Metanorma::IsoDocument::Sections::IsoClauseSection
63
- render_clause(node, **)
64
- when Metanorma::IsoDocument::Sections::IsoAnnexSection
65
- render_annex(node, **)
66
- when Metanorma::IsoDocument::Sections::IsoTermsSection
67
- render_terms_section(node, **)
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)
@@ -158,7 +133,7 @@ module Metanorma
158
133
 
159
134
  # Extract document type from ext.doctype.
160
135
  def extract_doctype(bibdata)
161
- return nil unless bibdata.respond_to?(:ext)
136
+ return nil unless bibdata.is_a?(Metanorma::IsoDocument::Metadata::IsoBibliographicItem)
162
137
 
163
138
  ext = bibdata.ext
164
139
  return nil unless ext
@@ -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
- def render(node, **)
9
- case node
10
- when Metanorma::StandardDocument::Root
11
- render_standard_document(node, **)
12
- when Metanorma::StandardDocument::Terms::Term
13
- render_term(node, **)
14
- when Metanorma::StandardDocument::Sections::TermsSection
15
- render_terms_section(node, **)
16
- when Metanorma::StandardDocument::Sections::StandardReferencesSection
17
- render_references_section(node, **)
18
- when Metanorma::StandardDocument::Sections::BibliographySection
19
- render_bibliography(node, **)
20
- when Metanorma::StandardDocument::Sections::ClauseSection
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
 
@@ -69,7 +50,7 @@ module Metanorma
69
50
  end
70
51
 
71
52
  # Index section from indexsect element (presentation XML)
72
- if doc.respond_to?(:indexsect) && doc.indexsect
53
+ if doc.is_a?(Metanorma::IsoDocument::Root) && doc.indexsect
73
54
  render(doc.indexsect)
74
55
  end
75
56
 
@@ -0,0 +1,27 @@
1
+ {% for fig in figures %}
2
+ <li class="toc-list-header" data-list="figures"><button class="toc-list-toggle" aria-expanded="false"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="2" width="14" height="12" rx="1"/><circle cx="5" cy="6.5" r="1.5"/><path d="M1 12l4-4 2 2 3-3 5 5"/></svg> Figures <span class="toc-list-count">({{ figures.size }})</span></button></li>
3
+ {% break %}
4
+ {% endfor %}
5
+ {% for fig in figures %}
6
+ <li class="toc-list-item toc-figures" style="display:none"><a href="#{{ fig.id }}" class="toc-link" data-target="{{ fig.id }}">{{ fig.text | escape }}</a></li>
7
+ {% endfor %}
8
+
9
+ {% for tbl in tables %}
10
+ <li class="toc-list-header" data-list="tables"><button class="toc-list-toggle" aria-expanded="false"><svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="1" y="2" width="14" height="12" rx="1"/><line x1="1" y1="6" x2="15" y2="6"/><line x1="1" y1="10" x2="15" y2="10"/><line x1="7" y1="2" x2="7" y2="14"/></svg> Tables <span class="toc-list-count">({{ tables.size }})</span></button></li>
11
+ {% break %}
12
+ {% endfor %}
13
+ {% for tbl in tables %}
14
+ <li class="toc-list-item toc-tables" style="display:none"><a href="#{{ tbl.id }}" class="toc-link" data-target="{{ tbl.id }}">{{ tbl.text | escape }}</a></li>
15
+ {% endfor %}
16
+
17
+ {% if has_special_lists %}
18
+ <li class="toc-divider"></li>
19
+ {% endif %}
20
+
21
+ {% if entries.size == 0 %}
22
+ <li class="toc-empty">No entries</li>
23
+ {% else %}
24
+ {% for entry in entries %}
25
+ <li class="toc-level-{{ entry.level }}"><a href="#{{ entry.id }}" class="toc-link" data-target="{{ entry.id }}">{{ entry.text | escape }}</a></li>
26
+ {% endfor %}
27
+ {% endif %}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-document
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
@@ -486,10 +486,12 @@ files:
486
486
  - lib/metanorma/html/drops/block_element_drop.rb
487
487
  - lib/metanorma/html/drops/example_drop.rb
488
488
  - lib/metanorma/html/drops/figure_drop.rb
489
+ - lib/metanorma/html/drops/figure_list_entry_drop.rb
489
490
  - lib/metanorma/html/drops/footnote_drop.rb
490
491
  - lib/metanorma/html/drops/formula_drop.rb
491
492
  - lib/metanorma/html/drops/note_drop.rb
492
493
  - lib/metanorma/html/drops/sourcecode_drop.rb
494
+ - lib/metanorma/html/drops/toc_entry_drop.rb
493
495
  - lib/metanorma/html/generator.rb
494
496
  - lib/metanorma/html/icc_renderer.rb
495
497
  - lib/metanorma/html/iec_renderer.rb
@@ -516,6 +518,7 @@ files:
516
518
  - lib/metanorma/html/templates/_iso_doc_title.html.liquid
517
519
  - lib/metanorma/html/templates/_note.html.liquid
518
520
  - lib/metanorma/html/templates/_sourcecode.html.liquid
521
+ - lib/metanorma/html/templates/_toc.html.liquid
519
522
  - lib/metanorma/html/templates/document.html.liquid
520
523
  - lib/metanorma/html/theme.rb
521
524
  - lib/metanorma/html/whitespace_patch.rb