isodoc 2.12.1 → 2.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +0 -21
- data/lib/isodoc/function/blocks.rb +8 -8
- data/lib/isodoc/function/blocks_example_note.rb +46 -23
- data/lib/isodoc/function/inline.rb +31 -8
- data/lib/isodoc/function/lists.rb +4 -4
- data/lib/isodoc/function/references.rb +5 -5
- data/lib/isodoc/function/reqt.rb +2 -2
- data/lib/isodoc/function/section.rb +25 -25
- data/lib/isodoc/function/section_titles.rb +15 -12
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +17 -14
- data/lib/isodoc/function/to_word_html.rb +5 -0
- data/lib/isodoc/html_function/footnotes.rb +2 -1
- data/lib/isodoc/html_function/html.rb +1 -5
- data/lib/isodoc/init.rb +14 -4
- data/lib/isodoc/metadata.rb +9 -0
- data/lib/isodoc/metadata_contributor.rb +1 -1
- data/lib/isodoc/metadata_date.rb +1 -1
- data/lib/isodoc/presentation_function/autonum.rb +139 -0
- data/lib/isodoc/presentation_function/block.rb +48 -39
- data/lib/isodoc/presentation_function/docid.rb +0 -23
- data/lib/isodoc/presentation_function/erefs.rb +4 -2
- data/lib/isodoc/presentation_function/image.rb +21 -5
- data/lib/isodoc/presentation_function/inline.rb +1 -1
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +46 -118
- data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
- data/lib/isodoc/presentation_function/terms.rb +3 -4
- data/lib/isodoc/presentation_function/title.rb +107 -0
- data/lib/isodoc/presentation_function/xrefs.rb +17 -10
- data/lib/isodoc/presentation_xml_convert.rb +2 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +7 -35
- data/lib/isodoc/word_function/footnotes.rb +1 -1
- data/lib/isodoc/word_function/lists.rb +12 -10
- data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
- data/lib/isodoc/word_function/postprocess_table.rb +1 -1
- data/lib/isodoc/word_function/postprocess_toc.rb +1 -1
- data/lib/isodoc/word_function/table.rb +2 -2
- data/lib/isodoc/xref/xref_anchor.rb +31 -16
- data/lib/isodoc/xref/xref_counter_types.rb +3 -2
- data/lib/isodoc/xref/xref_gen.rb +57 -33
- data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
- data/lib/isodoc/xref/xref_sect_gen.rb +60 -28
- data/lib/isodoc/xref/xref_util.rb +43 -1
- data/lib/isodoc/xref.rb +3 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
- data/lib/isodoc-yaml/i18n-de.yaml +9 -9
- data/lib/isodoc-yaml/i18n-en.yaml +9 -9
- data/lib/isodoc-yaml/i18n-es.yaml +9 -9
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
- data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
- data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
- data/lib/nokogiri/xml/node.rb +1 -0
- metadata +6 -4
@@ -28,24 +28,27 @@ module IsoDoc
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
33
|
-
first.children.each { |n| parse(n, para) }
|
34
|
-
node.elements.drop(1).each { |n| parse(n, div) }
|
35
|
-
else
|
36
|
-
node.elements.each { |n| parse(n, div) }
|
37
|
-
end
|
31
|
+
def termnote_p_class
|
32
|
+
nil
|
38
33
|
end
|
39
34
|
|
40
35
|
def termnote_parse(node, out)
|
41
|
-
|
36
|
+
para = block_body_first_elem(node)
|
42
37
|
out.div **note_attrs(node) do |div|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
38
|
+
termnote_parse1(node, para, div)
|
39
|
+
para&.xpath("./following-sibling::*")&.each { |n| parse(n, div) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def termnote_parse1(node, para, div)
|
44
|
+
div.p **attr_code(class: termnote_p_class) do |p|
|
45
|
+
name = node.at(ns("./fmt-name")) and
|
46
|
+
p.span class: "termnote_label" do |s|
|
47
|
+
children_parse(name, s)
|
48
|
+
end
|
49
|
+
para&.name == "p" and children_parse(para, p)
|
48
50
|
end
|
51
|
+
para&.name != "p" and parse(para, div)
|
49
52
|
end
|
50
53
|
|
51
54
|
def termref_parse(node, out)
|
@@ -60,7 +63,7 @@ module IsoDoc
|
|
60
63
|
end
|
61
64
|
|
62
65
|
def termdef_parse(node, out)
|
63
|
-
name = node.at(ns("./name"))&.remove
|
66
|
+
name = node.at(ns("./fmt-name"))&.remove
|
64
67
|
out.p class: "TermNum", id: node["id"] do |p|
|
65
68
|
name&.children&.each { |n| parse(n, p) }
|
66
69
|
end
|
@@ -262,6 +262,11 @@ module IsoDoc
|
|
262
262
|
when "ruby" then ruby_parse(node, out)
|
263
263
|
when "rt" then rt_parse(node, out)
|
264
264
|
when "rb" then rb_parse(node, out)
|
265
|
+
when "semx" then semx_parse(node, out)
|
266
|
+
when "name" then name_parse(node, out)
|
267
|
+
when "fmt-xref-label" then xref_label_parse(node, out)
|
268
|
+
when "fmt-name" then fmt_name_parse(node, out)
|
269
|
+
when "floating-title" then floating_title_parse(node, out)
|
265
270
|
else error_parse(node, out)
|
266
271
|
end
|
267
272
|
end
|
@@ -24,6 +24,7 @@ module IsoDoc
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
# Move to Presentation XML, as <fmt-footnote>: it's a footnote body
|
27
28
|
def make_table_footnote_text(node, fnid, fnref)
|
28
29
|
attrs = { id: "fn:#{fnid}" }
|
29
30
|
noko do |xml|
|
@@ -68,7 +69,7 @@ module IsoDoc
|
|
68
69
|
|
69
70
|
def footnote_parse(node, out)
|
70
71
|
return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
|
71
|
-
!node.ancestors.map(&:name).include?("name")
|
72
|
+
!node.ancestors.map(&:name).include?("fmt-name")
|
72
73
|
|
73
74
|
fn = node["reference"] || UUIDTools::UUID.random_create.to_s
|
74
75
|
attrs = { class: "FootnoteRef", href: "#fn:#{fn}" }
|
@@ -15,10 +15,6 @@ module IsoDoc
|
|
15
15
|
end.join("\n")
|
16
16
|
end
|
17
17
|
|
18
|
-
def preprocess_xslt(docxml)
|
19
|
-
super
|
20
|
-
end
|
21
|
-
|
22
18
|
def make_body1(body, _docxml)
|
23
19
|
return if @bare
|
24
20
|
|
@@ -78,7 +74,7 @@ module IsoDoc
|
|
78
74
|
end
|
79
75
|
|
80
76
|
def sourcecode_parse(node, out)
|
81
|
-
name = node.at(ns("./name"))
|
77
|
+
name = node.at(ns("./fmt-name"))
|
82
78
|
tag = node.at(ns(".//sourcecode | .//table")) ? "div" : "pre"
|
83
79
|
attr = sourcecode_attrs(node).merge(class: "sourcecode")
|
84
80
|
out.send tag, **attr do |div|
|
data/lib/isodoc/init.rb
CHANGED
@@ -141,13 +141,14 @@ module IsoDoc
|
|
141
141
|
self.class::AGENCIES.include?(text)
|
142
142
|
end
|
143
143
|
|
144
|
-
# This is highly specific to ISO, but it's not a bad precedent for
|
145
|
-
# references anyway; keeping here instead of in IsoDoc::Iso for now
|
146
144
|
def docid_l10n(text)
|
147
145
|
text.nil? and return text
|
148
146
|
@i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
|
149
|
-
|
150
|
-
text
|
147
|
+
x = Nokogiri::XML::DocumentFragment.parse(text)
|
148
|
+
(x.xpath(".//text()") - x.xpath(".//fn//text()")).each do |n|
|
149
|
+
n.replace(n.text.gsub(/ /, " "))
|
150
|
+
end
|
151
|
+
to_xml(x)
|
151
152
|
end
|
152
153
|
|
153
154
|
def docid_prefix(prefix, docid)
|
@@ -161,5 +162,14 @@ module IsoDoc
|
|
161
162
|
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
|
162
163
|
.include? prefix
|
163
164
|
end
|
165
|
+
|
166
|
+
def connectives_spans(text)
|
167
|
+
text.gsub("<conn>", "<span class='fmt-conn'>")
|
168
|
+
.gsub("</conn>", "</span>")
|
169
|
+
.gsub("<enum-comma>", "<span class='fmt-enum-comma'>")
|
170
|
+
.gsub("</enum-comma>", "</span>")
|
171
|
+
.gsub("<comma>", "<span class='fmt-comma'>")
|
172
|
+
.gsub("</comma>", "</span>")
|
173
|
+
end
|
164
174
|
end
|
165
175
|
end
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -13,6 +13,15 @@ module IsoDoc
|
|
13
13
|
@i18n.l10n(expr, lang, script, locale)
|
14
14
|
end
|
15
15
|
|
16
|
+
def connectives_strip(text)
|
17
|
+
text.gsub("<conn>", "")
|
18
|
+
.gsub("</conn>", "")
|
19
|
+
.gsub("<enum-comma>", "")
|
20
|
+
.gsub("</enum-comma>", "")
|
21
|
+
.gsub("<comma>", "")
|
22
|
+
.gsub("</comma>", "")
|
23
|
+
end
|
24
|
+
|
16
25
|
def initialize(lang, script, locale, i18n, fonts_options = {})
|
17
26
|
@metadata = { lang:, script: }
|
18
27
|
DATETYPES.each { |w| @metadata["#{w.tr('-', '_')}date".to_sym] = "XXX" }
|
@@ -79,7 +79,7 @@ module IsoDoc
|
|
79
79
|
def agency(xml)
|
80
80
|
agency, publisher = agency1(xml)
|
81
81
|
set(:agency, agency.sub(%r{/$}, ""))
|
82
|
-
set(:publisher, @i18n.boolean_conj(publisher, "and"))
|
82
|
+
set(:publisher, connectives_strip(@i18n.boolean_conj(publisher, "and")))
|
83
83
|
agency_addr(xml)
|
84
84
|
end
|
85
85
|
|
data/lib/isodoc/metadata_date.rb
CHANGED
@@ -0,0 +1,139 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def prefix_name(node, delims, label, elem)
|
4
|
+
label, delims = prefix_name_defaults(node, delims, label)
|
5
|
+
name, ins, ids, number = prefix_name_prep(node, elem)
|
6
|
+
ins.next = fmt_xref_label(label, number, ids)
|
7
|
+
# autonum can be empty, e.g single note in clause: "NOTE []"
|
8
|
+
number and node["autonum"] = number.gsub(/<[^>]+>/, "")
|
9
|
+
!node.at(ns("./fmt-#{elem}")) &&
|
10
|
+
(c = fmt_caption(label, elem, name, ids, delims)) and ins.next = c
|
11
|
+
prefix_name_postprocess(node, elem)
|
12
|
+
end
|
13
|
+
|
14
|
+
def prefix_name_defaults(node, delims, label)
|
15
|
+
label&.empty? and label = nil
|
16
|
+
delims.nil? and delims = {}
|
17
|
+
[label, delims]
|
18
|
+
end
|
19
|
+
|
20
|
+
def prefix_name_prep(node, elem)
|
21
|
+
lbls = prefix_name_labels(node)
|
22
|
+
name = node.at(ns("./#{elem}")) and name["id"] = lbls[:name]
|
23
|
+
ins = name || node.add_first_child("<sentinel/>").elements.first
|
24
|
+
node["unnumbered"] or
|
25
|
+
number = @xrefs.anchor(node["id"], :value, false)&.strip
|
26
|
+
[name, ins, lbls, number]
|
27
|
+
end
|
28
|
+
|
29
|
+
def prefix_name_labels(node)
|
30
|
+
{ elem: node["id"],
|
31
|
+
name: "_#{UUIDTools::UUID.random_create}" }
|
32
|
+
end
|
33
|
+
|
34
|
+
def prefix_name_postprocess(node, elem)
|
35
|
+
node.at(ns("./sentinel"))&.remove
|
36
|
+
strip_duplicate_ids(node, node.at(ns("./#{elem}")),
|
37
|
+
node.at(ns("./fmt-#{elem}")))
|
38
|
+
end
|
39
|
+
|
40
|
+
def transfer_id(old, new)
|
41
|
+
old["id"] or return
|
42
|
+
new["id"] = old["id"]
|
43
|
+
old["original-id"] = old["id"]
|
44
|
+
old.delete("id")
|
45
|
+
end
|
46
|
+
|
47
|
+
def gather_all_ids(elem)
|
48
|
+
elem.xpath(".//*[@id]").each_with_object([]) do |i, m|
|
49
|
+
m << i["id"]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# remove ids duplicated between title and fmt-title
|
54
|
+
# index terms are assumed transferred to fmt-title from title
|
55
|
+
def strip_duplicate_ids(_node, sem_title, pres_title)
|
56
|
+
sem_title && pres_title or return
|
57
|
+
ids = gather_all_ids(pres_title)
|
58
|
+
sem_title.xpath(".//*[@id]").each do |x|
|
59
|
+
ids.include?(x["id"]) or next
|
60
|
+
x["original-id"] = x["id"]
|
61
|
+
x.delete("id")
|
62
|
+
end
|
63
|
+
sem_title.xpath(ns(".//index")).each(&:remove)
|
64
|
+
end
|
65
|
+
|
66
|
+
def semx(node, label, element = "autonum")
|
67
|
+
id = node["id"] || node[:id]
|
68
|
+
/<semx element='[^']+' source='#{id}'/.match?(label) and return label
|
69
|
+
l = stripsemx(label)
|
70
|
+
%(<semx element='#{element}' source='#{id}'>#{l}</semx>)
|
71
|
+
end
|
72
|
+
|
73
|
+
def autonum(id, num)
|
74
|
+
/<semx/.match?(num) and return num # already contains markup
|
75
|
+
"<semx element='autonum' source='#{id}'>#{num}</semx>"
|
76
|
+
end
|
77
|
+
|
78
|
+
def labelled_autonum(label, id, num)
|
79
|
+
elem = "<span class='fmt-element-name'>#{label}</span>"
|
80
|
+
num.blank? and return elem
|
81
|
+
l10n("#{elem} #{autonum(id, num)}")
|
82
|
+
end
|
83
|
+
|
84
|
+
def fmt_xref_label(label, _number, ids)
|
85
|
+
label or return ""
|
86
|
+
x = @xrefs.anchor(ids[:elem], :xref, false) or return ""
|
87
|
+
ret = "<fmt-xref-label>#{x}</fmt-xref-label>"
|
88
|
+
container = @xrefs.anchor(ids[:elem], :container, false)
|
89
|
+
y = prefix_container_fmt_xref_label(container, x)
|
90
|
+
y != x and
|
91
|
+
ret += "<fmt-xref-label container='#{container}'>#{y}</fmt-xref-label>"
|
92
|
+
ret
|
93
|
+
end
|
94
|
+
|
95
|
+
def prefix_container_fmt_xref_label(container, xref)
|
96
|
+
container or return xref
|
97
|
+
container_container = @xrefs.anchor(container, :container, false)
|
98
|
+
container_label =
|
99
|
+
prefix_container_fmt_xref_label(container_container,
|
100
|
+
@xrefs.anchor(container, :xref, false))
|
101
|
+
l10n(connectives_spans(@i18n.nested_xref
|
102
|
+
.sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
|
103
|
+
.sub("%2", xref)))
|
104
|
+
end
|
105
|
+
|
106
|
+
# detect whether string which may contain XML markup is empty
|
107
|
+
def empty_xml?(str)
|
108
|
+
str.blank? and return true
|
109
|
+
x = Nokogiri::XML::DocumentFragment.parse(str)
|
110
|
+
x.to_str.strip.empty?
|
111
|
+
end
|
112
|
+
|
113
|
+
# Remove ".blank?" tests if want empty delim placeholders for manipulation
|
114
|
+
def fmt_caption(label, elem, name, ids, delims)
|
115
|
+
label = fmt_caption_label_wrap(label)
|
116
|
+
c = fmt_caption2(label, elem, name, ids, delims)
|
117
|
+
empty_xml?(c) and return
|
118
|
+
!delims[:label].blank? and
|
119
|
+
f = "<span class='fmt-label-delim'>#{delims[:label]}</span>"
|
120
|
+
"<fmt-#{elem}>#{c}#{f}</fmt-#{elem}>"
|
121
|
+
end
|
122
|
+
|
123
|
+
def fmt_caption_label_wrap(label)
|
124
|
+
empty_xml?(label) || %r{<span class=['"]fmt-caption-label['"]}.match?(label) or
|
125
|
+
label = "<span class='fmt-caption-label'>#{label}</span>"
|
126
|
+
label
|
127
|
+
end
|
128
|
+
|
129
|
+
def fmt_caption2(label, elem, name, ids, delims)
|
130
|
+
if name && !name.children.empty?
|
131
|
+
empty_xml?(label) or
|
132
|
+
d = "<span class='fmt-caption-delim'>#{delims[:caption]}</span>"
|
133
|
+
attr = " element='#{elem}' source='#{ids[:name]}'"
|
134
|
+
"#{label}#{d}<semx #{attr}>#{to_xml(name.children)}</semx>"
|
135
|
+
elsif label then label
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -1,29 +1,23 @@
|
|
1
1
|
require_relative "image"
|
2
2
|
require_relative "sourcecode"
|
3
|
+
require_relative "autonum"
|
3
4
|
require "rouge"
|
4
5
|
|
5
6
|
module IsoDoc
|
6
7
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
7
8
|
def lower2cap(text)
|
8
|
-
|
9
|
-
text
|
9
|
+
text.nil? and return text
|
10
|
+
x = Nokogiri::XML("<a>#{text}</a>")
|
11
|
+
firsttext = x.at(".//text()[string-length(normalize-space(.))>0]") or return text
|
12
|
+
/^[[:upper:]][[:upper:]]/.match?(firsttext.text) and return text
|
13
|
+
firsttext.replace(firsttext.text.capitalize)
|
14
|
+
to_xml(x.root.children)
|
10
15
|
end
|
11
16
|
|
12
17
|
def block_delim
|
13
18
|
" — "
|
14
19
|
end
|
15
20
|
|
16
|
-
def prefix_name(node, delim, number, elem)
|
17
|
-
number.nil? || number.empty? and return
|
18
|
-
unless name = node.at(ns("./#{elem}"))
|
19
|
-
node.add_first_child "<#{elem}></#{elem}>"
|
20
|
-
name = node.children.first
|
21
|
-
end
|
22
|
-
if name.children.empty? then name.add_child(cleanup_entities(number.strip))
|
23
|
-
else (name.children.first.previous = "#{number.strip}#{delim}")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
21
|
def formula(docxml)
|
28
22
|
docxml.xpath(ns("//formula")).each { |f| formula1(f) }
|
29
23
|
end
|
@@ -31,7 +25,7 @@ module IsoDoc
|
|
31
25
|
def formula1(elem)
|
32
26
|
formula_where(elem.at(ns("./dl")))
|
33
27
|
lbl = @xrefs.anchor(elem["id"], :label, false)
|
34
|
-
lbl.nil? || lbl.empty? or prefix_name(elem,
|
28
|
+
lbl.nil? || lbl.empty? or prefix_name(elem, {}, lbl, "name")
|
35
29
|
end
|
36
30
|
|
37
31
|
def formula_where(dlist)
|
@@ -47,11 +41,8 @@ module IsoDoc
|
|
47
41
|
|
48
42
|
def example1(elem)
|
49
43
|
n = @xrefs.get[elem["id"]]
|
50
|
-
lbl =
|
51
|
-
|
52
|
-
else l10n("#{@i18n.example} #{n[:label]}")
|
53
|
-
end
|
54
|
-
prefix_name(elem, block_delim, lbl, "name")
|
44
|
+
lbl = labelled_autonum(@i18n.example, elem["id"], n&.dig(:label))
|
45
|
+
prefix_name(elem, { caption: block_delim }, lbl, "name")
|
55
46
|
end
|
56
47
|
|
57
48
|
def note(docxml)
|
@@ -59,22 +50,18 @@ module IsoDoc
|
|
59
50
|
end
|
60
51
|
|
61
52
|
def note_delim(_elem)
|
62
|
-
""
|
53
|
+
"<tab/>"
|
63
54
|
end
|
64
55
|
|
65
56
|
def note1(elem)
|
66
57
|
%w(bibdata bibitem).include?(elem.parent.name) ||
|
67
|
-
elem["notag"] == "true"
|
68
|
-
|
69
|
-
prefix_name(elem, "", lbl, "name")
|
58
|
+
elem["notag"] == "true" or lbl = note_label(elem)
|
59
|
+
prefix_name(elem, { label: note_delim(elem) }, lbl, "name")
|
70
60
|
end
|
71
61
|
|
72
62
|
def note_label(elem)
|
73
63
|
n = @xrefs.get[elem["id"]]
|
74
|
-
|
75
|
-
(n.nil? || n[:label].nil? || n[:label].empty?) or
|
76
|
-
lbl = l10n("#{lbl} #{n[:label]}")
|
77
|
-
"#{lbl}#{note_delim(elem)}"
|
64
|
+
labelled_autonum(@i18n.note, elem["id"], n&.dig(:label))
|
78
65
|
end
|
79
66
|
|
80
67
|
def admonition(docxml)
|
@@ -85,24 +72,25 @@ module IsoDoc
|
|
85
72
|
if elem["type"] == "box"
|
86
73
|
admonition_numbered1(elem)
|
87
74
|
elsif elem["notag"] == "true" || elem.at(ns("./name"))
|
75
|
+
prefix_name(elem, { label: admonition_delim(elem) }, nil, "name")
|
88
76
|
else
|
89
77
|
label = admonition_label(elem, nil)
|
90
|
-
prefix_name(elem,
|
78
|
+
prefix_name(elem, { label: admonition_delim(elem) }, label, "name")
|
91
79
|
end
|
92
|
-
n = elem.at(ns("./name")) and n << admonition_delim(elem)
|
93
80
|
end
|
94
81
|
|
95
82
|
def admonition_numbered1(elem)
|
96
|
-
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
83
|
+
# elem["unnumbered"] && !elem.at(ns("./name")) and return
|
97
84
|
label = admonition_label(elem, @xrefs.anchor(elem["id"], :label, false))
|
98
|
-
prefix_name(elem, block_delim, label, "name")
|
85
|
+
prefix_name(elem, { caption: block_delim }, label, "name")
|
99
86
|
end
|
100
87
|
|
101
88
|
def admonition_label(elem, num)
|
102
89
|
lbl = if elem["type"] == "box" then @i18n.box
|
103
90
|
else @i18n.admonition[elem["type"]]&.upcase end
|
104
|
-
|
105
|
-
lbl
|
91
|
+
#lbl &&= "<span class='fmt-element-name'>#{lbl}</span>"
|
92
|
+
#num and lbl = l10n("#{lbl} #{autonum(elem['id'], num)}")
|
93
|
+
labelled_autonum(lbl, elem["id"], num)
|
106
94
|
end
|
107
95
|
|
108
96
|
def admonition_delim(_elem)
|
@@ -119,8 +107,14 @@ module IsoDoc
|
|
119
107
|
labelled_ancestor(elem) and return
|
120
108
|
elem["unnumbered"] && !elem.at(ns("./name")) and return
|
121
109
|
n = @xrefs.anchor(elem["id"], :label, false)
|
122
|
-
|
123
|
-
|
110
|
+
#lbl = "<span class='fmt-element-name'>#{lower2cap @i18n.table}</span> "\
|
111
|
+
#"#{autonum(elem['id'], n)}"
|
112
|
+
lbl = labelled_autonum(lower2cap(@i18n.table), elem["id"], n)
|
113
|
+
prefix_name(elem, { caption: table_delim }, l10n(lbl), "name")
|
114
|
+
end
|
115
|
+
|
116
|
+
def table_delim
|
117
|
+
block_delim
|
124
118
|
end
|
125
119
|
|
126
120
|
def table_long_strings_cleanup(docxml)
|
@@ -156,7 +150,23 @@ module IsoDoc
|
|
156
150
|
elem.replace(elem.children)
|
157
151
|
end
|
158
152
|
|
159
|
-
def dl(docxml)
|
153
|
+
def dl(docxml)
|
154
|
+
docxml.xpath(ns("//dl")).each { |f| dl1(f) }
|
155
|
+
end
|
156
|
+
|
157
|
+
def dl1(elem)
|
158
|
+
elem.at(ns("./name")) and
|
159
|
+
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
160
|
+
end
|
161
|
+
|
162
|
+
def ul(docxml)
|
163
|
+
docxml.xpath(ns("//ul")).each { |f| ul1(f) }
|
164
|
+
end
|
165
|
+
|
166
|
+
def ul1(elem)
|
167
|
+
elem.at(ns("./name")) and
|
168
|
+
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
169
|
+
end
|
160
170
|
|
161
171
|
def ol(docxml)
|
162
172
|
docxml.xpath(ns("//ol")).each { |f| ol1(f) }
|
@@ -179,9 +189,8 @@ module IsoDoc
|
|
179
189
|
|
180
190
|
def ol1(elem)
|
181
191
|
elem["type"] ||= ol_depth(elem).to_s
|
182
|
-
elem.
|
183
|
-
|
184
|
-
end
|
192
|
+
elem.at(ns("./name")) and
|
193
|
+
prefix_name(elem, {}, "", "name") # copy name to fmt-name
|
185
194
|
end
|
186
195
|
|
187
196
|
def ol_label(elem)
|
@@ -6,29 +6,6 @@ module IsoDoc
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
=begin
|
10
|
-
# This is highly specific to ISO, but it's not a bad precedent for
|
11
|
-
# references anyway; keeping here instead of in IsoDoc::Iso for now
|
12
|
-
def docid_l10n(text)
|
13
|
-
text.nil? and return text
|
14
|
-
@i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
|
15
|
-
text.size < 20 and text.gsub!(/ /, " ")
|
16
|
-
text
|
17
|
-
end
|
18
|
-
|
19
|
-
def docid_prefix(prefix, docid)
|
20
|
-
docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
|
21
|
-
!/^#{prefix}\b/.match(docid)
|
22
|
-
docid_l10n(docid)
|
23
|
-
end
|
24
|
-
|
25
|
-
def omit_docid_prefix(prefix)
|
26
|
-
prefix.nil? || prefix.empty? and return true
|
27
|
-
%w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
|
28
|
-
.include? prefix
|
29
|
-
end
|
30
|
-
=end
|
31
|
-
|
32
9
|
def pref_ref_code(bib)
|
33
10
|
bib["suppress_identifier"] == "true" and return nil
|
34
11
|
ret = bib.xpath(ns("./docidentifier[@scope = 'biblio-tag']"))
|
@@ -5,7 +5,8 @@ module IsoDoc
|
|
5
5
|
def citeas(xmldoc)
|
6
6
|
xmldoc.xpath(ns("//eref | //origin | //quote//source")).each do |e|
|
7
7
|
e["bibitemid"] && e["citeas"] or next
|
8
|
-
a = @xrefs.anchor(e["bibitemid"], :xref, false) and
|
8
|
+
a = @xrefs.anchor(e["bibitemid"], :xref, false) and
|
9
|
+
e["citeas"] = a.gsub(%r{</?[^>]+>}, "")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -87,7 +88,8 @@ module IsoDoc
|
|
87
88
|
locs1 = []
|
88
89
|
until locs.empty?
|
89
90
|
if locs[1] == "to"
|
90
|
-
locs1 << @i18n.chain_to.sub("%1", locs[0])
|
91
|
+
locs1 << connectives_spans(@i18n.chain_to.sub("%1", locs[0])
|
92
|
+
.sub("%2", locs[2]))
|
91
93
|
locs.shift(3)
|
92
94
|
else locs1 << locs.shift
|
93
95
|
end
|
@@ -43,16 +43,32 @@ module IsoDoc
|
|
43
43
|
elem.children = x
|
44
44
|
end
|
45
45
|
|
46
|
+
def subfigure_delim
|
47
|
+
""
|
48
|
+
# "<span class='fmt-label-delim'>)</span>"
|
49
|
+
end
|
50
|
+
|
51
|
+
def figure_delim(_elem)
|
52
|
+
block_delim
|
53
|
+
end
|
54
|
+
|
55
|
+
def figure_name(elem)
|
56
|
+
"<span class='fmt-element-name'>#{figure_label(elem)}</span> "
|
57
|
+
end
|
58
|
+
|
46
59
|
def figure1(elem)
|
47
60
|
elem["class"] == "pseudocode" || elem["type"] == "pseudocode" and
|
48
61
|
return sourcecode1(elem)
|
49
62
|
figure_fn(elem)
|
50
63
|
figure_key(elem.at(ns("./dl")))
|
51
|
-
|
52
|
-
lbl =
|
53
|
-
|
54
|
-
|
55
|
-
|
64
|
+
lbl = @xrefs.anchor(elem["id"], :label, false)
|
65
|
+
lbl and a = autonum(elem["id"], lbl)
|
66
|
+
figname = figure_name(elem)
|
67
|
+
if elem.parent.name == "figure"
|
68
|
+
a += subfigure_delim
|
69
|
+
end
|
70
|
+
lbl && figure_label?(elem) and s = "#{figname}#{a}"
|
71
|
+
prefix_name(elem, { caption: figure_delim(elem) }, l10n(s&.strip), "name")
|
56
72
|
end
|
57
73
|
|
58
74
|
# move footnotes into key, and get rid of footnote reference
|
@@ -13,7 +13,7 @@ module IsoDoc
|
|
13
13
|
node["style"] == "id" and anchor_id_postprocess(node)
|
14
14
|
xref_empty?(node) or return
|
15
15
|
target = docid_l10n(node["target"]) ||
|
16
|
-
expand_citeas(
|
16
|
+
docid_l10n(expand_citeas(node["citeas"]))
|
17
17
|
link = anchor_linkend(node, target)
|
18
18
|
link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
|
19
19
|
link, node)
|
@@ -24,7 +24,7 @@ module IsoDoc
|
|
24
24
|
def recommendation1(elem, type)
|
25
25
|
lbl = @reqt_models.model(elem["model"])
|
26
26
|
.recommendation_label(elem, type, xrefs)
|
27
|
-
prefix_name(elem,
|
27
|
+
prefix_name(elem, {}, l10n(lbl), "name")
|
28
28
|
end
|
29
29
|
|
30
30
|
def requirement_render_preprocessing(docxml); end
|