Class: IsoDoc::Bipm::PresentationXMLConvert
- Inherits:
-
Generic::PresentationXMLConvert
- Object
- Generic::PresentationXMLConvert
- IsoDoc::Bipm::PresentationXMLConvert
show all
- Includes:
- Init
- Defined in:
- lib/isodoc/bipm/doccontrol.rb,
lib/isodoc/bipm/presentation_biblio.rb,
lib/isodoc/bipm/presentation_blocks.rb,
lib/isodoc/bipm/presentation_footnotes.rb,
lib/isodoc/bipm/presentation_xml_convert.rb
Constant Summary
collapse
- COCHAIR =
"xmlns:role[contains(text(),'co-chair')]".freeze
- CHAIR =
"[xmlns:role[contains(text(),'chair')]" \
"[not(contains(text(),'co-chair'))]]".freeze
Instance Method Summary
collapse
-
#annex_delim(elem) ⇒ Object
-
#bibdata_dates(bibdata) ⇒ Object
-
#bibdata_i18n(bibdata) ⇒ Object
-
#bibdata_titles(bibdata) ⇒ Object
-
#biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib) ⇒ Object
-
#clause(docxml) ⇒ Object
-
#clause1(elem) ⇒ Object
-
#conversions(docxml) ⇒ Object
-
#convert1(docxml, filename, dir) ⇒ Object
-
#doccontrol(doc) ⇒ Object
-
#doccontrol_row1(doc) ⇒ Object
-
#doccontrol_row2(docxml) ⇒ Object
-
#document_footnotes(docxml) ⇒ Object
-
#enable_indexsect ⇒ Object
-
#eref(docxml) ⇒ Object
-
#eref_localities1(opt) ⇒ Object
-
#explode_subclauses(clause) ⇒ Object
-
#extract_brackets(node) ⇒ Object
-
#figure1(elem) ⇒ Object
-
#filter_document_footnotes(sects, excl) ⇒ Object
-
#fn_body_label(fnote) ⇒ Object
-
#fn_label_brackets(fnote) ⇒ Object
-
#fn_ref_label(fnote) ⇒ Object
-
#implicit_reference(bib) ⇒ Object
-
#index1(docxml, indexsect, index) ⇒ Object
-
#iso_fn_ref_label(fnote) ⇒ Object
-
#iso_processor(docxml) ⇒ Object
-
#jcgm_eref(docxml, xpath) ⇒ Object
-
#list_authors(xml) ⇒ Object
-
#list_chairs(xml) ⇒ Object
-
#list_cochairs(xml) ⇒ Object
-
#list_draft(xml, idx) ⇒ Object
-
#list_drafts(xml) ⇒ Object
-
#list_people(xml, xpath) ⇒ Object
-
#localize_maths(node, locale) ⇒ Object
-
#mathml1(node, locale) ⇒ Object
-
#middle_title(docxml) ⇒ Object
-
#non_document_footnotes(docxml) ⇒ Object
-
#norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn, _bib) ⇒ Object
-
#note1(elem) ⇒ Object
notes and remarques (list notes) are not numbered.
-
#note_delim(_elem) ⇒ Object
-
#note_label(elem) ⇒ Object
-
#ol_label_template(_elem) ⇒ Object
-
#omit_docid_prefix(prefix) ⇒ Object
-
#origin(docxml) ⇒ Object
-
#prefix_name(node, delims, number, elem) ⇒ Object
-
#quotedtitles(docxml) ⇒ Object
-
#reference_name(ref) ⇒ Object
-
#render_identifier(ident) ⇒ Object
-
#renumber_document_footnote(fnote, idx, seen) ⇒ Object
-
#renumber_document_footnote_key(fnote) ⇒ Object
quote/table/fn references are not unique within quote if there are multiple tables.
-
#renumber_document_footnotes(fns, idx) ⇒ Object
-
#sort_footnote_sections(docxml) ⇒ Object
explode out all the subclauses into separate entries assume no hanging clauses.
-
#table_delim ⇒ Object
-
#table_fn(elem) ⇒ Object
-
#termsource(docxml) ⇒ Object
-
#termsource_adapt(status) ⇒ Object
-
#termsource_insert_empty_modification(docxml) ⇒ Object
-
#termsource_label(elem, sources) ⇒ Object
-
#termsource_modification(elem) ⇒ Object
-
#twitter_cldr_localiser_symbols ⇒ Object
-
#ul_label_list(_elem) ⇒ Object
-
#wrap_brackets(txt) ⇒ Object
Methods included from Init
#amd?, #bibrenderer, #i18n_init, #metadata_init, #xref_init
Instance Method Details
#annex_delim(elem) ⇒ Object
36
37
38
39
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 36
def annex_delim(elem)
@jcgm and return super
".<tab/>"
end
|
#bibdata_dates(bibdata) ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 10
def bibdata_dates(bibdata)
pubdate = bibdata.at(ns("./date[not(@format)][@type = 'published']"))
pubdate or return
meta = metadata_init(@lang, @script, @locale, @i18n)
pubdate.next = pubdate.dup
pubdate.next["format"] = "ddMMMyyyy"
pubdate.next.children = meta.monthyr(pubdate.text)
end
|
#bibdata_i18n(bibdata) ⇒ Object
4
5
6
7
8
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 4
def bibdata_i18n(bibdata)
super
bibdata_dates(bibdata)
bibdata_titles(bibdata)
end
|
#bibdata_titles(bibdata) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 19
def bibdata_titles(bibdata)
app = bibdata.at(ns("//bibdata/ext/" \
"structuredidentifier/part")) or return
bibdata.xpath(ns("//bibdata/title[@type = 'title-part']")).each do |t|
t.previous = t.dup
t["type"] = "title-part-with-numbering"
part = t["language"] == "en" ? "Part" : "Partie" t.children = l10n("#{part} #{app.text}: #{to_xml(t.children)}",
t["language"])
end
end
|
#biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 38
def biblio_ref_entry_code(ordinal, ids, _id, _standard, datefn, _bib)
ret = ids[:ordinal] || ids[:metanorma] || "[#{ordinal}]"
if ids[:sdo]
ret = prefix_bracketed_ref(ret)
ret += "#{ids[:sdo]}#{datefn} "
else
ret = prefix_bracketed_ref("#{ret}#{datefn}")
end
ret
end
|
#clause(docxml) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 41
def clause(docxml)
quotedtitles(docxml)
super
@jcgm and
docxml.xpath(ns("//preface/introduction[clause]")).each do |f|
clause1(f)
end
end
|
#clause1(elem) ⇒ Object
50
51
52
53
54
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 50
def clause1(elem)
elem.at("./ancestor::*[@unnumbered = 'true']") and
elem["unnumbered"] = "true"
super
end
|
#conversions(docxml) ⇒ Object
67
68
69
70
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 67
def conversions(docxml)
doccontrol docxml
super
end
|
#convert1(docxml, filename, dir) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 14
def convert1(docxml, filename, dir)
@jcgm = docxml&.at(ns("//bibdata/ext/editorialgroup/committee/" \
"@acronym"))&.value == "JCGM"
@xrefs.klass.jcgm = @jcgm
@jcgm and @iso = iso_processor(docxml)
super
end
|
#doccontrol(doc) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 4
def doccontrol(doc)
return unless doc.at(ns("//bibdata/relation[@type = 'supersedes']"))
clause = <<~DOCCONTROL
<doccontrol displayorder="999">
<fmt-title>Document Control</fmt-title>
<table unnumbered="true"><tbody>
<tr><th>Authors:</th><td/><td>#{list_authors(doc)}</td></tr>
#{doccontrol_row1(doc)} #{doccontrol_row2(doc)} #{list_drafts(doc)}
</tbody></table></doccontrol>
DOCCONTROL
doc.root << clause
end
|
#doccontrol_row1(doc) ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 18
def doccontrol_row1(doc)
return "" if list_draft(doc,
1) == ["", ""] && list_cochairs(doc).empty?
<<~ROW
<tr>#{list_draft(doc, 1)&.map { |x| "<td>#{x}</td>" }&.join}
<td>#{list_cochairs(doc)}</td></tr>
ROW
end
|
#doccontrol_row2(docxml) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 28
def doccontrol_row2(docxml)
list_draft(docxml, 2) == ["", ""] && list_chairs(docxml).empty? and
return ""
<<~ROW
<tr>#{list_draft(docxml, 2)&.map { |x| "<td>#{x}</td>" }&.join}
<td>#{list_chairs(docxml)}</td></tr>
ROW
end
|
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 71
def (docxml)
@jcgm and return super
sects = (docxml)
excl = (docxml)
fns = (sects, excl)
sects.each_with_index do |s, i|
ret = ((fns[i], 1))
f = (fns[i], ret) and s << f
end
end
|
#enable_indexsect ⇒ Object
143
144
145
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 143
def enable_indexsect
true
end
|
#eref(docxml) ⇒ Object
101
102
103
104
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 101
def eref(docxml)
super
jcgm_eref(docxml, "//fmt-eref")
end
|
#eref_localities1(opt) ⇒ Object
31
32
33
34
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 31
def eref_localities1(opt)
@jcgm and return @iso.eref_localities1(opt)
super
end
|
#explode_subclauses(clause) ⇒ Object
42
43
44
45
46
47
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 42
def explode_subclauses(clause)
clause.at(ns(".//clause")) or return [clause]
(clause.xpath(ns(".//clause")) - clause.xpath(ns(".//clause//clause")))
.map { |x| explode_subclauses(x) }
.flatten.unshift(clause)
end
|
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 125
def (node)
start = node.at("./text()[1]")
finish = node.at("./text()[last()]")
(/^\[/.match?(start&.text) && /\]$/.match?(finish&.text)) or return
start.replace(start.text[1..-1])
node.previous = "["
finish = node.at("./text()[last()]")
finish.replace(finish.text[0..-2])
node.next = "]"
end
|
13
14
15
16
17
18
19
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 13
def figure1(elem)
if @jcgm
@iso.xrefs = @xrefs
@iso.figure1(elem)
else super
end
end
|
82
83
84
85
86
87
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 82
def (sects, excl)
sects.each_with_object([]) do |s, m|
docfns = s.xpath(ns(".//fn")) - excl - s.xpath(ns(".//clause//fn"))
m << docfns
end
end
|
#fn_body_label(fnote) ⇒ Object
27
28
29
30
31
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 27
def fn_body_label(fnote)
if @jcgm then super
else fn_label_brackets(fnote)
end
end
|
#fn_label_brackets(fnote) ⇒ Object
4
5
6
7
8
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 4
def fn_label_brackets(fnote)
"<sup><span class='fmt-label-delim'>(</span>" \
"#{fn_label(fnote)}" \
"<span class='fmt-label-delim'>)</span></sup>"
end
|
#fn_ref_label(fnote) ⇒ Object
10
11
12
13
14
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 10
def fn_ref_label(fnote)
if @jcgm then iso_fn_ref_label(fnote)
else fn_label_brackets(fnote)
end
end
|
#implicit_reference(bib) ⇒ Object
50
51
52
53
54
55
56
57
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 50
def implicit_reference(bib)
b = bib.at(ns("./docidentifier[@primary = 'true'][@type = 'BIPM']"))
return true if @doctype == "brochure" && /^(CGPM|CIPM|CCDS|CCTF)[ ]
(Resolution|Recommendation|Declaration|Decision|Recommendation|Meeting)/x
.match?(b&.text)
super
end
|
#index1(docxml, indexsect, index) ⇒ Object
147
148
149
150
151
152
153
154
155
156
157
158
159
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 147
def index1(docxml, indexsect, index)
index.keys.sort.each do |k|
c = indexsect.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
words = index[k].keys.each_with_object({}) do |w, v|
v[sortable(w).downcase] = w
end
words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
end
end
docxml.xpath(ns("//indexsect//xref")).each { |x| x.children.remove }
@xrefs.bookmark_anchor_names(docxml)
end
|
#iso_fn_ref_label(fnote) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 17
def iso_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
"<sup>#{fn_label(fnote)}</sup>"
end
end
|
#iso_processor(docxml) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 22
def iso_processor(docxml)
iso = IsoDoc::Iso::PresentationXMLConvert
.new({ language: @lang, script: @script })
i18n = iso.i18n_init(@lang, @script, @locale, nil)
iso.metadata_init(@lang, @script, @locale, i18n)
iso.info(docxml, nil)
iso
end
|
#jcgm_eref(docxml, xpath) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 111
def jcgm_eref(docxml, xpath)
@jcgm or return
docxml.xpath(ns(xpath)).each { |x| (x) }
docxml.root.replace(Nokogiri::XML(docxml.root.to_xml).root)
docxml.xpath(ns(xpath)).each do |x| if x.parent.next&.text? && /^\],\s+\[$/.match?(x.parent.next.text) &&
%w(eref origin fmt-eref
fmt-origin).include?(x.parent.next.next&.name)
x.parent.next.replace(", ")
end
end
end
|
#list_authors(xml) ⇒ Object
60
61
62
63
64
65
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 60
def list_authors(xml)
ret = list_people(
xml, "//bibdata/contributor[xmlns:role/@type = 'author']/person"
)
connectives_spans(@i18n.boolean_conj(ret, "and"))
end
|
#list_chairs(xml) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 79
def list_chairs(xml)
ret = list_people(xml, "//bibdata/contributor#{CHAIR}/person")
ret.empty? and return ""
role = xml&.at(ns("//bibdata/contributor#{CHAIR}/role"))&.text
label = ret.size > 1 && role ? "#{role}s" : role
"#{label}: #{connectives_spans(@i18n.boolean_conj(ret, 'and'))}"
end
|
#list_cochairs(xml) ⇒ Object
71
72
73
74
75
76
77
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 71
def list_cochairs(xml)
ret = list_people(xml, "//bibdata/contributor[#{COCHAIR}]/person")
ret.empty? and return ""
role = xml&.at(ns("//bibdata/contributor[#{COCHAIR}]/role"))&.text
label = ret.size > 1 && role ? "#{role}s" : role
"#{label}: #{connectives_spans(@i18n.boolean_conj(ret, 'and'))}"
end
|
#list_draft(xml, idx) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 51
def list_draft(xml, idx)
d = xml.at(ns("//bibdata/relation[@type = 'supersedes'][#{idx}]" \
"/bibitem")) or return ["", ""]
draft = d&.at(ns("./version/draft"))&.text and draft = "Draft #{draft}"
edn = d&.at(ns("./edition"))&.text and edn = "Version #{edn}"
[[draft, edn].join(" "), d&.at(ns("./date"))&.text]
end
|
#list_drafts(xml) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 38
def list_drafts(xml)
ret = ""
i = 3
while list_draft(xml, i) != ["", ""]
ret += "<tr>#{list_draft(xml, i).map do |x|
"<td>#{x}</td>"
end.join} " \
"<td/></tr>"
i += 1
end
ret
end
|
#list_people(xml, xpath) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/isodoc/bipm/doccontrol.rb', line 87
def list_people(xml, xpath)
ret = []
xml.xpath(ns(xpath)).each do |p|
name = p.at(ns("./name/completename"))&.text
aff = p.at(ns("./affiliation/organization/abbreviation"))&.text ||
p.at(ns("./affiliation/organization/name"))&.text
c = name || ""
aff and c += " (#{aff})"
ret << c
end
ret
end
|
#localize_maths(node, locale) ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 77
def localize_maths(node, locale)
super
node.xpath(".//m:mn", MATHML).each do |x|
x.children = x.text
.sub(/^(\d)#{@cldr[:g]}(\d) (?= \d\d$ | \d\d#{@cldr[:d]} )/x,
"\\1\\2")
.sub(/(?<= ^\d\d | #{@cldr[:d]}\d\d ) (\d)#{@cldr[:f]}(\d) $/x,
"\\1\\2")
end
end
|
#mathml1(node, locale) ⇒ Object
88
89
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 88
def mathml1(node, locale)
unless @cldr
r = @numfmt.(locale: locale)
.transform_values { |v| @c.decode(v) }
@cldr = {
g: Regexp.quote(r[:group]),
f: Regexp.quote(r[:fraction_group]),
d: Regexp.quote(r[:decimal]),
}
end
super
end
|
#middle_title(docxml) ⇒ Object
4
5
6
7
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 4
def middle_title(docxml)
@jcgm or return nil
@iso.middle_title(docxml)
end
|
102
103
104
105
106
107
108
109
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 102
def (docxml)
table_fns = docxml.xpath(ns("//table//fn")) -
docxml.xpath(ns("//table/name//fn"))
@jcgm or table_fns -= docxml.xpath(ns("//quote//table//fn"))
fig_fns = docxml.xpath(ns("//figure//fn")) -
docxml.xpath(ns("//figure/name//fn"))
table_fns + fig_fns
end
|
#norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn, _bib) ⇒ Object
31
32
33
34
35
36
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 31
def norm_ref_entry_code(_ordinal, identifiers, _ids, _standard, datefn,
_bib)
ret = identifiers[0] || identifiers[1]
ret += " #{identifiers[1]}" if identifiers[0] && identifiers[1]
"#{ret}#{datefn} "
end
|
#note1(elem) ⇒ Object
notes and remarques (list notes) are not numbered
26
27
28
29
30
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 26
def note1(elem)
elem.parent.name == "bibitem" || elem["notag"] == "true" and return
lbl = l10n(note_label(elem))
prefix_name(elem, { label: note_delim(elem) }, lbl, "name")
end
|
#note_delim(_elem) ⇒ Object
21
22
23
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 21
def note_delim(_elem)
l10n("x:<tab/>").sub("x", "") end
|
#note_label(elem) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 32
def note_label(elem)
if elem.ancestors("preface").empty?
if elem.ancestors("ul, ol, dl").empty?
@i18n.note
else @i18n.listnote end
else @i18n.prefacenote
end
end
|
#ol_label_template(_elem) ⇒ Object
73
74
75
76
77
78
79
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 73
def ol_label_template(_elem)
super.merge({
roman: %{<span class="fmt-label-delim">(</span>% \
<span class="fmt-label-delim">)</span>},
arabic: %{%<span class="fmt-label-delim">.</span>},
})
end
|
#omit_docid_prefix(prefix) ⇒ Object
59
60
61
62
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 59
def omit_docid_prefix(prefix)
%w(BIPM BIPM-long).include? prefix and return true
super
end
|
#origin(docxml) ⇒ Object
106
107
108
109
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 106
def origin(docxml)
super
jcgm_eref(docxml, "//fmt-origin[not(.//termref)]")
end
|
#prefix_name(node, delims, number, elem) ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 56
def prefix_name(node, delims, number, elem)
if n = node.at(ns("./#{elem}[@type = 'quoted']"))
n1 = n.dup
n1.name = "fmt-#{elem}"
n.next = n1
prefix_name_postprocess(node, elem)
else
super
end
end
|
#quotedtitles(docxml) ⇒ Object
136
137
138
139
140
141
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 136
def quotedtitles(docxml)
docxml.xpath(ns("//variant-title[@type = 'quoted']")).each do |t|
t.name = "title"
t.children.first.previous = "<blacksquare/>"
end
end
|
#reference_name(ref) ⇒ Object
75
76
77
78
79
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 75
def reference_name(ref)
super
@jcgm and @xrefs.get[ref["id"]][:xref] =
wrap_brackets(@xrefs.get[ref["id"]][:xref])
end
|
#render_identifier(ident) ⇒ Object
64
65
66
67
68
69
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 64
def render_identifier(ident)
ret = super
ret[:sdo] = ret[:sdo]&.sub(/^(BIPM)([ ])(PV|CR)([ ])(\d.*)$/,
"\\1\\2<strong>\\3</strong>,\\4\\5")
ret
end
|
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 58
def (fnote, idx, seen)
fnote["original-reference"] = fnote["reference"]
key = (fnote)
if seen[key]
fnote["reference"] = seen[fnote["reference"]]
else
seen[key] = idx
fnote["reference"] = idx
idx += 1
end
idx
end
|
quote/table/fn references are not unique within quote if there are multiple tables
51
52
53
54
55
56
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 51
def (fnote)
key = fnote["reference"]
!@jcgm && (t = fnote.at("./ancestor::xmlns:table")) and
key = "#{t['id']} #{key}"
key
end
|
89
90
91
92
93
94
95
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 89
def (fns, idx)
@jcgm and return super
fns.each_with_object({}) do |f, seen|
idx = (f, idx, seen)
end
fns
end
|
explode out all the subclauses into separate entries assume no hanging clauses
35
36
37
38
39
40
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 35
def (docxml)
ret = super
ret.flat_map do |x|
explode_subclauses(x)
end
end
|
#table_delim ⇒ Object
9
10
11
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 9
def table_delim
l10n("x.<tab/>").sub("x", "") end
|
#table_fn(elem) ⇒ Object
97
98
99
100
|
# File 'lib/isodoc/bipm/presentation_footnotes.rb', line 97
def table_fn(elem)
!@jcgm && !elem.ancestors("quote").empty? and return
super
end
|
#termsource(docxml) ⇒ Object
53
54
55
56
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 53
def termsource(docxml)
termsource_insert_empty_modification(docxml)
super
end
|
#termsource_adapt(status) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 45
def termsource_adapt(status)
case status
when "adapted" then @i18n.adapted_from
when "modified" then @i18n.modified_from
else ""
end
end
|
#termsource_insert_empty_modification(docxml) ⇒ Object
58
59
60
61
62
63
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 58
def termsource_insert_empty_modification(docxml)
docxml.xpath("//xmlns:term//xmlns:source[@status = 'modified']" \
"[not(xmlns:modification)]").each do |f|
f << "<modification/>"
end
end
|
#termsource_label(elem, sources) ⇒ Object
41
42
43
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 41
def termsource_label(elem, sources)
elem.replace(l10n("[#{termsource_adapt(elem['status'])} #{sources}]"))
end
|
#termsource_modification(elem) ⇒ Object
65
66
67
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 65
def termsource_modification(elem)
termsource_add_modification_text(elem.at(ns("./modification")))
end
|
72
73
74
75
|
# File 'lib/isodoc/bipm/presentation_xml_convert.rb', line 72
def
{ group: " ", fraction_group: " ",
fraction_group_digits: 3 }
end
|
#ul_label_list(_elem) ⇒ Object
69
70
71
|
# File 'lib/isodoc/bipm/presentation_blocks.rb', line 69
def ul_label_list(_elem)
%w(• − o)
end
|
#wrap_brackets(txt) ⇒ Object
71
72
73
|
# File 'lib/isodoc/bipm/presentation_biblio.rb', line 71
def wrap_brackets(txt)
/^\[.*\]$/.match?(txt) ? txt : "[#{txt}]"
end
|