Class: IsoDoc::Iso::PresentationXMLConvert
- Inherits:
-
PresentationXMLConvert
- Object
- PresentationXMLConvert
- IsoDoc::Iso::PresentationXMLConvert
show all
- Includes:
- Init
- Defined in:
- lib/isodoc/iso/presentation_xref.rb,
lib/isodoc/iso/presentation_terms.rb,
lib/isodoc/iso/presentation_bibdata.rb,
lib/isodoc/iso/presentation_section.rb,
lib/isodoc/iso/presentation_xml_convert.rb
Constant Summary
collapse
- LOCALITY2SPAN =
ISO has not bothered to communicate to us what most of these span classes mean
{
annex: "citeapp",
dunno: "citebase",
dunno2: "citebib",
dunno3: "citebox",
dunno4: "citeen",
dunno5: "citeeq",
figure: "citefig",
dunno6: "citefn",
clause: "citesec",
dunno7: "citesection",
table: "citetbl",
dunno8: "citetfn",
}.freeze
Instance Method Summary
collapse
-
#admonition1(elem) ⇒ Object
-
#admonition_delim(elem) ⇒ Object
-
#admonition_outside_clauses(elem) ⇒ Object
-
#anchor_linkend1(node) ⇒ Object
-
#anchor_value(id) ⇒ Object
-
#annex(isoxml) ⇒ Object
Redo Amendment annex titles as numbered.
-
#bibdata(docxml) ⇒ Object
-
#bibdata_i18n(bib) ⇒ Object
-
#bibdata_i18n_stage(bib, stage, type, lang: @lang, i18n: @i18n) ⇒ Object
-
#bibdata_i18n_stage1(stage, type, lang, i18n) ⇒ Object
-
#bibrender_formattedref(formattedref, xml) ⇒ Object
-
#block(docxml) ⇒ Object
-
#can_conflate_eref_rendering?(refs) ⇒ Boolean
-
#clause(docxml) ⇒ Object
Redo Amendment annex subclause titles as numbered.
-
#clause1(node) ⇒ Object
-
#clause1_section_prefix(node) ⇒ Object
-
#comments(docxml) ⇒ Object
-
#concept(docxml) ⇒ Object
-
#concept1(node) ⇒ Object
-
#concept1_ref_content(ref) ⇒ Object
-
#concept_term(docxml) ⇒ Object
-
#concept_term1(node, seen) ⇒ Object
-
#convert1(docxml, filename, dir) ⇒ Object
-
#convert_i18n_init(docxml) ⇒ Object
-
#edition_printing_date(bibdata) ⇒ Object
-
#edition_replacement(bibdata) ⇒ Object
-
#edition_translate(bibdata) ⇒ Object
-
#editorialgroup_identifier(docxml) ⇒ Object
-
#editorialgroup_identifier1(group) ⇒ Object
-
#editorialgroup_identifier2(group, level) ⇒ Object
-
#enable_indexsect ⇒ Object
-
#eref_delim(delim, type) ⇒ Object
-
#eref_localities1(opt) ⇒ Object
-
#eref_localities1_zh(opt) ⇒ Object
-
#eref_localities_conflated(refs, target, node) ⇒ Object
-
#example_span_label(_node, div, name) ⇒ Object
-
#expand_citeas(text) ⇒ Object
-
#figure_delim(elem) ⇒ Object
-
#figure_label?(_elem) ⇒ Boolean
-
#figure_name(elem) ⇒ Object
-
#fn_ref_label(fnote) ⇒ Object
-
#formula_where(dlist) ⇒ Object
-
#formula_where_one(dlist) ⇒ Object
-
#implicit_reference(bib) ⇒ Object
-
#insertall_after_here(node, insert, name) ⇒ Object
-
#labelled_ancestor(elem, exceptions = []) ⇒ Object
-
#locality_delimiter(loc) ⇒ Object
-
#locality_span_wrap(ret, type) ⇒ Object
-
#middle_title(docxml) ⇒ Object
-
#middle_title_amd ⇒ Object
-
#middle_title_main ⇒ Object
-
#middle_title_part ⇒ Object
-
#move_norm_ref_to_sections(docxml) ⇒ Object
-
#note1(elem) ⇒ Object
-
#ol_depth(node) ⇒ Object
-
#ol_label_template(_elem) ⇒ Object
-
#prefix_clause(target, loc) ⇒ Object
-
#prefix_container(container, linkend, node, target) ⇒ Object
7 a) : Clause 7 a), but Clause 7 List 1 a).
-
#prefix_container_template(container, node, target) ⇒ Object
-
#related1(node) ⇒ Object
-
#render_identifier(ident) ⇒ Object
-
#requirement_note1(elem) ⇒ Object
-
#subclause?(target, type, from) ⇒ Boolean
-
#subfigure_delim ⇒ Object
-
#table1(elem) ⇒ Object
-
#table1_fmt_xref_modspec(elem) ⇒ Object
-
#table1_key(elem) ⇒ Object
-
#termexamples_before_termnotes(node) ⇒ Object
-
#terms(docxml) ⇒ Object
-
#termsource_status(status) ⇒ Object
-
#toc_title(docxml) ⇒ Object
-
#twitter_cldr_localiser_symbols ⇒ Object
-
#ul_label_list(_elem) ⇒ Object
-
#warning_for_missing_metadata(docxml) ⇒ Object
-
#warning_for_missing_metadata_create(docxml) ⇒ Object
-
#warning_for_missing_metadata_post(docxml, ret) ⇒ Object
-
#wrap_in_bold(cell) ⇒ Object
-
#xref_init(lang, script, klass, labels, options) ⇒ Object
Methods included from Init
#amd?, #bibrenderer, #clausedelim, #i18n_conditional_set, #i18n_init, #metadata_init, #requirements_processor, #std_docid_semantic, #std_docid_semantic1, #std_docid_semantic_full, #update_i18n
Instance Method Details
#admonition1(elem) ⇒ Object
74
75
76
77
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 74
def admonition1(elem)
super
admonition_outside_clauses(elem)
end
|
#admonition_delim(elem) ⇒ Object
179
180
181
182
183
184
185
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 179
def admonition_delim(elem)
if elem.at("./*[not(self::xmlns:name)]")&.name == "p"
" — "
else
""
end
end
|
#admonition_outside_clauses(elem) ⇒ Object
79
80
81
82
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 79
def admonition_outside_clauses(elem)
elem.parent.name == "sections" or return
wrap_in_bold(elem)
end
|
#anchor_linkend1(node) ⇒ Object
145
146
147
148
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 145
def anchor_linkend1(node)
locality_span_wrap(super, @xrefs.anchor(node["target"], :subtype) ||
@xrefs.anchor(node["target"], :type))
end
|
#anchor_value(id) ⇒ Object
140
141
142
143
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 140
def anchor_value(id)
locality_span_wrap(super, @xrefs.anchor(id, :subtype) ||
@xrefs.anchor(id, :type))
end
|
#annex(isoxml) ⇒ Object
Redo Amendment annex titles as numbered
45
46
47
48
49
|
# File 'lib/isodoc/iso/presentation_section.rb', line 45
def annex(isoxml)
amd?(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
super
amd?(isoxml) and @suppressheadingnumbers = true
end
|
#bibdata(docxml) ⇒ Object
4
5
6
7
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 4
def bibdata(docxml)
super
editorialgroup_identifier(docxml)
end
|
#bibdata_i18n(bib) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 33
def bibdata_i18n(bib)
hash_translate(bib, @i18n.get["doctype_dict"], "./ext/doctype")
bibdata_i18n_stage(bib, bib.at(ns("./status/stage")),
bib.at(ns("./ext/doctype")))
hash_translate(bib, @i18n.get["substage_dict"],
"./status/substage")
edition_translate(bib)
end
|
#bibdata_i18n_stage(bib, stage, type, lang: @lang, i18n: @i18n) ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 67
def bibdata_i18n_stage(bib, stage, type, lang: @lang, i18n: @i18n)
stage or return
i18n.get.dig("stage_dict", stage.text).is_a?(Hash) or
return hash_translate(bib, i18n.get["stage_dict"],
"./status/stage", lang)
bibdata_i18n_stage1(stage, type, lang, i18n)
end
|
#bibdata_i18n_stage1(stage, type, lang, i18n) ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 75
def bibdata_i18n_stage1(stage, type, lang, i18n)
stagetype = i18n.get.dig("stage_dict", stage.text, type&.text) or return
h = i18n.get.dig("stage_draft_variants", stagetype) and h.each do |k, v|
tag_translate(stage, lang, v)
stage.next["type"] = k
end
tag_translate(stage, lang, stagetype)
end
|
91
92
93
94
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 91
def bibrender_formattedref(formattedref, xml)
%w(techreport standard).include? xml["type"] and return
super
end
|
#block(docxml) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 26
def block(docxml)
amend docxml
figure docxml
sourcecode docxml
formula docxml
admonition docxml
source docxml
ul docxml
ol docxml
quote docxml
permission docxml
requirement docxml
recommendation docxml
requirement_render docxml
@xrefs.anchors_previous = @xrefs.anchors.dup @xrefs.parse docxml
table docxml dl docxml
example docxml
note docxml
end
|
#can_conflate_eref_rendering?(refs) ⇒ Boolean
14
15
16
17
18
19
20
21
22
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 14
def can_conflate_eref_rendering?(refs)
super or return false
first = subclause?(nil, refs.first.at(ns("./locality/@type"))&.text,
refs.first.at(ns("./locality/referenceFrom"))&.text)
refs.all? do |r|
subclause?(nil, r.at(ns("./locality/@type"))&.text,
r.at(ns("./locality/referenceFrom"))&.text) == first
end
end
|
#clause(docxml) ⇒ Object
Redo Amendment annex subclause titles as numbered
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/isodoc/iso/presentation_section.rb', line 52
def clause(docxml)
super
amd?(docxml) or return
@suppressheadingnumbers = @oldsuppressheadingnumbers
docxml.xpath(ns("//annex//clause | //annex//appendix")).each do |f|
f.xpath(ns("./fmt-title | ./fmt-xref-label")).each(&:remove)
clause1(f)
end
@suppressheadingnumbers = true
end
|
#clause1(node) ⇒ Object
64
65
66
67
68
69
70
|
# File 'lib/isodoc/iso/presentation_section.rb', line 64
def clause1(node)
!node.at(ns("./title")) &&
!%w(sections preface bibliography).include?(node.parent.name) and
node["inline-header"] = "true"
super
clause1_section_prefix(node)
end
|
#clause1_section_prefix(node) ⇒ Object
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/isodoc/iso/presentation_section.rb', line 72
def clause1_section_prefix(node)
if node["type"] == "section" &&
c = node.at(ns("./fmt-title//span[@class = 'fmt-caption-delim']"))
c.add_first_child(":")
t = node.at(ns("./fmt-title"))
t.replace @i18n.l10n(to_xml(t).gsub("<tab/>", "<tab> </tab>"))
.gsub(%r{<tab>[^<]+</tab>}, "<tab/>")
end
end
|
4
5
6
7
|
# File 'lib/isodoc/iso/presentation_section.rb', line 4
def (docxml)
warning_for_missing_metadata(docxml)
super
end
|
#concept(docxml) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 10
def concept(docxml)
concept_term(docxml)
(docxml.xpath(ns("//concept")) - docxml.xpath(ns("//term//concept")))
.each do |node|
node.ancestors("definition, termsource, related").empty? and
concept_render(node, ital: "false", ref: "false",
linkref: "true", linkmention: "false")
end
end
|
#concept1(node) ⇒ Object
53
54
55
56
57
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 53
def concept1(node)
node.replace(node&.at(ns("./renderterm"))&.children ||
node&.at(ns("./refterm"))&.children ||
node.children)
end
|
#concept1_ref_content(ref) ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 43
def concept1_ref_content(ref)
prev = "("
foll = ")"
if ref.name == "termref"
prev, foll = @i18n.term_defined_in.split("%")
end
ref.previous = prev
ref.next = foll
end
|
#concept_term(docxml) ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 20
def concept_term(docxml)
docxml.xpath(ns("//term")).each do |f|
m = {}
(f.xpath(ns(".//concept")) - f.xpath(ns(".//term//concept")))
.each do |c|
c.ancestors("definition, termsource, related").empty? and
concept_term1(c, m)
end
end
end
|
#concept_term1(node, seen) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 31
def concept_term1(node, seen)
term = to_xml(node.at(ns("./refterm")))
if term && seen[term]
concept_render(node, ital: "false", ref: "false",
linkref: "true", linkmention: "false")
else concept_render(node, ital: "true", ref: "true",
linkref: "true", linkmention: "false")
end
seen[term] = true if term
seen
end
|
#convert1(docxml, filename, dir) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 17
def convert1(docxml, filename, dir)
@iso_class = instance_of?(IsoDoc::Iso::PresentationXMLConvert)
if amd?(docxml)
@oldsuppressheadingnumbers = @suppressheadingnumbers
@suppressheadingnumbers = true
end
super
end
|
#convert_i18n_init(docxml) ⇒ Object
12
13
14
15
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 12
def convert_i18n_init(docxml)
super
update_i18n(docxml)
end
|
#edition_printing_date(bibdata) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 50
def edition_printing_date(bibdata)
@i18n.get["date_printing"] &&
pd = bibdata.at(ns("//metanorma-extension/presentation-metadata/" \
"printing-date[1]")) or return
x = @i18n.populate("date_printing", { "var1" => pd.text.to_i })
bibdata.at(ns("./ext")) << "<date-printing>#{x}</date-printing>"
end
|
#edition_replacement(bibdata) ⇒ Object
58
59
60
61
62
63
64
65
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 58
def edition_replacement(bibdata)
e = bibdata.at(ns("./edition[not(@language) or @language = '']"))&.text
if /^\d+$/.match?(e) && e.to_i > 1
h = { "var1" => e.to_i, "var2" => e.to_i - 1 }
x = @i18n.populate("edition_replacement", h)
bibdata.at(ns("./ext")) << "<edn-replacement>#{x}</edn-replacement>"
end
end
|
#edition_translate(bibdata) ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 42
def edition_translate(bibdata)
super
@lang == "fr" and e = bibdata.at(ns("./edition[@language = 'fr']")) and
e.children = e.text.sub(/(\d+)(\p{L}+)/, "\\1<sup>\\2</sup>")
@docscheme == "1951" and edition_replacement(bibdata)
edition_printing_date(bibdata)
end
|
#editorialgroup_identifier(docxml) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 9
def editorialgroup_identifier(docxml)
%w(editorialgroup approvalgroup).each do |v|
docxml.xpath(ns("//bibdata/ext/#{v}")).each do |a|
editorialgroup_identifier1(a)
end
end
end
|
#editorialgroup_identifier1(group) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 17
def editorialgroup_identifier1(group)
agency = group.xpath(ns("./agency"))&.map(&:text)
ret = %w(technical-committee subcommittee workgroup)
.each_with_object([]) do |v, m|
m << editorialgroup_identifier2(group, v)
end
group["identifier"] = (agency + ret.compact).join("/")
end
|
#editorialgroup_identifier2(group, level) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/isodoc/iso/presentation_bibdata.rb', line 26
def editorialgroup_identifier2(group, level)
a = group.at(ns("./#{level}")) or return nil
type = a["type"]
type&.casecmp("other")&.zero? and type = ""
"#{type} #{a['number']}".strip
end
|
#enable_indexsect ⇒ Object
133
134
135
|
# File 'lib/isodoc/iso/presentation_section.rb', line 133
def enable_indexsect
true
end
|
#eref_delim(delim, type) ⇒ Object
8
9
10
11
12
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 8
def eref_delim(delim, type)
if delim == ";" then ";"
else type == "list" ? " " : delim
end
end
|
#eref_localities1(opt) ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 94
def eref_localities1(opt)
return nil if opt[:type] == "anchor"
opt[:type] = opt[:type].downcase
opt[:lang] == "zh" and return l10n(eref_localities1_zh(opt))
ret = ""
opt[:node]["droploc"] != "true" &&
!subclause?(opt[:target], opt[:type], opt[:from]) and
ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
ret += " #{opt[:from]}" if opt[:from]
ret += "–#{opt[:upto]}" if opt[:upto]
ret += ")" if opt[:type] == "list"
ret = l10n(ret)
locality_span_wrap(ret, opt[:type])
end
|
#eref_localities1_zh(opt) ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 84
def eref_localities1_zh(opt)
ret = " 第#{opt[:from]}" if opt[:from]
ret += "–#{opt[:upto]}" if opt[:upto]
opt[:node]["droploc"] != "true" &&
!subclause?(opt[:target], opt[:type], opt[:from]) and
ret += eref_locality_populate(opt[:type], opt[:node], "sg")
ret += ")" if opt[:type] == "list"
locality_span_wrap(ret, opt[:type])
end
|
#eref_localities_conflated(refs, target, node) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 29
def eref_localities_conflated(refs, target, node)
droploc = node["droploc"]
node["droploc"] = true
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
node))
node["droploc"] = droploc
eref_localities1({ target:, number: "pl",
type: prefix_clause(target,
refs.first.at(ns("./locality"))),
from: l10n(ret[1..].join),
node:, lang: @lang })
end
|
#example_span_label(_node, div, name) ⇒ Object
67
68
69
70
71
72
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 67
def example_span_label(_node, div, name)
name.nil? and return
div.span class: "example_label" do |_p|
name.children.each { |n| parse(n, div) }
end
end
|
#expand_citeas(text) ⇒ Object
134
135
136
137
138
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 134
def expand_citeas(text)
ret = super or return
ret.include?("<span") and return ret
std_docid_semantic(super)
end
|
54
55
56
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 54
def figure_delim(elem)
elem.parent.name == "figure" ? "  " : " — "
end
|
63
64
65
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 63
def figure_label?(_elem)
true
end
|
58
59
60
61
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 58
def figure_name(elem)
elem.parent.name == "figure" and return ""
super
end
|
#fn_ref_label(fnote) ⇒ Object
204
205
206
207
208
209
210
211
212
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 204
def fn_ref_label(fnote)
if fnote.ancestors("table, figure").empty? ||
!fnote.ancestors("name, fmt-name").empty?
"<sup>#{fn_label(fnote)}" \
"<span class='fmt-label-delim'>)</span></sup>"
else
super
end
end
|
111
112
113
114
115
116
117
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 111
def formula_where(dlist)
dlist.nil? and return
dlist.xpath(ns("./dt")).size == 1 &&
dlist.at(ns("./dd"))&.elements&.size == 1 &&
dlist.at(ns("./dd/p")) or return super
formula_where_one(dlist)
end
|
119
120
121
122
123
124
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 119
def formula_where_one(dlist)
dt = to_xml(dlist.at(ns("./dt")).children)
dd = to_xml(dlist.at(ns("./dd/p")).children)
dlist.previous = "<p>#{@i18n.where_one} #{dt} #{dd}</p>"
dlist.remove
end
|
#implicit_reference(bib) ⇒ Object
168
169
170
171
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 168
def implicit_reference(bib)
bib.at(ns("./docidentifier"))&.text == "IEV" and return true
super
end
|
#insertall_after_here(node, insert, name) ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 59
def insertall_after_here(node, insert, name)
node.children.each do |n|
n.name == name or next
insert.next = n.remove
insert = n
end
insert
end
|
#labelled_ancestor(elem, exceptions = []) ⇒ Object
158
159
160
161
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 158
def labelled_ancestor(elem, exceptions = [])
elem["class"] == "modspec" and return false
super
end
|
#locality_delimiter(loc) ⇒ Object
24
25
26
27
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 24
def locality_delimiter(loc)
loc&.next_element&.attribute("type")&.text == "list" and return " "
super
end
|
#locality_span_wrap(ret, type) ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 75
def locality_span_wrap(ret, type)
type or return ret
m = /\A(\s*)(?=\S)(.+?)(\s*)\Z/m.match(ret) or return ret
ret = [m[1], m[2], m[3]]
spanclass = LOCALITY2SPAN[type.to_sym] and
ret[1] = "<span class='#{spanclass}'>#{ret[1]}</span>"
ret.join
end
|
#middle_title(docxml) ⇒ Object
88
89
90
91
92
93
94
|
# File 'lib/isodoc/iso/presentation_section.rb', line 88
def middle_title(docxml)
@meta.get[:doctitlemain].nil? || @meta.get[:doctitlemain].empty? and
return
s = docxml.at(ns("//sections")) or return
ret = "#{middle_title_main}#{middle_title_amd}"
s.add_first_child ret
end
|
#middle_title_amd ⇒ Object
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/isodoc/iso/presentation_section.rb', line 117
def middle_title_amd
ret = ""
if a = @meta.get[:doctitleamdlabel]
ret += "<p class='zzSTDTitle2'>#{a}"
a = @meta.get[:doctitleamd] and ret += ": #{a}"
ret += "</p>"
end
a = @meta.get[:doctitlecorrlabel] and
ret += "<p class='zzSTDTitle2'>#{a}</p>"
ret
end
|
#middle_title_main ⇒ Object
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/isodoc/iso/presentation_section.rb', line 96
def middle_title_main
ret = "<span class='boldtitle'>#{@meta.get[:doctitleintro]}"
@meta.get[:doctitleintro] && @meta.get[:doctitlemain] and
ret += " — "
ret += @meta.get[:doctitlemain]
@meta.get[:doctitlemain] && @meta.get[:doctitlepart] and
ret += " — "
ret += "</span>#{middle_title_part}"
"<p class='zzSTDTitle1'>#{ret}</p>"
end
|
#middle_title_part ⇒ Object
107
108
109
110
111
112
113
114
115
|
# File 'lib/isodoc/iso/presentation_section.rb', line 107
def middle_title_part
ret = ""
if a = @meta.get[:doctitlepart]
b = @meta.get[:doctitlepartlabel] and
ret += "<span class='nonboldtitle'>#{b}:</span> "
ret += "<span class='boldtitle'>#{a}</span>"
end
ret
end
|
#move_norm_ref_to_sections(docxml) ⇒ Object
129
130
131
|
# File 'lib/isodoc/iso/presentation_section.rb', line 129
def move_norm_ref_to_sections(docxml)
amd?(docxml) or super
end
|
#note1(elem) ⇒ Object
101
102
103
104
105
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 101
def note1(elem)
elem["type"] == "units" and return
elem["type"] == "requirement" and return requirement_note1(elem)
super
end
|
#ol_depth(node) ⇒ Object
96
97
98
99
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 96
def ol_depth(node)
depth = node.ancestors(@iso_class ? "ol" : "ul, ol").size + 1
@counter.ol_type(node, depth)
end
|
#ol_label_template(_elem) ⇒ Object
195
196
197
198
199
200
201
202
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 195
def ol_label_template(_elem)
ret = super
@docscheme == "1951" and
ret[:alphabet] = <<~SPAN.strip
<span class="fmt-label-delim">(</span>%<span class="fmt-label-delim">)</span>
SPAN
ret
end
|
#prefix_clause(target, loc) ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 42
def prefix_clause(target, loc)
loc["type"] == "clause" or return loc["type"]
if subclause?(target, loc["type"],
loc&.at(ns("./referenceFrom"))&.text)
""
else "clause"
end
end
|
#prefix_container(container, linkend, node, target) ⇒ Object
7 a) : Clause 7 a), but Clause 7 List 1 a)
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 111
def prefix_container(container, linkend, node, target)
prefix_container?(container, node) or return linkend
container_container = @xrefs.anchor(container, :container, false)
nested_xref, container_label =
prefix_container_template(container, node, target)
container_label = prefix_container(container_container,
container_label, node, target)
l10n(connectives_spans(nested_xref
.sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
.sub("%2", linkend)))
end
|
#prefix_container_template(container, node, target) ⇒ Object
123
124
125
126
127
128
129
130
131
132
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 123
def prefix_container_template(container, node, target)
nested_xref = @i18n.nested_xref
container_label = anchor_xref(node, container)
if @xrefs.anchor(target, :type) == "listitem" &&
!@xrefs.anchor(target, :refer_list)
nested_xref = "%1 %2"
end
[nested_xref, container_label]
end
|
81
82
83
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 81
def related1(node)
node.remove
end
|
#render_identifier(ident) ⇒ Object
173
174
175
176
177
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 173
def render_identifier(ident)
ret = super
ret[:sdo] = std_docid_semantic(ret[:sdo])
ret
end
|
#requirement_note1(elem) ⇒ Object
107
108
109
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 107
def requirement_note1(elem)
elem["unnumbered"] = "true"
end
|
#subclause?(target, type, from) ⇒ Boolean
52
53
54
55
56
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 52
def subclause?(target, type, from)
(from&.match?(/\./) && type == "clause") ||
type == "list" ||
target&.gsub(/<[^<>]+>/, "")&.match(/^IEV$|^IEC 60050-/)
end
|
50
51
52
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 50
def subfigure_delim
"<span class='fmt-label-delim'>)</span>"
end
|
#table1(elem) ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 126
def table1(elem)
table1_key(elem)
if elem["class"] == "modspec"
if n = elem.at(ns(".//fmt-name"))
n.remove.name = "name"
elem.add_first_child(n)
end
elem.at(ns("./thead"))&.remove
super
elem.at(ns("./name"))&.remove
table1_fmt_xref_modspec(elem)
else super
end
end
|
#table1_fmt_xref_modspec(elem) ⇒ Object
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 141
def table1_fmt_xref_modspec(elem)
p = elem.parent.parent.at(ns("./fmt-xref-label"))
t = elem.at(ns("./fmt-xref-label"))&.remove or return
n = t.at(ns("./span[@class='fmt-element-name'][2]")) or return
while i = n.next
i.remove
end
n.remove
p.children.first.previous = to_xml(t.children)
end
|
#table1_key(elem) ⇒ Object
152
153
154
155
156
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 152
def table1_key(elem)
elem.xpath(ns(".//dl[@key = 'true'][not(./name)]")).each do |dl|
dl.add_first_child "<name>#{@i18n.key}</name>"
end
end
|
#termexamples_before_termnotes(node) ⇒ Object
68
69
70
71
72
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 68
def termexamples_before_termnotes(node)
insert = node.at(ns("./definition")) or return
insert = insertall_after_here(node, insert, "termexample")
insertall_after_here(node, insert, "termnote")
end
|
#terms(docxml) ⇒ Object
74
75
76
77
78
79
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 74
def terms(docxml)
docxml.xpath(ns("//term[termnote][termexample]")).each do |node|
termexamples_before_termnotes(node)
end
super
end
|
#termsource_status(status) ⇒ Object
85
86
87
88
89
90
|
# File 'lib/isodoc/iso/presentation_terms.rb', line 85
def termsource_status(status)
case status
when "modified", "adapted"
@i18n.modified
end
end
|
#toc_title(docxml) ⇒ Object
83
84
85
86
|
# File 'lib/isodoc/iso/presentation_section.rb', line 83
def toc_title(docxml)
%w(amendment technical-corrigendum).include?(@doctype) and return
super
end
|
163
164
165
166
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 163
def
{ group: " ", fraction_group: " ",
fraction_group_digits: 3, decimal: "," }
end
|
#ul_label_list(_elem) ⇒ Object
187
188
189
190
191
192
193
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 187
def ul_label_list(_elem)
if @docscheme == "1951"
%w(–)
else
%w(—)
end
end
|
9
10
11
12
13
14
|
# File 'lib/isodoc/iso/presentation_section.rb', line 9
def warning_for_missing_metadata(docxml)
@meta.get[:unpublished] or return
ret = warning_for_missing_metadata_create(docxml)
ret.empty? and return
warning_for_missing_metadata_post(docxml, ret)
end
|
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/isodoc/iso/presentation_section.rb', line 16
def warning_for_missing_metadata_create(docxml)
ret = ""
docxml.at(ns("//bibdata/ext//secretariat")) or
ret += "<p>Secretariat is missing.</p>"
docxml.at(ns("//bibdata/ext//editorialgroup")) or
ret += "<p>Editorial groups are missing.</p>"
docxml.at(ns("//bibdata/date[@type = 'published' or @type = 'issued' " \
"or @type = 'created']")) ||
docxml.at(ns("//bibdata/version/revision-date")) or
ret += "<p>Document date is missing.</p>"
ret
end
|
#warning_for_missing_metadata_post(docxml, ret) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/isodoc/iso/presentation_section.rb', line 29
def warning_for_missing_metadata_post(docxml, ret)
from = docxml.at(ns("//sections/*/@id"))&.text or return
id = UUIDTools::UUID.random_create
ret = <<~REVIEW
<review date='#{Date.today}' reviewer='Metanorma' id='_#{id}' from='#{from}' to='#{from}'>
<p><strong>Metadata warnings:</strong></p> #{ret}
</review>
REVIEW
unless ins = docxml.at(ns("//review-container"))
docxml.root << "<review-container></review-container>"
ins = docxml.at(ns("//review-container"))
end
ins.add_first_child ret
end
|
#wrap_in_bold(cell) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/isodoc/iso/presentation_xml_convert.rb', line 84
def wrap_in_bold(cell)
cell.text? && cell.text.strip.empty? and return
cell.text? and cell.swap("<strong>#{cell.to_xml}</strong>")
%w(strong fn).include?(cell.name) and return
cell.children.each { |p| wrap_in_bold(p) }
end
|
#xref_init(lang, script, klass, labels, options) ⇒ Object
4
5
6
|
# File 'lib/isodoc/iso/presentation_xref.rb', line 4
def xref_init(lang, script, klass, labels, options)
@xrefs = Xref.new(lang, script, klass, labels, options)
end
|