metanorma-document 0.2.3 → 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 +4 -4
- data/.rubocop_todo.yml +24 -13
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/html/base_renderer.rb +61 -93
- data/lib/metanorma/html/drops/figure_list_entry_drop.rb +16 -0
- data/lib/metanorma/html/drops/toc_entry_drop.rb +17 -0
- data/lib/metanorma/html/drops.rb +2 -0
- data/lib/metanorma/html/iso_renderer.rb +1 -1
- data/lib/metanorma/html/standard_renderer.rb +1 -1
- data/lib/metanorma/html/templates/_toc.html.liquid +27 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: afb9ddd75c55018b0ff15fb41d06a1eddc5fe7448a3841a5a7fd4d4061965756
|
|
4
|
+
data.tar.gz: 52550547f425bbcab7fb88b940eda4798ae842240ec9b53e8c7052737128cfcd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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:
|
|
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:
|
|
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
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
140
|
+
# Offense count: 58
|
|
138
141
|
# Configuration parameters: AllowedMethods, AllowedPatterns, Max.
|
|
139
142
|
Metrics/CyclomaticComplexity:
|
|
140
143
|
Exclude:
|
|
@@ -153,7 +156,7 @@ 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:
|
|
159
|
+
# Offense count: 84
|
|
157
160
|
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
158
161
|
Metrics/MethodLength:
|
|
159
162
|
Max: 75
|
|
@@ -163,7 +166,7 @@ Metrics/MethodLength:
|
|
|
163
166
|
Metrics/ParameterLists:
|
|
164
167
|
Max: 7
|
|
165
168
|
|
|
166
|
-
# Offense count:
|
|
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:
|
|
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:
|
|
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,11 +223,12 @@ Naming/PredicatePrefix:
|
|
|
219
223
|
Exclude:
|
|
220
224
|
- 'lib/metanorma/html/standard_renderer.rb'
|
|
221
225
|
|
|
222
|
-
# Offense count:
|
|
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'
|
|
@@ -253,7 +258,12 @@ RSpec/MultipleDescribes:
|
|
|
253
258
|
Exclude:
|
|
254
259
|
- 'spec/metanorma/document_spec.rb'
|
|
255
260
|
|
|
256
|
-
# Offense count:
|
|
261
|
+
# Offense count: 1
|
|
262
|
+
# Configuration parameters: AllowSubject.
|
|
263
|
+
RSpec/MultipleMemoizedHelpers:
|
|
264
|
+
Max: 7
|
|
265
|
+
|
|
266
|
+
# Offense count: 322
|
|
257
267
|
# Configuration parameters: AllowedPatterns.
|
|
258
268
|
# AllowedPatterns: ^expect_, ^assert_
|
|
259
269
|
RSpec/NoExpectationExample:
|
|
@@ -265,7 +275,7 @@ RSpec/NoExpectationExample:
|
|
|
265
275
|
RSpec/SpecFilePathFormat:
|
|
266
276
|
Enabled: false
|
|
267
277
|
|
|
268
|
-
# Offense count:
|
|
278
|
+
# Offense count: 4
|
|
269
279
|
# This cop supports safe autocorrection (--autocorrect).
|
|
270
280
|
# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames.
|
|
271
281
|
# RedundantRestArgumentNames: args, arguments
|
|
@@ -273,6 +283,7 @@ RSpec/SpecFilePathFormat:
|
|
|
273
283
|
# RedundantBlockArgumentNames: blk, block, proc
|
|
274
284
|
Style/ArgumentsForwarding:
|
|
275
285
|
Exclude:
|
|
286
|
+
- 'lib/metanorma/html/base_renderer.rb'
|
|
276
287
|
- 'lib/metanorma/html/component/footnote_collector.rb'
|
|
277
288
|
|
|
278
289
|
# Offense count: 1
|
|
@@ -83,33 +83,37 @@ module Metanorma
|
|
|
83
83
|
# --- Public API ---
|
|
84
84
|
|
|
85
85
|
# Facade object for Drops to call renderer methods without exposing
|
|
86
|
-
# the full private interface. Delegates
|
|
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.
|
|
87
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
|
+
|
|
88
100
|
def initialize(renderer)
|
|
89
101
|
@renderer = renderer
|
|
90
102
|
end
|
|
91
103
|
|
|
92
|
-
def
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def render_figure(f) = @renderer.send(:render_figure, f)
|
|
106
|
-
def render_quote(q) = @renderer.send(:render_quote, q)
|
|
107
|
-
def render_formula(f) = @renderer.send(:render_formula, f)
|
|
108
|
-
def render_note(n) = @renderer.send(:render_note, n)
|
|
109
|
-
def render_image(img) = @renderer.send(:render_image, img)
|
|
110
|
-
def render_stem_content(stem) = @renderer.send(:render_stem_content, stem)
|
|
111
|
-
def register_figure_entry(...) = @renderer.send(:register_figure_entry, ...)
|
|
112
|
-
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
|
|
113
117
|
end
|
|
114
118
|
|
|
115
119
|
def renderer_context
|
|
@@ -265,41 +269,17 @@ module Metanorma
|
|
|
265
269
|
# --- ToC generation ---
|
|
266
270
|
|
|
267
271
|
def build_toc_html(entries)
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
# List of Figures — at top of sidebar
|
|
281
|
-
unless @figure_entries.empty?
|
|
282
|
-
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>"
|
|
283
|
-
@figure_entries.each do |f|
|
|
284
|
-
id = f[:id].to_s
|
|
285
|
-
text = escape_html(f[:text].to_s)
|
|
286
|
-
top_lines << "<li class=\"toc-list-item toc-figures\" style=\"display:none\"><a href=\"##{id}\" class=\"toc-link\" data-target=\"#{id}\">#{text}</a></li>"
|
|
287
|
-
end
|
|
288
|
-
end
|
|
289
|
-
|
|
290
|
-
# List of Tables — at top of sidebar
|
|
291
|
-
unless @table_entries.empty?
|
|
292
|
-
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>"
|
|
293
|
-
@table_entries.each do |t|
|
|
294
|
-
id = t[:id].to_s
|
|
295
|
-
text = escape_html(t[:text].to_s)
|
|
296
|
-
top_lines << "<li class=\"toc-list-item toc-tables\" style=\"display:none\"><a href=\"##{id}\" class=\"toc-link\" data-target=\"#{id}\">#{text}</a></li>"
|
|
297
|
-
end
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
top_lines << "<li class=\"toc-divider\"></li>" unless top_lines.empty?
|
|
301
|
-
|
|
302
|
-
(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
|
+
})
|
|
303
283
|
end
|
|
304
284
|
|
|
305
285
|
# --- Scripts ---
|
|
@@ -1103,15 +1083,6 @@ module Metanorma
|
|
|
1103
1083
|
end
|
|
1104
1084
|
end
|
|
1105
1085
|
end
|
|
1106
|
-
rescue StandardError
|
|
1107
|
-
node.each_mixed_content do |child|
|
|
1108
|
-
case child
|
|
1109
|
-
when String
|
|
1110
|
-
@output << escape_html(child)
|
|
1111
|
-
else
|
|
1112
|
-
render_inline_element(child)
|
|
1113
|
-
end
|
|
1114
|
-
end
|
|
1115
1086
|
end
|
|
1116
1087
|
|
|
1117
1088
|
# Inline adapter methods for registry dispatch
|
|
@@ -1207,17 +1178,14 @@ module Metanorma
|
|
|
1207
1178
|
end
|
|
1208
1179
|
|
|
1209
1180
|
def render_inline_collections(node)
|
|
1210
|
-
# Fallback: render text and inline collections sequentially
|
|
1211
1181
|
texts = node.text
|
|
1212
1182
|
if texts.is_a?(Array)
|
|
1213
1183
|
texts.each do |t|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
escape_html(t.to_s)
|
|
1220
|
-
end
|
|
1184
|
+
if t.is_a?(String)
|
|
1185
|
+
@output << escape_html(t)
|
|
1186
|
+
else
|
|
1187
|
+
render_inline_element(t)
|
|
1188
|
+
end
|
|
1221
1189
|
end
|
|
1222
1190
|
elsif texts.is_a?(String)
|
|
1223
1191
|
@output << escape_html(texts)
|
|
@@ -1464,7 +1432,7 @@ module Metanorma
|
|
|
1464
1432
|
return stem.math.to_xml
|
|
1465
1433
|
rescue StandardError
|
|
1466
1434
|
math_items = Array(stem.math)
|
|
1467
|
-
return math_items.map { |m| m.
|
|
1435
|
+
return math_items.map { |m| m.is_a?(Lutaml::Model::Serializable) ? m.content.to_s : m.to_s }.join
|
|
1468
1436
|
end
|
|
1469
1437
|
end
|
|
1470
1438
|
if stem.asciimath
|
|
@@ -1499,30 +1467,30 @@ module Metanorma
|
|
|
1499
1467
|
parts.join
|
|
1500
1468
|
end
|
|
1501
1469
|
|
|
1502
|
-
BLOCK_TYPES =
|
|
1503
|
-
Metanorma::Document::Components::Paragraphs::ParagraphBlock,
|
|
1504
|
-
Metanorma::Document::Components::Tables::TableBlock,
|
|
1505
|
-
Metanorma::Document::Components::Lists::UnorderedList,
|
|
1506
|
-
Metanorma::Document::Components::Lists::OrderedList,
|
|
1507
|
-
Metanorma::Document::Components::Lists::DefinitionList,
|
|
1508
|
-
Metanorma::Document::Components::AncillaryBlocks::FigureBlock,
|
|
1509
|
-
Metanorma::Document::Components::Blocks::NoteBlock,
|
|
1510
|
-
Metanorma::Document::Components::AncillaryBlocks::ExampleBlock,
|
|
1511
|
-
Metanorma::Document::Components::AncillaryBlocks::SourcecodeBlock,
|
|
1512
|
-
Metanorma::Document::Components::AncillaryBlocks::FormulaBlock,
|
|
1513
|
-
Metanorma::Document::Components::MultiParagraph::QuoteBlock,
|
|
1514
|
-
Metanorma::Document::Components::MultiParagraph::AdmonitionBlock,
|
|
1515
|
-
Metanorma::Document::Components::Sections::HierarchicalSection,
|
|
1516
|
-
Metanorma::Document::Components::Sections::BasicSection,
|
|
1517
|
-
Metanorma::Document::Components::Sections::ContentSection,
|
|
1518
|
-
|
|
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
|
|
1519
1487
|
|
|
1520
1488
|
def html_class_for_span(xml_class)
|
|
1521
1489
|
SPAN_ROLE_CLASSES[xml_class] || "span-#{xml_class}"
|
|
1522
1490
|
end
|
|
1523
1491
|
|
|
1524
1492
|
def block_element?(obj)
|
|
1525
|
-
BLOCK_TYPES.any? { |type| obj.is_a?(type) }
|
|
1493
|
+
BLOCK_TYPES[obj.class] || BLOCK_TYPES.any? { |type, _| obj.is_a?(type) }
|
|
1526
1494
|
end
|
|
1527
1495
|
|
|
1528
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
|
data/lib/metanorma/html/drops.rb
CHANGED
|
@@ -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
|
|
@@ -133,7 +133,7 @@ module Metanorma
|
|
|
133
133
|
|
|
134
134
|
# Extract document type from ext.doctype.
|
|
135
135
|
def extract_doctype(bibdata)
|
|
136
|
-
return nil unless bibdata.
|
|
136
|
+
return nil unless bibdata.is_a?(Metanorma::IsoDocument::Metadata::IsoBibliographicItem)
|
|
137
137
|
|
|
138
138
|
ext = bibdata.ext
|
|
139
139
|
return nil unless ext
|
|
@@ -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.
|
|
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
|