metanorma-ieee 1.5.3 → 1.5.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/lib/isodoc/ieee/html/header.html +3 -3
- data/lib/isodoc/ieee/html/html_ieee_titlepage.html +15 -2
- data/lib/isodoc/ieee/html/ieee.css +46 -1
- data/lib/isodoc/ieee/html/ieee.scss +42 -1
- data/lib/isodoc/ieee/html/word_ieee_titlepage.html +10 -2
- data/lib/isodoc/ieee/html/wordstyle.css +48 -0
- data/lib/isodoc/ieee/html/wordstyle.scss +44 -0
- data/lib/isodoc/ieee/html/wordstyle_wp.css +47 -0
- data/lib/isodoc/ieee/html/wordstyle_wp.scss +43 -0
- data/lib/isodoc/ieee/i18n-en.yaml +2 -0
- data/lib/isodoc/ieee/ieee.amendment.xsl +1131 -438
- data/lib/isodoc/ieee/ieee.standard.xsl +1131 -438
- data/lib/isodoc/ieee/metadata.rb +22 -11
- data/lib/isodoc/ieee/presentation_bibitem.rb +102 -0
- data/lib/isodoc/ieee/presentation_ref.rb +149 -96
- data/lib/isodoc/ieee/presentation_terms.rb +52 -12
- data/lib/isodoc/ieee/presentation_xml_convert.rb +15 -67
- data/lib/isodoc/ieee/word_authority.rb +37 -59
- data/lib/isodoc/ieee/word_cleanup.rb +83 -35
- data/lib/isodoc/ieee/word_cleanup_blocks.rb +0 -1
- data/lib/isodoc/ieee/word_convert.rb +19 -16
- data/lib/isodoc/ieee/word_toc.rb +46 -0
- data/lib/metanorma/ieee/boilerplate.adoc +6 -5
- data/lib/metanorma/ieee/boilerplate_wp.adoc +1 -2
- data/lib/metanorma/ieee/cleanup.rb +56 -9
- data/lib/metanorma/ieee/cleanup_boilerplate.rb +1 -4
- data/lib/metanorma/ieee/cleanup_ref.rb +0 -98
- data/lib/metanorma/ieee/cleanup_ref_fn.rb +116 -0
- data/lib/metanorma/ieee/front.rb +26 -0
- data/lib/metanorma/ieee/isodoc.rng +19 -1
- data/lib/metanorma/ieee/processor.rb +1 -0
- data/lib/metanorma/ieee/relaton-ieee.rng +4 -0
- data/lib/metanorma/ieee/validate.rb +1 -1
- data/lib/metanorma/ieee/version.rb +1 -1
- metadata +5 -2
data/lib/isodoc/ieee/metadata.rb
CHANGED
@@ -54,6 +54,20 @@ module IsoDoc
|
|
54
54
|
wg(xml)
|
55
55
|
bg(xml)
|
56
56
|
program(xml)
|
57
|
+
coverpage_stmt(xml)
|
58
|
+
end
|
59
|
+
|
60
|
+
def agency(xml)
|
61
|
+
super
|
62
|
+
logos = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'author']/" \
|
63
|
+
"organization/logo/image/@src"))
|
64
|
+
set(:corporate_author_logos, logos.map { |l| to_datauri(l.value) })
|
65
|
+
set(:corporate_author_logo_attrs, contrib_logo_attrs(xml, "author"))
|
66
|
+
end
|
67
|
+
|
68
|
+
def coverpage_stmt(xml)
|
69
|
+
p = xml.at(ns("//presentation-metadata/coverpage-statement")) and
|
70
|
+
set(:coverpage_statement, p.children.to_xml)
|
57
71
|
end
|
58
72
|
|
59
73
|
def program(xml)
|
@@ -105,6 +119,8 @@ module IsoDoc
|
|
105
119
|
set(:stdid_pdf, dn&.text || "STDXXXXX")
|
106
120
|
dn = isoxml.at(ns("//#{id}[@scope = 'print']"))
|
107
121
|
set(:stdid_print, dn&.text || "STDPDXXXXX")
|
122
|
+
dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'IEEE-draft']")) and
|
123
|
+
set(:docid_draft, dn.text)
|
108
124
|
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/amendment")) and
|
109
125
|
set(:amd, dn.text)
|
110
126
|
dn = isoxml.at(ns("//bibdata/ext/structuredidentifier/corrigendum")) and
|
@@ -114,18 +130,13 @@ module IsoDoc
|
|
114
130
|
def title(isoxml, _out)
|
115
131
|
metadata_parse_init(isoxml)
|
116
132
|
super
|
117
|
-
draft = isoxml.at(ns("//bibdata/version/draft"))
|
118
133
|
doctype(isoxml, _out)
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
def fulltitle(type, draft)
|
126
|
-
title = "#{type || '???'} for #{@metadata[:doctitle] || '???'}"
|
127
|
-
draft and title = "Draft #{title}"
|
128
|
-
title
|
134
|
+
{ doctitle: "title-main", full_doctitle: "main",
|
135
|
+
abbrev_doctitle: "title-abbrev", provenance_doctitle: "provenance" }
|
136
|
+
.each do |k, v|
|
137
|
+
t = isoxml.at(ns("//bibdata/title[@type='#{v}']")) and
|
138
|
+
set(k, Common::to_xml(t.children))
|
139
|
+
end
|
129
140
|
end
|
130
141
|
|
131
142
|
def metadata_parse_init(isoxml)
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require_relative "../../relaton/render/general"
|
2
|
+
|
3
|
+
module IsoDoc
|
4
|
+
module Ieee
|
5
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
6
|
+
def references_render(docxml)
|
7
|
+
@author = {}
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def bibrender_relaton(xml, renderings)
|
12
|
+
bibrender_relaton1(xml, renderings)
|
13
|
+
author_date(xml, renderings)
|
14
|
+
@author[xml["id"]] = renderings[xml["id"]][:author]
|
15
|
+
end
|
16
|
+
|
17
|
+
def bibrender_relaton1(xml, renderings)
|
18
|
+
f = renderings[xml["id"]][:formattedref] or return
|
19
|
+
fn = availability_note(xml)
|
20
|
+
f = "<formattedref>#{f}#{fn}</formattedref>"
|
21
|
+
if x = xml.at(ns("./formattedref"))
|
22
|
+
x.replace(f)
|
23
|
+
elsif xml.children.empty?
|
24
|
+
xml << f
|
25
|
+
else
|
26
|
+
xml.children.first.previous = f
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def author_date(xml, renderings)
|
31
|
+
author_date?(xml) or return
|
32
|
+
cit = renderings[xml["id"]][:citation]
|
33
|
+
xml << "<docidentifier type='metanorma'>#{cit}</docidentifier>"
|
34
|
+
xml.at(ns("./biblio-tag"))&.remove
|
35
|
+
xml << "<biblio-tag>#{cit}, </biblio-tag>"
|
36
|
+
end
|
37
|
+
|
38
|
+
def author_date?(xml)
|
39
|
+
ret = !xml["type"]
|
40
|
+
ret ||= %w(standard techreport website webresource)
|
41
|
+
.include?(xml["type"])
|
42
|
+
ret ||= xml.at(".//ancestor::xmlns:references[@normative = 'false']")
|
43
|
+
ret ||= xml.at(ns("./docidentifier[@type = 'metanorma']"))
|
44
|
+
ret and return false
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def creatornames(bib)
|
49
|
+
::Relaton::Render::Ieee::General
|
50
|
+
.new(language: @lang, i18nhash: @i18n.get,
|
51
|
+
# template: { (bib["type"] || "misc").to_sym =>
|
52
|
+
# "{{ creatornames }}" },
|
53
|
+
template: "{{ creatornames }}",
|
54
|
+
extenttemplate: { (bib["type"] || "misc").to_sym => "{{page}}" },
|
55
|
+
sizetemplate: { (bib["type"] || "misc").to_sym => "{{data}}" })
|
56
|
+
.render1(RelatonBib::XMLParser.from_xml(bib.to_xml))
|
57
|
+
end
|
58
|
+
|
59
|
+
def bibliography_bibitem_number1(bibitem, idx, normative)
|
60
|
+
bibitem.xpath(ns(".//docidentifier[@type = 'metanorma' or " \
|
61
|
+
"@type = 'metanorma-ordinal']")).each do |mn|
|
62
|
+
/^\[?B?\d\]?$/.match?(mn&.text) and mn.remove
|
63
|
+
end
|
64
|
+
unless bibliography_bibitem_number_skip(bibitem) || normative
|
65
|
+
idx += 1
|
66
|
+
docidentifier_insert_pt(bibitem).next =
|
67
|
+
"<docidentifier type='metanorma-ordinal'>[B#{idx}]</docidentifier>"
|
68
|
+
end
|
69
|
+
idx
|
70
|
+
end
|
71
|
+
|
72
|
+
def docidentifier_insert_pt(bibitem)
|
73
|
+
bibitem.at(ns(".//docidentifier"))&.previous ||
|
74
|
+
bibitem.at(ns(".//title")) ||
|
75
|
+
bibitem.at(ns(".//formattedref"))
|
76
|
+
end
|
77
|
+
|
78
|
+
def availability_note(bib)
|
79
|
+
notes = bib.xpath(ns("./note[@type = 'Availability']"))
|
80
|
+
notes.map do |note|
|
81
|
+
id = UUIDTools::UUID.random_create.to_s
|
82
|
+
@new_ids[id] = nil
|
83
|
+
"<fn id='#{id}' reference='#{id}'><p>#{note.content}</p></fn>"
|
84
|
+
end.join
|
85
|
+
end
|
86
|
+
|
87
|
+
def omit_docid_prefix(prefix)
|
88
|
+
prefix == "DOI" and return true
|
89
|
+
super
|
90
|
+
end
|
91
|
+
|
92
|
+
def bracket_if_num(num)
|
93
|
+
num.nil? and return nil
|
94
|
+
ret = num.dup
|
95
|
+
ret.xpath(ns(".//fn")).each(&:remove)
|
96
|
+
ret = ret.text.strip.sub(/^\[/, "").sub(/\]$/, "")
|
97
|
+
/^B?\d+$/.match?(ret) and return "[#{ret}]"
|
98
|
+
ret
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -1,142 +1,195 @@
|
|
1
|
-
require_relative "../../relaton/render/general"
|
2
|
-
|
3
1
|
module IsoDoc
|
4
2
|
module Ieee
|
5
3
|
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
4
|
+
def xref_empty?(node)
|
5
|
+
if node["citeas"] &&
|
6
|
+
@bibanchors[node["bibitemid"]] && !node.children.empty?
|
7
|
+
true
|
8
|
+
else super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def inline(docxml)
|
13
|
+
@bibanchors ||= biblio_ids_titles(docxml, false)
|
14
|
+
@normrefanchors ||= biblio_ids_titles(docxml, true)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
6
18
|
# Style manual 19
|
7
19
|
def anchor_linkend(node, linkend)
|
8
|
-
@bibanchors ||= biblio_ids_titles(node.document)
|
9
20
|
if node["citeas"] && i = @bibanchors[node["bibitemid"]]
|
10
21
|
biblio_anchor_linkend(node, i)
|
22
|
+
elsif node["citeas"] && (i = @normrefanchors[node["bibitemid"]])
|
23
|
+
cit = normref_anchor_linkend(node, i)
|
24
|
+
cit || super
|
11
25
|
else super
|
12
26
|
end
|
13
27
|
end
|
14
28
|
|
29
|
+
# force Author-Date referencing on non-standards in norm ref
|
30
|
+
def normref_anchor_linkend(node, bib)
|
31
|
+
@ref_renderings or return nil
|
32
|
+
%w(techreport standard).include?(bib[:type]) and return nil
|
33
|
+
cit = @ref_renderings[node["bibitemid"]][:citation]&.strip
|
34
|
+
cit.empty? and cit = nil
|
35
|
+
cit
|
36
|
+
end
|
37
|
+
|
15
38
|
def biblio_anchor_linkend(node, bib)
|
16
39
|
if %w(techreport standard).include?(bib[:type])
|
17
|
-
|
18
|
-
|
19
|
-
"
|
20
|
-
|
21
|
-
|
40
|
+
if !node.children.empty?
|
41
|
+
to_xml(node.children).strip
|
42
|
+
elsif node["citeas"] == bib[:ord] then node["citeas"]
|
43
|
+
else [node["citeas"], bib[:ord]].compact.join(" ")
|
44
|
+
end
|
45
|
+
else biblio_anchor_linkend_nonstd(node, bib)
|
22
46
|
end
|
23
47
|
end
|
24
48
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
ord: b.at(ns("./docidentifier[@type = 'metanorma' or " \
|
35
|
-
"@type = 'metanorma-ordinal']"))&.text }
|
49
|
+
def biblio_anchor_linkend_nonstd(node, bib)
|
50
|
+
node["style"] == "no-biblio-tag" or tag = node["citeas"]
|
51
|
+
if !node.children.empty?
|
52
|
+
"#{to_xml(node.children)} #{tag}".strip
|
53
|
+
elsif node["style"] == "title" && bib[:title]
|
54
|
+
"#{bib[:title]} #{tag}".strip
|
55
|
+
elsif bib[:author] # default, also if node["style"] == "title"
|
56
|
+
"#{bib[:author]} #{tag}".strip
|
57
|
+
else tag.strip
|
36
58
|
end
|
37
59
|
end
|
38
60
|
|
39
|
-
def
|
40
|
-
"
|
61
|
+
def biblio_ids_titles(xmldoc, normative)
|
62
|
+
xmldoc.xpath(ns("//references[@normative = '#{normative}']/bibitem"))
|
63
|
+
.each_with_object({}) do |b, acc|
|
64
|
+
biblio_ids_titles1(b, acc)
|
65
|
+
end
|
41
66
|
end
|
42
67
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
68
|
+
def biblio_ids_titles1(bib, acc)
|
69
|
+
acc[bib["id"]] =
|
70
|
+
{ docid: pref_ref_code(bib), type: bib["type"],
|
71
|
+
title: bib.at(ns("./title")) || bib.at(ns("./formattedref")),
|
72
|
+
author: @author[bib["id"]] || (bib.at(ns("./title")) ||
|
73
|
+
bib.at(ns("./formattedref"))),
|
74
|
+
ord: bib.at(ns("./docidentifier[@type = 'metanorma' or " \
|
75
|
+
"@type = 'metanorma-ordinal']")) }
|
76
|
+
%i(title author ord).each do |k|
|
77
|
+
acc[bib["id"]][k].is_a?(Nokogiri::XML::Node) and
|
78
|
+
acc[bib["id"]][k] = acc[bib["id"]][k].text
|
79
|
+
end
|
46
80
|
end
|
47
81
|
|
48
|
-
def
|
49
|
-
|
50
|
-
author_date(xml, renderings)
|
51
|
-
@author[xml["id"]] = renderings[xml["id"]][:author]
|
82
|
+
def citestyle
|
83
|
+
"author-date"
|
52
84
|
end
|
53
85
|
|
54
|
-
def
|
55
|
-
|
56
|
-
fn = availability_note(xml)
|
57
|
-
f = "<formattedref>#{f}#{fn}</formattedref>"
|
58
|
-
if x = xml.at(ns("./formattedref"))
|
59
|
-
x.replace(f)
|
60
|
-
elsif xml.children.empty?
|
61
|
-
xml << f
|
62
|
-
else
|
63
|
-
xml.children.first.previous = f
|
64
|
-
end
|
86
|
+
def expand_citeas(text)
|
87
|
+
std_docid_semantic(super)
|
65
88
|
end
|
66
89
|
|
67
|
-
def
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
90
|
+
def eref_localities_conflated(refs, target, node)
|
91
|
+
droploc = node["droploc"]
|
92
|
+
node["droploc"] = true
|
93
|
+
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
94
|
+
node))
|
95
|
+
node["droploc"] = droploc
|
96
|
+
p = prefix_clause(target, refs.first.at(ns("./locality")))
|
97
|
+
eref_localities1({ target: target, number: "pl",
|
98
|
+
type: p,
|
99
|
+
from: l10n(ret[1..-1].join), node: node,
|
100
|
+
lang: @lang })
|
101
|
+
end
|
102
|
+
|
103
|
+
def prefix_clause(target, loc)
|
104
|
+
loc["type"] == "clause" or return loc["type"]
|
105
|
+
if subclause?(target, loc["type"],
|
106
|
+
loc&.at(ns("./referenceFrom"))&.text)
|
107
|
+
""
|
108
|
+
else "clause"
|
109
|
+
end
|
73
110
|
end
|
74
111
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
.include?(xml["type"])
|
79
|
-
ret ||= xml.at(".//ancestor::xmlns:references[@normative = 'false']")
|
80
|
-
ret ||= xml.at(ns("./docidentifier[@type = 'metanorma']"))
|
81
|
-
ret and return false
|
82
|
-
true
|
112
|
+
def subclause?(target, type, from)
|
113
|
+
(from&.include?(".") && type == "clause") ||
|
114
|
+
target&.gsub(/<[^<>]+>/, "")&.match?(/^IEV$|^IEC 60050-/)
|
83
115
|
end
|
84
116
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
117
|
+
def eref_localities1(opt)
|
118
|
+
opt[:type] == "anchor" and return nil
|
119
|
+
opt[:type].downcase!
|
120
|
+
opt[:lang] == "zh" and return l10n(eref_localities1_zh(opt))
|
121
|
+
ret = ""
|
122
|
+
opt[:node]["droploc"] != "true" &&
|
123
|
+
!subclause?(opt[:target], opt[:type], opt[:from]) and
|
124
|
+
ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
|
125
|
+
ret += " #{opt[:from]}" if opt[:from]
|
126
|
+
ret += "–#{opt[:upto]}" if opt[:upto]
|
127
|
+
ret += ")" if opt[:type] == "list"
|
128
|
+
l10n(ret)
|
94
129
|
end
|
95
130
|
|
96
|
-
def
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
end
|
106
|
-
idx
|
131
|
+
def anchor_linkend1(node)
|
132
|
+
linkend = @xrefs.anchor(node["target"], :xref)
|
133
|
+
@xrefs.anchor(node["target"], :type) == "clause" &&
|
134
|
+
@xrefs.anchor(node["target"], :level) > 1 &&
|
135
|
+
!start_of_sentence(node) and
|
136
|
+
linkend = strip_initial_clause(linkend)
|
137
|
+
container = @xrefs.anchor(node["target"], :container, false)
|
138
|
+
linkend = prefix_container(container, linkend, node, node["target"])
|
139
|
+
capitalise_xref(node, linkend, anchor_value(node["target"]))
|
107
140
|
end
|
108
141
|
|
109
|
-
def
|
110
|
-
|
111
|
-
|
112
|
-
|
142
|
+
def strip_initial_clause(linkend)
|
143
|
+
x = Nokogiri::XML("<a>#{linkend}</a>")
|
144
|
+
x.at(".//span[@class = 'fmt-element-name']")&.remove
|
145
|
+
to_xml(x.elements.first.children).strip
|
113
146
|
end
|
114
147
|
|
115
|
-
def
|
116
|
-
|
148
|
+
def eref_locality_populate(type, node, number)
|
149
|
+
type == "page" and return ""
|
150
|
+
super
|
117
151
|
end
|
118
152
|
|
119
|
-
def
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
153
|
+
def first_biblio_eref_fn(docxml)
|
154
|
+
@bibanchors ||= biblio_ids_titles(docxml)
|
155
|
+
docxml.xpath("//*[@citeas]").each do |node|
|
156
|
+
@bibanchors[node["bibitemid"]] or next
|
157
|
+
node.children.empty? or next
|
158
|
+
insert_biblio_footnote(node, docxml)
|
159
|
+
break
|
160
|
+
end
|
126
161
|
end
|
127
162
|
|
128
|
-
|
129
|
-
|
130
|
-
|
163
|
+
private
|
164
|
+
|
165
|
+
def insert_biblio_footnote(node, docxml)
|
166
|
+
n = node.next_sibling
|
167
|
+
# Check if the next sibling is a text node that starts with punctuation
|
168
|
+
if n&.text? && (match = n.content.match(/^([.,;:])(?=\s|$)/))
|
169
|
+
insert_biblio_footnote_with_punctuation1(n, match, docxml)
|
170
|
+
else # Default behavior: insert footnote immediately after the node
|
171
|
+
node.next = biblio_ref_inform_fn
|
172
|
+
end
|
131
173
|
end
|
132
174
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
175
|
+
# If so, split the text at the punctuation
|
176
|
+
# and replace the text node with punctuation + footnote + remaining text
|
177
|
+
def insert_biblio_footnote_with_punctuation1(node, match, docxml)
|
178
|
+
punct = match[0]
|
179
|
+
remaining_text = node.content[punct.length..-1]
|
180
|
+
node.content = punct
|
181
|
+
node.add_next_sibling(biblio_ref_inform_fn)
|
182
|
+
remaining_text && !remaining_text.empty? and
|
183
|
+
node.next_sibling
|
184
|
+
.add_next_sibling(Nokogiri::XML::Text.new(
|
185
|
+
remaining_text, docxml
|
186
|
+
))
|
187
|
+
end
|
188
|
+
|
189
|
+
def biblio_ref_inform_fn
|
190
|
+
<<~XML
|
191
|
+
<fn reference='#{UUIDTools::UUID.random_create}'><p>#{@i18n.biblio_ref_inform_fn}</p></fn>
|
192
|
+
XML
|
140
193
|
end
|
141
194
|
end
|
142
195
|
end
|
@@ -31,11 +31,21 @@ module IsoDoc
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
def wrap_termsource_in_parens(xpath)
|
35
|
+
xpath.empty? and return xpath
|
36
|
+
opening_paren = Nokogiri::XML::Node.new("span", xpath[0].document)
|
37
|
+
opening_paren["class"] = "fmt-termsource-delim"
|
38
|
+
opening_paren.content = "("
|
39
|
+
xpath[0].add_previous_sibling(opening_paren)
|
40
|
+
closing_paren = Nokogiri::XML::Node.new("span", xpath[-1].document)
|
41
|
+
closing_paren["class"] = "fmt-termsource-delim"
|
42
|
+
closing_paren.content = ")"
|
43
|
+
xpath[-1].add_next_sibling(closing_paren)
|
44
|
+
# Return expanded nodeset including parentheses
|
45
|
+
parent = xpath[0].parent
|
46
|
+
start_index = parent.children.index(opening_paren)
|
47
|
+
end_index = parent.children.index(closing_paren)
|
48
|
+
parent.children[start_index..end_index]
|
39
49
|
end
|
40
50
|
|
41
51
|
def unwrap_definition1(d)
|
@@ -44,11 +54,15 @@ module IsoDoc
|
|
44
54
|
if v.elements.all? { |n| %w(source p).include?(n.name) }
|
45
55
|
p = v.xpath(ns("./p"))
|
46
56
|
s = v.xpath(ns("./source"))
|
47
|
-
s
|
57
|
+
s = wrap_termsource_in_parens(s) unless s.empty?
|
48
58
|
v.children =
|
49
|
-
"#{p.map(&:children).map
|
59
|
+
"#{p.map(&:children).map do |x|
|
60
|
+
to_xml(x)
|
61
|
+
end.join("\n")}#{s.map do |x|
|
62
|
+
to_xml(x)
|
63
|
+
end.join}"
|
50
64
|
else
|
51
|
-
|
65
|
+
wrap_termsource_in_parens(v.xpath(ns("./source")))
|
52
66
|
end
|
53
67
|
v.replace(v.children)
|
54
68
|
end
|
@@ -120,15 +134,19 @@ module IsoDoc
|
|
120
134
|
end
|
121
135
|
|
122
136
|
def collapse_term_template_tail(opt)
|
123
|
-
|
124
|
-
|
125
|
-
|
137
|
+
if opt[:source]
|
138
|
+
# For this context, we need to use the old string-based approach
|
139
|
+
# since the source element has been removed from its parent
|
140
|
+
src = "<span class='fmt-termsource-delim'>(</span>#{to_xml(opt[:source].children).strip}<span class='fmt-termsource-delim'>)</span>"
|
141
|
+
end
|
142
|
+
opt[:fns].empty? or fn = opt[:fns].map { |f| to_xml(f) }.join
|
143
|
+
"#{collapse_term_related(opt[:rels])} #{src}#{fn}".strip
|
126
144
|
end
|
127
145
|
|
128
146
|
def collapse_term_pref(opt)
|
129
147
|
p = opt[:pref]
|
130
148
|
p.text.strip.empty? and return "**TERM NOT FOUND**"
|
131
|
-
|
149
|
+
wrap_termsource_in_parens(p.xpath(ns(".//semx[@element = 'source']")))
|
132
150
|
p.xpath(ns(".//fmt-termsource")).each { |x| x.replace(x.children) }
|
133
151
|
to_xml(p.children).strip
|
134
152
|
end
|
@@ -172,6 +190,28 @@ module IsoDoc
|
|
172
190
|
end
|
173
191
|
|
174
192
|
def term(docxml); end
|
193
|
+
|
194
|
+
def license_termnote(elem, idx)
|
195
|
+
elem.name = "fn"
|
196
|
+
elem["reference"] = "_termnote_license_#{idx}"
|
197
|
+
elem.parent << elem
|
198
|
+
end
|
199
|
+
|
200
|
+
def termsource_brackets(docxml)
|
201
|
+
docxml.xpath(ns("//term//semx[@element = 'source']")).each do |s|
|
202
|
+
text = termsource_text_content(s)
|
203
|
+
text&.include?("(") && text.include?(")") or next
|
204
|
+
prevbr = s.at("./preceding-sibling::xmlns:span[@class='fmt-termsource-delim']")
|
205
|
+
nextbr = s.at("./following-sibling::xmlns:span[@class='fmt-termsource-delim']")
|
206
|
+
prevbr.children = "["
|
207
|
+
nextbr.children = "]"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
def termsource_text_content(span)
|
212
|
+
span.dup.xpath(ns(".//localityStack | .//locality")).each(&:remove)
|
213
|
+
.text
|
214
|
+
end
|
175
215
|
end
|
176
216
|
end
|
177
217
|
end
|
@@ -3,6 +3,7 @@ require_relative "presentation_bibdata"
|
|
3
3
|
require_relative "presentation_terms"
|
4
4
|
require_relative "presentation_concepts"
|
5
5
|
require_relative "presentation_ref"
|
6
|
+
require_relative "presentation_bibitem"
|
6
7
|
require "isodoc"
|
7
8
|
|
8
9
|
module IsoDoc
|
@@ -13,69 +14,6 @@ module IsoDoc
|
|
13
14
|
super
|
14
15
|
end
|
15
16
|
|
16
|
-
def eref_localities_conflated(refs, target, node)
|
17
|
-
droploc = node["droploc"]
|
18
|
-
node["droploc"] = true
|
19
|
-
ret = resolve_eref_connectives(eref_locality_stacks(refs, target,
|
20
|
-
node))
|
21
|
-
node["droploc"] = droploc
|
22
|
-
p = prefix_clause(target, refs.first.at(ns("./locality")))
|
23
|
-
eref_localities1({ target: target, number: "pl",
|
24
|
-
type: p,
|
25
|
-
from: l10n(ret[1..-1].join), node: node,
|
26
|
-
lang: @lang })
|
27
|
-
end
|
28
|
-
|
29
|
-
def prefix_clause(target, loc)
|
30
|
-
loc["type"] == "clause" or return loc["type"]
|
31
|
-
if subclause?(target, loc["type"],
|
32
|
-
loc&.at(ns("./referenceFrom"))&.text)
|
33
|
-
""
|
34
|
-
else "clause"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def subclause?(target, type, from)
|
39
|
-
(from&.include?(".") && type == "clause") ||
|
40
|
-
target&.gsub(/<[^<>]+>/, "")&.match?(/^IEV$|^IEC 60050-/)
|
41
|
-
end
|
42
|
-
|
43
|
-
def eref_localities1(opt)
|
44
|
-
opt[:type] == "anchor" and return nil
|
45
|
-
opt[:type].downcase!
|
46
|
-
opt[:lang] == "zh" and return l10n(eref_localities1_zh(opt))
|
47
|
-
ret = ""
|
48
|
-
opt[:node]["droploc"] != "true" &&
|
49
|
-
!subclause?(opt[:target], opt[:type], opt[:from]) and
|
50
|
-
ret = eref_locality_populate(opt[:type], opt[:node], opt[:number])
|
51
|
-
ret += " #{opt[:from]}" if opt[:from]
|
52
|
-
ret += "–#{opt[:upto]}" if opt[:upto]
|
53
|
-
ret += ")" if opt[:type] == "list"
|
54
|
-
l10n(ret)
|
55
|
-
end
|
56
|
-
|
57
|
-
def anchor_linkend1(node)
|
58
|
-
linkend = @xrefs.anchor(node["target"], :xref)
|
59
|
-
@xrefs.anchor(node["target"], :type) == "clause" &&
|
60
|
-
@xrefs.anchor(node["target"], :level) > 1 &&
|
61
|
-
!start_of_sentence(node) and
|
62
|
-
linkend = strip_initial_clause(linkend)
|
63
|
-
container = @xrefs.anchor(node["target"], :container, false)
|
64
|
-
linkend = prefix_container(container, linkend, node, node["target"])
|
65
|
-
capitalise_xref(node, linkend, anchor_value(node["target"]))
|
66
|
-
end
|
67
|
-
|
68
|
-
def strip_initial_clause(linkend)
|
69
|
-
x = Nokogiri::XML("<a>#{linkend}</a>")
|
70
|
-
x.at(".//span[@class = 'fmt-element-name']")&.remove
|
71
|
-
to_xml(x.elements.first.children).strip
|
72
|
-
end
|
73
|
-
|
74
|
-
def eref_locality_populate(type, node, number)
|
75
|
-
type == "page" and return ""
|
76
|
-
super
|
77
|
-
end
|
78
|
-
|
79
17
|
def block_delim
|
80
18
|
"—"
|
81
19
|
end
|
@@ -183,7 +121,7 @@ module IsoDoc
|
|
183
121
|
%w(icap industry-connection-report).include?(@subdoctype)
|
184
122
|
%w(▪ —)
|
185
123
|
else
|
186
|
-
%w(&#
|
124
|
+
%w(—)
|
187
125
|
end
|
188
126
|
end
|
189
127
|
|
@@ -231,13 +169,23 @@ module IsoDoc
|
|
231
169
|
# before processing, move license termnotes to fn at end of term,
|
232
170
|
# so they aren't numbered as termnotes
|
233
171
|
def conversions(docxml)
|
234
|
-
docxml.xpath(ns("//termnote[@type='license']"))
|
235
|
-
|
236
|
-
n
|
172
|
+
docxml.xpath(ns("//termnote[@type='license']"))
|
173
|
+
.each_with_index do |n, i|
|
174
|
+
license_termnote(n, i)
|
237
175
|
end
|
238
176
|
super
|
239
177
|
end
|
240
178
|
|
179
|
+
def cleanup(docxml)
|
180
|
+
termsource_brackets(docxml)
|
181
|
+
super
|
182
|
+
end
|
183
|
+
|
184
|
+
def document_footnotes(docxml)
|
185
|
+
first_biblio_eref_fn(docxml)
|
186
|
+
super
|
187
|
+
end
|
188
|
+
|
241
189
|
include Init
|
242
190
|
end
|
243
191
|
end
|