metanorma-document 0.2.0 → 0.2.2
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 +231 -53
- data/README.adoc +59 -18
- data/data/stylesheets/components/bibliography.css +2 -2
- data/data/stylesheets/components/inline.css +11 -12
- data/docs/html-renderer.adoc +261 -0
- data/lib/metanorma/document/version.rb +1 -1
- data/lib/metanorma/html/base_renderer.rb +210 -257
- data/lib/metanorma/html/bipm_renderer.rb +0 -1
- data/lib/metanorma/html/cc_renderer.rb +0 -1
- data/lib/metanorma/html/drops/admonition_drop.rb +26 -0
- data/lib/metanorma/html/drops/block_element_drop.rb +20 -0
- data/lib/metanorma/html/drops/example_drop.rb +35 -0
- data/lib/metanorma/html/drops/figure_drop.rb +53 -0
- data/lib/metanorma/html/drops/formula_drop.rb +44 -0
- data/lib/metanorma/html/drops/note_drop.rb +32 -0
- data/lib/metanorma/html/drops/sourcecode_drop.rb +37 -0
- data/lib/metanorma/html/drops.rb +7 -0
- data/lib/metanorma/html/iec_renderer.rb +0 -1
- data/lib/metanorma/html/ieee_renderer.rb +0 -1
- data/lib/metanorma/html/ietf_renderer.rb +0 -1
- data/lib/metanorma/html/iho_renderer.rb +0 -1
- data/lib/metanorma/html/iso_renderer.rb +77 -209
- data/lib/metanorma/html/itu_renderer.rb +0 -1
- data/lib/metanorma/html/ogc_renderer.rb +5 -6
- data/lib/metanorma/html/oiml_renderer.rb +0 -1
- data/lib/metanorma/html/pdfa_renderer.rb +0 -1
- data/lib/metanorma/html/ribose_renderer.rb +0 -1
- data/lib/metanorma/html/standard_renderer.rb +63 -82
- data/lib/metanorma/html/templates/_admonition.html.liquid +4 -0
- data/lib/metanorma/html/templates/_doc_title.html.liquid +1 -1
- data/lib/metanorma/html/templates/_example.html.liquid +3 -0
- data/lib/metanorma/html/templates/_figure.html.liquid +6 -0
- data/lib/metanorma/html/templates/_formula.html.liquid +6 -0
- data/lib/metanorma/html/templates/_iso_doc_title.html.liquid +2 -2
- data/lib/metanorma/html/templates/_note.html.liquid +3 -0
- data/lib/metanorma/html/templates/_sourcecode.html.liquid +4 -0
- data/lib/metanorma/html.rb +0 -1
- metadata +16 -3
- data/lib/metanorma/html/component_registry.rb +0 -37
|
@@ -8,22 +8,6 @@ module Metanorma
|
|
|
8
8
|
# Extends StandardRenderer with ISO-specific cover page, boilerplate,
|
|
9
9
|
# foreword, introduction, annex formatting, and ISO term entries.
|
|
10
10
|
class IsoRenderer < StandardRenderer
|
|
11
|
-
class << self
|
|
12
|
-
def doc_types
|
|
13
|
-
@doc_types ||= []
|
|
14
|
-
if superclass <= IsoRenderer && superclass != IsoRenderer
|
|
15
|
-
superclass.doc_types + @doc_types
|
|
16
|
-
else
|
|
17
|
-
@doc_types.dup
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def registers_doc_type(klass)
|
|
22
|
-
@doc_types ||= []
|
|
23
|
-
@doc_types << klass
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
11
|
# --- Public hooks for flavor customization ---
|
|
28
12
|
|
|
29
13
|
def flavor_publishers(_doc_id)
|
|
@@ -67,32 +51,32 @@ module Metanorma
|
|
|
67
51
|
end
|
|
68
52
|
end
|
|
69
53
|
|
|
70
|
-
def render(node, **
|
|
54
|
+
def render(node, **)
|
|
71
55
|
case node
|
|
72
56
|
when Metanorma::IsoDocument::Root
|
|
73
|
-
render_document(node, **
|
|
57
|
+
render_document(node, **)
|
|
74
58
|
when Metanorma::IsoDocument::Sections::IsoPreface
|
|
75
|
-
render_preface(node, **
|
|
59
|
+
render_preface(node, **)
|
|
76
60
|
when Metanorma::IsoDocument::Sections::IsoSections
|
|
77
|
-
render_sections(node, **
|
|
61
|
+
render_sections(node, **)
|
|
78
62
|
when Metanorma::IsoDocument::Sections::IsoClauseSection
|
|
79
|
-
render_clause(node, **
|
|
63
|
+
render_clause(node, **)
|
|
80
64
|
when Metanorma::IsoDocument::Sections::IsoAnnexSection
|
|
81
|
-
render_annex(node, **
|
|
65
|
+
render_annex(node, **)
|
|
82
66
|
when Metanorma::IsoDocument::Sections::IsoTermsSection
|
|
83
|
-
render_terms_section(node, **
|
|
67
|
+
render_terms_section(node, **)
|
|
84
68
|
when Metanorma::IsoDocument::Sections::IsoForewordSection
|
|
85
|
-
render_foreword(node, **
|
|
69
|
+
render_foreword(node, **)
|
|
86
70
|
when Metanorma::IsoDocument::Sections::IsoAbstractSection
|
|
87
|
-
render_abstract(node, **
|
|
71
|
+
render_abstract(node, **)
|
|
88
72
|
when Metanorma::IsoDocument::Terms::IsoTerm
|
|
89
|
-
render_term(node, **
|
|
73
|
+
render_term(node, **)
|
|
90
74
|
when Metanorma::IsoDocument::Terms::TermNote
|
|
91
|
-
render_term_note(node, **
|
|
75
|
+
render_term_note(node, **)
|
|
92
76
|
when Metanorma::IsoDocument::Terms::TermExample
|
|
93
|
-
render_term_example(node, **
|
|
77
|
+
render_term_example(node, **)
|
|
94
78
|
when Metanorma::IsoDocument::Boilerplate
|
|
95
|
-
render_boilerplate(node, **
|
|
79
|
+
render_boilerplate(node, **)
|
|
96
80
|
else
|
|
97
81
|
super
|
|
98
82
|
end
|
|
@@ -147,33 +131,35 @@ module Metanorma
|
|
|
147
131
|
|
|
148
132
|
# Extract English stage text, deduplicating duplicate language variants.
|
|
149
133
|
def extract_stage(bibdata)
|
|
150
|
-
return nil unless bibdata.status
|
|
134
|
+
return nil unless bibdata.status&.stage
|
|
151
135
|
|
|
152
136
|
stages = Array(bibdata.status.stage)
|
|
153
137
|
return nil if stages.empty?
|
|
154
138
|
|
|
155
139
|
# Prefer English-language stage
|
|
156
|
-
en_stage = stages.find
|
|
140
|
+
en_stage = stages.find do |s|
|
|
157
141
|
lang = safe_attr(s, :language)
|
|
158
142
|
lang == "en" if lang
|
|
159
|
-
|
|
160
|
-
return Array(en_stage.value).join.strip if en_stage
|
|
143
|
+
end
|
|
144
|
+
return Array(en_stage.value).join.strip if en_stage&.value
|
|
161
145
|
|
|
162
146
|
# Fallback: first non-empty, deduplicated
|
|
163
147
|
seen = Set.new
|
|
164
|
-
stage_text = stages.filter_map
|
|
148
|
+
stage_text = stages.filter_map do |s|
|
|
165
149
|
val = Array(s.value).join.strip
|
|
166
150
|
down = val.downcase
|
|
167
151
|
next if seen.include?(down)
|
|
152
|
+
|
|
168
153
|
seen << down
|
|
169
154
|
val.empty? ? nil : val
|
|
170
|
-
|
|
155
|
+
end.compact.join(" ")
|
|
171
156
|
stage_text.empty? ? nil : stage_text
|
|
172
157
|
end
|
|
173
158
|
|
|
174
159
|
# Extract document type from ext.doctype.
|
|
175
160
|
def extract_doctype(bibdata)
|
|
176
161
|
return nil unless bibdata.respond_to?(:ext)
|
|
162
|
+
|
|
177
163
|
ext = bibdata.ext
|
|
178
164
|
return nil unless ext
|
|
179
165
|
|
|
@@ -181,11 +167,11 @@ module Metanorma
|
|
|
181
167
|
return nil unless doctypes && !doctypes.empty?
|
|
182
168
|
|
|
183
169
|
# Prefer English-language doctype
|
|
184
|
-
en_dt = doctypes.find
|
|
170
|
+
en_dt = doctypes.find do |d|
|
|
185
171
|
lang = safe_attr(d, :language)
|
|
186
172
|
lang == "en" if lang
|
|
187
|
-
|
|
188
|
-
return en_dt.value.to_s if en_dt
|
|
173
|
+
end
|
|
174
|
+
return en_dt.value.to_s if en_dt&.value
|
|
189
175
|
|
|
190
176
|
# Fallback: first doctype
|
|
191
177
|
dt = doctypes.first
|
|
@@ -216,7 +202,7 @@ module Metanorma
|
|
|
216
202
|
all_items.each do |node|
|
|
217
203
|
next if node.is_a?(String)
|
|
218
204
|
next if is_title_element?(node, doc.sections)
|
|
219
|
-
|
|
205
|
+
|
|
220
206
|
render(node)
|
|
221
207
|
end
|
|
222
208
|
|
|
@@ -254,13 +240,13 @@ module Metanorma
|
|
|
254
240
|
stage_text = extract_stage(bibdata)
|
|
255
241
|
|
|
256
242
|
@output << render_liquid("_iso_cover.html.liquid", {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
243
|
+
"publisher_logos" => logos,
|
|
244
|
+
"doc_id" => doc_id,
|
|
245
|
+
"pub_date" => pub_date,
|
|
246
|
+
"doctype" => doctype,
|
|
247
|
+
"title" => title_text,
|
|
248
|
+
"stage" => stage_text,
|
|
249
|
+
})
|
|
264
250
|
end
|
|
265
251
|
|
|
266
252
|
def render_doc_title(doc)
|
|
@@ -274,8 +260,8 @@ module Metanorma
|
|
|
274
260
|
return unless en_title
|
|
275
261
|
|
|
276
262
|
@output << render_liquid("_iso_doc_title.html.liquid", {
|
|
277
|
-
|
|
278
|
-
|
|
263
|
+
"title" => en_title.to_s,
|
|
264
|
+
})
|
|
279
265
|
end
|
|
280
266
|
|
|
281
267
|
def render_boilerplate_section(doc)
|
|
@@ -303,7 +289,7 @@ module Metanorma
|
|
|
303
289
|
fw_id = safe_attr(fw, :id)
|
|
304
290
|
title_text = extract_plain_text(title)
|
|
305
291
|
register_toc_entry(id: fw_id, level: level, text: title_text)
|
|
306
|
-
@output << "<h1 class=\"
|
|
292
|
+
@output << "<h1 class=\"foreword-title\">"
|
|
307
293
|
render_mixed_inline(title)
|
|
308
294
|
@output << "</h1>"
|
|
309
295
|
end
|
|
@@ -319,7 +305,7 @@ module Metanorma
|
|
|
319
305
|
sec_id = safe_attr(section, :id)
|
|
320
306
|
title_text = extract_plain_text(title)
|
|
321
307
|
register_toc_entry(id: sec_id, level: level, text: title_text)
|
|
322
|
-
@output << "<h1 class=\"
|
|
308
|
+
@output << "<h1 class=\"intro-title\">"
|
|
323
309
|
render_mixed_inline(title)
|
|
324
310
|
@output << "</h1>"
|
|
325
311
|
end
|
|
@@ -344,7 +330,7 @@ module Metanorma
|
|
|
344
330
|
# --- Clause rendering ---
|
|
345
331
|
|
|
346
332
|
def render_clause(clause, level: 1, **_opts)
|
|
347
|
-
attrs = element_attrs(id: safe_attr(clause, :id)
|
|
333
|
+
attrs = element_attrs(id: safe_attr(clause, :id))
|
|
348
334
|
tag("div", attrs) do
|
|
349
335
|
render_title(clause, level)
|
|
350
336
|
render_ordered_content(clause, level)
|
|
@@ -354,7 +340,7 @@ module Metanorma
|
|
|
354
340
|
# --- Annex rendering ---
|
|
355
341
|
|
|
356
342
|
def render_annex(annex, level: 1, **_opts)
|
|
357
|
-
attrs = element_attrs(id: safe_attr(annex, :id), class: "
|
|
343
|
+
attrs = element_attrs(id: safe_attr(annex, :id), class: "section-sub")
|
|
358
344
|
tag("div", attrs) do
|
|
359
345
|
render_annex_title(annex, level)
|
|
360
346
|
render_ordered_content(annex, level)
|
|
@@ -370,7 +356,7 @@ module Metanorma
|
|
|
370
356
|
register_toc_entry(id: annex_id, level: level, text: title_text)
|
|
371
357
|
|
|
372
358
|
h = "h#{[[level, 6].min, 1].max}"
|
|
373
|
-
@output << "<#{h} class=\"
|
|
359
|
+
@output << "<#{h} class=\"annex-title\">"
|
|
374
360
|
render_mixed_inline(title_element)
|
|
375
361
|
@output << "</#{h}>"
|
|
376
362
|
end
|
|
@@ -398,7 +384,7 @@ module Metanorma
|
|
|
398
384
|
# In presentation mode, use fmt_* elements
|
|
399
385
|
if term.fmt_name
|
|
400
386
|
# Render term number (e.g. "3.1")
|
|
401
|
-
@output << "<p class=\"
|
|
387
|
+
@output << "<p class=\"term-number\">"
|
|
402
388
|
render_inline_element(term.fmt_name)
|
|
403
389
|
@output << "</p>"
|
|
404
390
|
elsif term.term_number
|
|
@@ -408,7 +394,7 @@ module Metanorma
|
|
|
408
394
|
else
|
|
409
395
|
extract_text_value(tn)
|
|
410
396
|
end
|
|
411
|
-
@output << "<p class=\"
|
|
397
|
+
@output << "<p class=\"term-number\">#{escape_html(tn_text)}</p>"
|
|
412
398
|
end
|
|
413
399
|
|
|
414
400
|
# Preferred designations — use fmt-preferred if available
|
|
@@ -436,7 +422,7 @@ module Metanorma
|
|
|
436
422
|
# (fmt-definition already includes domain text in its content)
|
|
437
423
|
if term.domain && !term.fmt_definition
|
|
438
424
|
domain_text = safe_attr(term.domain, :text)
|
|
439
|
-
@output << "<p class=\"domain\"><#{escape_html(domain_text)}></p>" if domain_text
|
|
425
|
+
@output << "<p class=\"term-domain\"><#{escape_html(domain_text)}></p>" if domain_text
|
|
440
426
|
end
|
|
441
427
|
|
|
442
428
|
# Definition — use fmt-definition if available
|
|
@@ -458,7 +444,7 @@ module Metanorma
|
|
|
458
444
|
# Source references — use fmt-termsource if available
|
|
459
445
|
if term.fmt_termsource && !term.fmt_termsource.empty?
|
|
460
446
|
term.fmt_termsource.each do |fts|
|
|
461
|
-
@output << "<p class=\"source\">"
|
|
447
|
+
@output << "<p class=\"term-source\">"
|
|
462
448
|
render_mixed_inline(fts)
|
|
463
449
|
@output << "</p>"
|
|
464
450
|
end
|
|
@@ -485,7 +471,8 @@ module Metanorma
|
|
|
485
471
|
if term.preferred && !term.preferred.empty?
|
|
486
472
|
return extract_designation_name(term.preferred.first).to_s
|
|
487
473
|
end
|
|
488
|
-
|
|
474
|
+
|
|
475
|
+
safe_attr(term, :id).to_s.delete_prefix("term-")
|
|
489
476
|
end
|
|
490
477
|
|
|
491
478
|
def extract_term_definition(term)
|
|
@@ -502,11 +489,11 @@ module Metanorma
|
|
|
502
489
|
|
|
503
490
|
def strip_html(html)
|
|
504
491
|
html.gsub(/<[^>]+>/, "").gsub("<", "<").gsub(">", ">")
|
|
505
|
-
|
|
492
|
+
.gsub("&", "&").gsub(" ", " ")
|
|
506
493
|
end
|
|
507
494
|
|
|
508
495
|
def render_term_designation(designation, type)
|
|
509
|
-
css_class = type == "deprecated" ? "
|
|
496
|
+
css_class = type == "deprecated" ? "term-deprecated" : "term-name"
|
|
510
497
|
@output << "<p class=\"#{css_class}\" style=\"text-align:left;\">"
|
|
511
498
|
@output << "<del>" if type == "deprecated"
|
|
512
499
|
@output << "<b><dfn>"
|
|
@@ -582,32 +569,6 @@ module Metanorma
|
|
|
582
569
|
end
|
|
583
570
|
end
|
|
584
571
|
|
|
585
|
-
def render_term_note(note)
|
|
586
|
-
attrs = element_attrs(id: safe_attr(note, :id), class: "Note")
|
|
587
|
-
tag("div", attrs) do
|
|
588
|
-
label = extract_termnote_label(note)
|
|
589
|
-
@output << "<p><span class=\"termnote_label\">#{escape_html(label)}: </span>"
|
|
590
|
-
note.p&.each { |para| render_mixed_inline(para) }
|
|
591
|
-
@output << "</p>"
|
|
592
|
-
note.ul&.each { |ul| render_unordered_list(ul) }
|
|
593
|
-
note.ol&.each { |ol| render_ordered_list(ol) }
|
|
594
|
-
note.dl&.then { |dl| render_definition_list(dl) }
|
|
595
|
-
end
|
|
596
|
-
end
|
|
597
|
-
|
|
598
|
-
def render_term_example(example)
|
|
599
|
-
attrs = element_attrs(id: safe_attr(example, :id), class: "example")
|
|
600
|
-
tag("div", attrs) do
|
|
601
|
-
label = extract_block_label(example, "EXAMPLE")
|
|
602
|
-
@output << "<p><span class=\"example_label\">#{escape_html(label)}</span> "
|
|
603
|
-
example.p&.each { |para| render_mixed_inline(para) }
|
|
604
|
-
@output << "</p>"
|
|
605
|
-
example.ul&.each { |ul| render_unordered_list(ul) }
|
|
606
|
-
example.ol&.each { |ol| render_ordered_list(ol) }
|
|
607
|
-
example.dl&.then { |dl| render_definition_list(dl) }
|
|
608
|
-
end
|
|
609
|
-
end
|
|
610
|
-
|
|
611
572
|
# --- Boilerplate rendering ---
|
|
612
573
|
|
|
613
574
|
def render_boilerplate(boilerplate, **_opts)
|
|
@@ -627,7 +588,13 @@ module Metanorma
|
|
|
627
588
|
.gsub(/<variant-title[^>]*>.*?<\/variant-title>/m, "")
|
|
628
589
|
.gsub(/<\/?(?:copyright-statement|clause)[^>]*>/, "")
|
|
629
590
|
|
|
630
|
-
|
|
591
|
+
# Remap XML class names to HTML-specific class names
|
|
592
|
+
boilerplate_doc = Nokogiri::HTML::DocumentFragment.parse(clean)
|
|
593
|
+
boilerplate_doc.css("[class]").each do |el|
|
|
594
|
+
el["class"] = el["class"].split(/\s+/).map { |c| html_class_for_span(c) }.join(" ")
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
@output << boilerplate_doc.inner_html.strip
|
|
631
598
|
|
|
632
599
|
@output << "</div>"
|
|
633
600
|
end
|
|
@@ -641,19 +608,19 @@ module Metanorma
|
|
|
641
608
|
next_sib = next_sib.next_sibling
|
|
642
609
|
end
|
|
643
610
|
|
|
644
|
-
display_text = if next_sib
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
display_text ||= target.to_s.
|
|
611
|
+
display_text = if next_sib&.element? && next_sib.name == "semx"
|
|
612
|
+
fmt_link = next_sib.at_css("fmt-link")
|
|
613
|
+
if fmt_link
|
|
614
|
+
fmt_target = fmt_link["target"] || fmt_link["href"] || target
|
|
615
|
+
display_text = fmt_target.to_s.delete_prefix("mailto:")
|
|
616
|
+
next_sib.remove
|
|
617
|
+
display_text
|
|
618
|
+
end
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
display_text ||= target.to_s.delete_prefix("mailto:")
|
|
655
622
|
a_tag = Nokogiri::HTML::DocumentFragment.parse(
|
|
656
|
-
"<a href=\"#{CGI.escapeHTML(target.to_s)}\">#{CGI.escapeHTML(display_text)}</a>"
|
|
623
|
+
"<a href=\"#{CGI.escapeHTML(target.to_s)}\">#{CGI.escapeHTML(display_text)}</a>",
|
|
657
624
|
)
|
|
658
625
|
link.replace(a_tag)
|
|
659
626
|
end
|
|
@@ -676,128 +643,29 @@ module Metanorma
|
|
|
676
643
|
@output << "</#{h}>"
|
|
677
644
|
end
|
|
678
645
|
|
|
679
|
-
# Collect all renderable children from a section, sorted by displayorder.
|
|
680
|
-
# Uses element_order directly because each_mixed_content returns early
|
|
681
|
-
# when the model class doesn't declare mixed_content (mixed? is false).
|
|
682
|
-
def collect_ordered_children(section)
|
|
683
|
-
children = gather_element_order_children(section)
|
|
684
|
-
|
|
685
|
-
# Also gather typed attributes that may not appear in element_order
|
|
686
|
-
%i[terms definitions].each do |attr|
|
|
687
|
-
val = safe_attr(section, attr)
|
|
688
|
-
next if val.nil?
|
|
689
|
-
Array(val).each do |v|
|
|
690
|
-
children << v unless children.include?(v)
|
|
691
|
-
end
|
|
692
|
-
end
|
|
693
|
-
|
|
694
|
-
# Sort by displayorder (non-nil first, then nil at end)
|
|
695
|
-
children.reject!(&:nil?)
|
|
696
|
-
children.sort_by do |node|
|
|
697
|
-
order = node.displayorder rescue nil
|
|
698
|
-
order &&= order.to_i
|
|
699
|
-
order || Float::INFINITY
|
|
700
|
-
end
|
|
701
|
-
end
|
|
702
|
-
|
|
703
|
-
def render_ordered_content(section, level = 1)
|
|
704
|
-
children = collect_ordered_children(section)
|
|
705
|
-
children.each do |node|
|
|
706
|
-
next if node.is_a?(String)
|
|
707
|
-
next if is_title_element?(node, section)
|
|
708
|
-
|
|
709
|
-
render(node, level: level + 1)
|
|
710
|
-
end
|
|
711
|
-
end
|
|
712
|
-
|
|
713
|
-
private
|
|
714
|
-
|
|
715
|
-
# Filter document title paragraphs that are rendered by render_doc_title
|
|
716
|
-
def is_doc_title_paragraph?(node)
|
|
717
|
-
return false unless node.respond_to?(:class_attr)
|
|
718
|
-
["zzSTDTitle1", "zzSTDTitle2"].include?(node.class_attr)
|
|
719
|
-
end
|
|
720
|
-
|
|
721
646
|
# Collect all document-level children (sections, normative refs, annexes,
|
|
722
647
|
# bibliography) sorted by displayorder for correct document order.
|
|
648
|
+
# Top-level paragraphs in sections (title paragraphs) are excluded —
|
|
649
|
+
# they are rendered separately by render_doc_title.
|
|
723
650
|
def collect_document_children(doc)
|
|
724
651
|
items = []
|
|
725
652
|
|
|
726
|
-
# Main sections children (clauses, terms, etc.)
|
|
727
653
|
if doc.sections
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
val = safe_attr(doc.sections, attr)
|
|
732
|
-
next if val.nil?
|
|
733
|
-
Array(val).each { |v| items << v unless items.include?(v) }
|
|
654
|
+
section_children = collect_ordered_children(doc.sections)
|
|
655
|
+
section_children.reject! do |node|
|
|
656
|
+
node.is_a?(Metanorma::Document::Components::Paragraphs::ParagraphBlock)
|
|
734
657
|
end
|
|
658
|
+
items.concat(section_children)
|
|
735
659
|
end
|
|
736
660
|
|
|
737
|
-
|
|
738
|
-
if doc.bibliography && doc.bibliography.references
|
|
739
|
-
doc.bibliography.references.each { |r| items << r }
|
|
740
|
-
end
|
|
741
|
-
|
|
742
|
-
# Annexes
|
|
661
|
+
doc.bibliography&.references&.each { |r| items << r }
|
|
743
662
|
doc.annex&.each { |a| items << a }
|
|
744
663
|
|
|
745
|
-
# Non-normative bibliography (no displayorder = goes at end)
|
|
746
|
-
if doc.bibliography && doc.bibliography.references
|
|
747
|
-
# Already included above; filter normative vs non-normative below
|
|
748
|
-
end
|
|
749
|
-
|
|
750
664
|
items.compact!
|
|
751
|
-
items
|
|
752
|
-
order = node.displayorder rescue nil
|
|
753
|
-
order &&= order.to_i
|
|
754
|
-
order || Float::INFINITY
|
|
755
|
-
end
|
|
756
|
-
end
|
|
757
|
-
|
|
758
|
-
# Iterate element_order directly, bypassing each_mixed_content which
|
|
759
|
-
# requires mixed?/ordered? to be true (many section models aren't).
|
|
760
|
-
def gather_element_order_children(node)
|
|
761
|
-
children = []
|
|
762
|
-
return children unless node.is_a?(Lutaml::Model::Serializable)
|
|
763
|
-
return children unless node.element_order && !node.element_order.empty?
|
|
764
|
-
|
|
765
|
-
xml_mapping = node.class.mappings_for(:xml, node.lutaml_register)
|
|
766
|
-
return children unless xml_mapping
|
|
767
|
-
|
|
768
|
-
element_to_attr = {}
|
|
769
|
-
xml_mapping.mapping_elements_hash.each_value do |rule_or_array|
|
|
770
|
-
Array(rule_or_array).each do |rule|
|
|
771
|
-
element_to_attr[rule.name] = rule.to
|
|
772
|
-
element_to_attr[rule.name.to_s] = rule.to if rule.name.is_a?(Symbol)
|
|
773
|
-
end
|
|
774
|
-
end
|
|
775
|
-
|
|
776
|
-
indices = Hash.new(0)
|
|
777
|
-
|
|
778
|
-
node.element_order.each do |el|
|
|
779
|
-
if el.text?
|
|
780
|
-
children << el.text_content if el.text_content
|
|
781
|
-
elsif el.element?
|
|
782
|
-
attr_name = element_to_attr[el.name]
|
|
783
|
-
next unless attr_name
|
|
784
|
-
|
|
785
|
-
coll = node.send(attr_name)
|
|
786
|
-
obj = if coll.is_a?(Array)
|
|
787
|
-
idx = indices[attr_name]
|
|
788
|
-
indices[attr_name] += 1
|
|
789
|
-
coll[idx]
|
|
790
|
-
else
|
|
791
|
-
coll
|
|
792
|
-
end
|
|
793
|
-
children << obj if obj
|
|
794
|
-
end
|
|
795
|
-
end
|
|
796
|
-
|
|
797
|
-
children
|
|
665
|
+
sort_by_displayorder(items)
|
|
798
666
|
end
|
|
799
667
|
|
|
800
|
-
def publisher_logos_html(
|
|
668
|
+
def publisher_logos_html(_doc)
|
|
801
669
|
publishers = flavor_publishers(extract_primary_doc_id)
|
|
802
670
|
logo_map = publisher_logo_map
|
|
803
671
|
return [] if publishers.empty? && logo_map.empty?
|
|
@@ -811,8 +679,8 @@ module Metanorma
|
|
|
811
679
|
next unless svg
|
|
812
680
|
|
|
813
681
|
# White fill for dark cover background
|
|
814
|
-
svg = svg.gsub(
|
|
815
|
-
svg = svg.gsub(
|
|
682
|
+
svg = svg.gsub("fill:#00b1ff", "fill:white") if pub == "OGC"
|
|
683
|
+
svg = svg.gsub("fill:#e3000f", "fill:white") if pub == "ISO"
|
|
816
684
|
svg
|
|
817
685
|
end
|
|
818
686
|
end
|
|
@@ -5,7 +5,6 @@ module Metanorma
|
|
|
5
5
|
# Renders OgcDocument components to HTML.
|
|
6
6
|
# Extends IsoRenderer with OGC-specific branding (geospatial, OGC cyan-blue #00b1ff).
|
|
7
7
|
class OgcRenderer < IsoRenderer
|
|
8
|
-
registers_doc_type Metanorma::OgcDocument::Root
|
|
9
8
|
|
|
10
9
|
def flavor_publishers(_doc_id)
|
|
11
10
|
["OGC"]
|
|
@@ -46,7 +45,7 @@ module Metanorma
|
|
|
46
45
|
t.example_bg = "#e8f4fa"
|
|
47
46
|
t.example_color = "#004d73"
|
|
48
47
|
t.admonition_border = "#e8812e"
|
|
49
|
-
t.admonition_bg
|
|
48
|
+
t.admonition_bg = "#fff5eb"
|
|
50
49
|
t.admonition_color = "#c06a1a"
|
|
51
50
|
t.footer_border_color = "#00b1ff"
|
|
52
51
|
t.cover_separator_color = "rgba(0,177,255,0.25)"
|
|
@@ -69,13 +68,13 @@ module Metanorma
|
|
|
69
68
|
preface_clauses = preface.clause&.reject { |cl| cl.type == "toc" } || []
|
|
70
69
|
|
|
71
70
|
return if preface_clauses.empty? &&
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
!preface.foreword && !preface.introduction &&
|
|
72
|
+
!preface.abstract && !preface.acknowledgements &&
|
|
73
|
+
!preface.executivesummary
|
|
75
74
|
|
|
76
75
|
@output << "<div id=\"preface\" class=\"preface-section\">"
|
|
77
76
|
register_toc_entry(id: "preface", level: 1, text: "Preface")
|
|
78
|
-
@output << "<h1 class=\"
|
|
77
|
+
@output << "<h1 class=\"foreword-title\">Preface</h1>"
|
|
79
78
|
|
|
80
79
|
preface_clauses.each { |cl| render(cl, level: 2) }
|
|
81
80
|
|
|
@@ -5,7 +5,6 @@ module Metanorma
|
|
|
5
5
|
# Renders PDF Association (PDFA) taste documents to HTML.
|
|
6
6
|
# PDFA brand: #cf9c1d gold + #d03544 red + #4992b2 steel blue from logo
|
|
7
7
|
class PdfaRenderer < IsoRenderer
|
|
8
|
-
registers_doc_type Metanorma::RiboseDocument::Root
|
|
9
8
|
|
|
10
9
|
def flavor_publishers(_doc_id)
|
|
11
10
|
["PDF Association"]
|