isodoc 1.2.6 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +69 -0
- data/README.adoc +1 -3
- data/isodoc.gemspec +2 -1
- data/lib/isodoc-yaml/i18n-en.yaml +56 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +64 -7
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc/base_style/all.css +4 -0
- data/lib/isodoc/base_style/blocks.scss +2 -2
- data/lib/isodoc/base_style/reset.css +4 -0
- data/lib/isodoc/base_style/reset.scss +5 -0
- data/lib/isodoc/base_style/typography.scss +1 -1
- data/lib/isodoc/convert.rb +13 -98
- data/lib/isodoc/css.rb +95 -0
- data/lib/isodoc/function/inline.rb +0 -33
- data/lib/isodoc/function/inline_simple.rb +4 -1
- data/lib/isodoc/function/lists.rb +2 -1
- data/lib/isodoc/function/references.rb +8 -13
- data/lib/isodoc/function/section.rb +1 -1
- data/lib/isodoc/function/table.rb +10 -0
- data/lib/isodoc/function/to_word_html.rb +2 -2
- data/lib/isodoc/gem_tasks.rb +4 -0
- data/lib/isodoc/html_function/html.rb +1 -0
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +82 -0
- data/lib/isodoc/html_function/postprocess.rb +41 -20
- data/lib/isodoc/i18n.rb +15 -2
- data/lib/isodoc/metadata.rb +28 -109
- data/lib/isodoc/metadata_contributor.rb +91 -0
- data/lib/isodoc/metadata_date.rb +6 -0
- data/lib/isodoc/presentation_function/bibdata.rb +79 -7
- data/lib/isodoc/presentation_function/block.rb +14 -9
- data/lib/isodoc/presentation_function/inline.rb +126 -22
- data/lib/isodoc/presentation_function/section.rb +9 -0
- data/lib/isodoc/presentation_xml_convert.rb +5 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_convert.rb +0 -20
- data/lib/isodoc/word_function/body.rb +12 -0
- data/lib/isodoc/word_function/postprocess.rb +38 -80
- data/lib/isodoc/word_function/postprocess_cover.rb +55 -0
- data/lib/isodoc/word_function/table.rb +10 -0
- data/lib/isodoc/xref.rb +1 -0
- data/lib/isodoc/xref/xref_counter.rb +20 -9
- data/lib/isodoc/xref/xref_gen.rb +20 -2
- data/lib/isodoc/xref/xref_sect_gen.rb +1 -1
- data/spec/assets/html.scss +14 -0
- data/spec/assets/i18n.yaml +17 -9
- data/spec/isodoc/blocks_spec.rb +89 -241
- data/spec/isodoc/cleanup_spec.rb +0 -1
- data/spec/isodoc/footnotes_spec.rb +4 -5
- data/spec/isodoc/i18n_spec.rb +73 -38
- data/spec/isodoc/inline_spec.rb +177 -199
- data/spec/isodoc/lists_spec.rb +1 -1
- data/spec/isodoc/metadata_spec.rb +50 -7
- data/spec/isodoc/postproc_spec.rb +472 -11
- data/spec/isodoc/presentation_xml_spec.rb +584 -1
- data/spec/isodoc/ref_spec.rb +327 -12
- data/spec/isodoc/table_spec.rb +28 -0
- data/spec/isodoc/xref_spec.rb +162 -17
- data/spec/spec_helper.rb +2 -0
- metadata +22 -7
- data/.github/workflows/macos.yml +0 -42
- data/.github/workflows/ubuntu.yml +0 -62
- data/.github/workflows/windows.yml +0 -44
data/lib/isodoc/i18n.rb
CHANGED
@@ -4,8 +4,21 @@ module IsoDoc
|
|
4
4
|
class I18n
|
5
5
|
def load_yaml(lang, script, i18nyaml = nil)
|
6
6
|
ret = load_yaml1(lang, script)
|
7
|
-
return ret.merge(YAML.load_file(i18nyaml)) if i18nyaml
|
8
|
-
ret
|
7
|
+
return normalise_hash(ret.merge(YAML.load_file(i18nyaml))) if i18nyaml
|
8
|
+
normalise_hash(ret)
|
9
|
+
end
|
10
|
+
|
11
|
+
def normalise_hash(ret)
|
12
|
+
if ret.is_a? Hash
|
13
|
+
ret.each do |k, v|
|
14
|
+
ret[k] = normalise_hash(v)
|
15
|
+
end
|
16
|
+
ret
|
17
|
+
elsif ret.is_a? Array then ret.map { |n| normalise_hash(n) }
|
18
|
+
elsif ret.is_a? String then ret.unicode_normalize(:nfc)
|
19
|
+
else
|
20
|
+
ret
|
21
|
+
end
|
9
22
|
end
|
10
23
|
|
11
24
|
def load_yaml1(lang, script)
|
data/lib/isodoc/metadata.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative './metadata_date'
|
4
|
+
require_relative './metadata_contributor'
|
4
5
|
|
5
6
|
module IsoDoc
|
6
7
|
class Metadata
|
@@ -15,7 +16,7 @@ module IsoDoc
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def initialize(lang, script, i18n, fonts_options = {})
|
18
|
-
@metadata = {}
|
19
|
+
@metadata = { lang: lang, script: script }
|
19
20
|
DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = 'XXX' }
|
20
21
|
@lang = lang
|
21
22
|
@script = script
|
@@ -37,122 +38,33 @@ module IsoDoc
|
|
37
38
|
@metadata[key] = value
|
38
39
|
end
|
39
40
|
|
40
|
-
|
41
|
-
authors.reduce([]) do |ret, a|
|
42
|
-
if a.at(ns('./name/completename'))
|
43
|
-
ret << a.at(ns('./name/completename')).text
|
44
|
-
else
|
45
|
-
fn = []
|
46
|
-
forenames = a.xpath(ns('./name/forename'))
|
47
|
-
forenames.each { |f| fn << f.text }
|
48
|
-
surname = a&.at(ns('./name/surname'))&.text
|
49
|
-
ret << fn.join(' ') + ' ' + surname
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def extract_person_affiliations(authors)
|
55
|
-
authors.reduce([]) do |m, a|
|
56
|
-
name = a&.at(ns('./affiliation/organization/name'))&.text
|
57
|
-
location = a&.at(ns('./affiliation/organization/address/'\
|
58
|
-
'formattedAddress'))&.text
|
59
|
-
m << (!name.nil? && !location.nil? ? "#{name}, #{location}" :
|
60
|
-
(name || location || ''))
|
61
|
-
m
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def extract_person_names_affiliations(authors)
|
66
|
-
names = extract_person_names(authors)
|
67
|
-
affils = extract_person_affiliations(authors)
|
68
|
-
ret = {}
|
69
|
-
affils.each_with_index do |a, i|
|
70
|
-
ret[a] ||= []
|
71
|
-
ret[a] << names[i]
|
72
|
-
end
|
73
|
-
ret
|
74
|
-
end
|
75
|
-
|
76
|
-
def personal_authors(isoxml)
|
77
|
-
authors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'author' "\
|
78
|
-
"or xmlns:role/@type = 'editor']/person"))
|
79
|
-
set(:authors, extract_person_names(authors))
|
80
|
-
set(:authors_affiliations, extract_person_names_affiliations(authors))
|
81
|
-
end
|
41
|
+
NOLANG = "[not(@language) or @language = '']".freeze
|
82
42
|
|
83
|
-
def
|
84
|
-
|
85
|
-
agency(xml)
|
86
|
-
end
|
87
|
-
|
88
|
-
def bibdate(isoxml, _out)
|
89
|
-
isoxml.xpath(ns('//bibdata/date')).each do |d|
|
90
|
-
set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
|
91
|
-
end
|
43
|
+
def currlang
|
44
|
+
"[@language = '#{@lang}']"
|
92
45
|
end
|
93
46
|
|
94
47
|
def doctype(isoxml, _out)
|
95
|
-
b = isoxml&.at(ns(
|
48
|
+
b = isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}"))&.text || return
|
96
49
|
set(:doctype, status_print(b))
|
97
|
-
|
98
|
-
set(:doctype_display, status_print(
|
99
|
-
end
|
100
|
-
|
101
|
-
def iso?(org)
|
102
|
-
name = org&.at(ns('./name'))&.text
|
103
|
-
abbrev = org&.at(ns('./abbreviation'))&.text
|
104
|
-
(abbrev == 'ISO' ||
|
105
|
-
name == 'International Organization for Standardization')
|
106
|
-
end
|
107
|
-
|
108
|
-
def agency1(xml)
|
109
|
-
agency = ''
|
110
|
-
publisher = []
|
111
|
-
xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
|
112
|
-
'organization')).each do |org|
|
113
|
-
name = org&.at(ns('./name'))&.text
|
114
|
-
agency1 = org&.at(ns('./abbreviation'))&.text || name
|
115
|
-
publisher << name if name
|
116
|
-
agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
|
117
|
-
end
|
118
|
-
[agency, publisher]
|
119
|
-
end
|
120
|
-
|
121
|
-
def agency(xml)
|
122
|
-
agency, publisher = agency1(xml)
|
123
|
-
set(:agency, agency.sub(%r{/$}, ''))
|
124
|
-
set(:publisher, @i18n.multiple_and(publisher, @labels['and']))
|
125
|
-
agency_addr(xml)
|
126
|
-
end
|
127
|
-
|
128
|
-
def agency_addr(xml)
|
129
|
-
a = xml.at(ns("//bibdata/contributor[xmlns:role/@type = 'publisher'][1]/"\
|
130
|
-
"organization")) or return
|
131
|
-
n = a.at(ns("./subdivision")) and set(:subdivision, n.text)
|
132
|
-
n = a.at(ns("./address/formattedAddress")) and
|
133
|
-
set(:pub_address, n.children.to_xml)
|
134
|
-
n = a.at(ns("./phone[not(@type = 'fax')]")) and set(:pub_phone, n.text)
|
135
|
-
n = a.at(ns("./phone[@type = 'fax']")) and set(:pub_fax, n.text)
|
136
|
-
n = a.at(ns("./email")) and set(:pub_email, n.text)
|
137
|
-
n = a.at(ns("./uri")) and set(:pub_uri, n.text)
|
50
|
+
b1 = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}"))&.text || b
|
51
|
+
set(:doctype_display, status_print(b1))
|
138
52
|
end
|
139
53
|
|
140
|
-
def docstatus(
|
54
|
+
def docstatus(xml, _out)
|
141
55
|
set(:unpublished, true)
|
142
|
-
return unless
|
143
|
-
|
144
|
-
set(:stage, status_print(
|
145
|
-
|
146
|
-
|
147
|
-
(i = isoxml&.at(ns('//bibdata/status/substage'))&.text) &&
|
56
|
+
return unless s = xml.at(ns("//bibdata/status/stage#{NOLANG}"))
|
57
|
+
s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
|
58
|
+
set(:stage, status_print(s.text))
|
59
|
+
s1 and set(:stage_display, status_print(s1.text))
|
60
|
+
(i = xml&.at(ns("//bibdata/status/substage#{NOLANG}"))&.text) and
|
148
61
|
set(:substage, i)
|
149
|
-
(
|
150
|
-
set(:substage_display,
|
151
|
-
(
|
152
|
-
set(:iteration,
|
153
|
-
set(:unpublished, unpublished(
|
154
|
-
unpublished(
|
155
|
-
set(:stageabbr, stage_abbr(docstatus.text))
|
62
|
+
(i1 = xml&.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
|
63
|
+
set(:substage_display, i1)
|
64
|
+
(i2 = xml&.at(ns('//bibdata/status/iteration'))&.text) and
|
65
|
+
set(:iteration, i2)
|
66
|
+
set(:unpublished, unpublished(s.text))
|
67
|
+
unpublished(s.text) && set(:stageabbr, stage_abbr(s.text))
|
156
68
|
end
|
157
69
|
|
158
70
|
def stage_abbr(docstatus)
|
@@ -172,6 +84,13 @@ module IsoDoc
|
|
172
84
|
set(:docnumber, dn&.text)
|
173
85
|
end
|
174
86
|
|
87
|
+
def otherid(isoxml, _out)
|
88
|
+
dn = isoxml.at(ns('//bibdata/docidentifier[@type = "ISBN"]'))
|
89
|
+
set(:isbn, dn&.text)
|
90
|
+
dn = isoxml.at(ns('//bibdata/docidentifier[@type = "ISBN10"]'))
|
91
|
+
set(:isbn10, dn&.text)
|
92
|
+
end
|
93
|
+
|
175
94
|
def docnumeric(isoxml, _out)
|
176
95
|
dn = isoxml.at(ns('//bibdata/docnumber'))
|
177
96
|
set(:docnumeric, dn&.text)
|
@@ -197,7 +116,7 @@ module IsoDoc
|
|
197
116
|
end
|
198
117
|
|
199
118
|
def title(isoxml, _out)
|
200
|
-
main = isoxml&.at(ns("//bibdata/title[@language='
|
119
|
+
main = isoxml&.at(ns("//bibdata/title[@language='#{@lang}']"))&.text
|
201
120
|
set(:doctitle, main)
|
202
121
|
end
|
203
122
|
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module IsoDoc
|
2
|
+
class Metadata
|
3
|
+
def extract_person_names(authors)
|
4
|
+
authors.reduce([]) do |ret, a|
|
5
|
+
if a.at(ns('./name/completename'))
|
6
|
+
ret << a.at(ns('./name/completename')).text
|
7
|
+
else
|
8
|
+
fn = []
|
9
|
+
forenames = a.xpath(ns('./name/forename'))
|
10
|
+
forenames.each { |f| fn << f.text }
|
11
|
+
surname = a&.at(ns('./name/surname'))&.text
|
12
|
+
ret << fn.join(' ') + ' ' + surname
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def extract_person_affiliations(authors)
|
18
|
+
authors.reduce([]) do |m, a|
|
19
|
+
name = a&.at(ns('./affiliation/organization/name'))&.text
|
20
|
+
subdivs = a&.xpath(ns('./affiliation/organization/subdivision'))&.map(&:text)&.join(", ")
|
21
|
+
name and subdivs and !subdivs.empty? and name = l10n("#{name}, #{subdivs}", @lang, @script)
|
22
|
+
location = a&.at(ns('./affiliation/organization/address/formattedAddress'))&.text
|
23
|
+
m << (!name.nil? && !location.nil? ? l10n("#{name}, #{location}", @lang, @script) :
|
24
|
+
(name || location || ''))
|
25
|
+
m
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def extract_person_names_affiliations(authors)
|
30
|
+
names = extract_person_names(authors)
|
31
|
+
affils = extract_person_affiliations(authors)
|
32
|
+
ret = {}
|
33
|
+
affils.each_with_index do |a, i|
|
34
|
+
ret[a] ||= []
|
35
|
+
ret[a] << names[i]
|
36
|
+
end
|
37
|
+
ret
|
38
|
+
end
|
39
|
+
|
40
|
+
def personal_authors(isoxml)
|
41
|
+
authors = isoxml.xpath(ns("//bibdata/contributor[role/@type = 'author' "\
|
42
|
+
"or xmlns:role/@type = 'editor']/person"))
|
43
|
+
set(:authors, extract_person_names(authors))
|
44
|
+
set(:authors_affiliations, extract_person_names_affiliations(authors))
|
45
|
+
end
|
46
|
+
|
47
|
+
def author(xml, _out)
|
48
|
+
personal_authors(xml)
|
49
|
+
agency(xml)
|
50
|
+
end
|
51
|
+
|
52
|
+
def iso?(org)
|
53
|
+
name = org&.at(ns('./name'))&.text
|
54
|
+
abbrev = org&.at(ns('./abbreviation'))&.text
|
55
|
+
(abbrev == 'ISO' ||
|
56
|
+
name == 'International Organization for Standardization')
|
57
|
+
end
|
58
|
+
|
59
|
+
def agency1(xml)
|
60
|
+
agency = ''
|
61
|
+
publisher = []
|
62
|
+
xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/"\
|
63
|
+
'organization')).each do |org|
|
64
|
+
name = org&.at(ns('./name'))&.text
|
65
|
+
agency1 = org&.at(ns('./abbreviation'))&.text || name
|
66
|
+
publisher << name if name
|
67
|
+
agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
|
68
|
+
end
|
69
|
+
[agency, publisher]
|
70
|
+
end
|
71
|
+
|
72
|
+
def agency(xml)
|
73
|
+
agency, publisher = agency1(xml)
|
74
|
+
set(:agency, agency.sub(%r{/$}, ''))
|
75
|
+
set(:publisher, @i18n.multiple_and(publisher, @labels['and']))
|
76
|
+
agency_addr(xml)
|
77
|
+
end
|
78
|
+
|
79
|
+
def agency_addr(xml)
|
80
|
+
a = xml.at(ns("//bibdata/contributor[xmlns:role/@type = 'publisher'][1]/"\
|
81
|
+
"organization")) or return
|
82
|
+
n = a.at(ns("./subdivision")) and set(:subdivision, n.text)
|
83
|
+
n = a.at(ns("./address/formattedAddress")) and
|
84
|
+
set(:pub_address, n.children.to_xml)
|
85
|
+
n = a.at(ns("./phone[not(@type = 'fax')]")) and set(:pub_phone, n.text)
|
86
|
+
n = a.at(ns("./phone[@type = 'fax']")) and set(:pub_fax, n.text)
|
87
|
+
n = a.at(ns("./email")) and set(:pub_email, n.text)
|
88
|
+
n = a.at(ns("./uri")) and set(:pub_uri, n.text)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/isodoc/metadata_date.rb
CHANGED
@@ -40,5 +40,11 @@ module IsoDoc
|
|
40
40
|
Date.parse(isodate).strftime("%B %d, %Y")
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def bibdate(isoxml, _out)
|
45
|
+
isoxml.xpath(ns('//bibdata/date')).each do |d|
|
46
|
+
set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
|
47
|
+
end
|
48
|
+
end
|
43
49
|
end
|
44
50
|
end
|
@@ -1,11 +1,22 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
3
|
def bibdata(docxml)
|
4
|
+
a = bibdata_current(docxml) or return
|
5
|
+
bibdata_i18n(a)
|
6
|
+
a.next =
|
7
|
+
"<localized-strings>#{i8n_name(trim_hash(@i18n.get), "").join("")}"\
|
8
|
+
"</localized-strings>"
|
9
|
+
end
|
10
|
+
|
11
|
+
def bibdata_current(docxml)
|
4
12
|
a = docxml.at(ns("//bibdata")) or return
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
a.
|
13
|
+
a.xpath(ns("./language")).each do |l|
|
14
|
+
l.text == @lang and l["current"] = "true"
|
15
|
+
end
|
16
|
+
a.xpath(ns("./script")).each do |l|
|
17
|
+
l.text == @script and l["current"] = "true"
|
18
|
+
end
|
19
|
+
a
|
9
20
|
end
|
10
21
|
|
11
22
|
def bibdata_i18n(b)
|
@@ -14,11 +25,72 @@ module IsoDoc
|
|
14
25
|
hash_translate(b, @i18n.get["substage_dict"], "./status/substage")
|
15
26
|
end
|
16
27
|
|
17
|
-
def hash_translate(bibdata, hash, xpath)
|
18
|
-
hash.is_a? Hash or return
|
28
|
+
def hash_translate(bibdata, hash, xpath, lang = @lang)
|
19
29
|
x = bibdata.at(ns(xpath)) or return
|
30
|
+
x["language"] = ""
|
31
|
+
hash.is_a? Hash or return
|
20
32
|
hash[x.text] or return
|
21
|
-
x.
|
33
|
+
x.next = x.dup
|
34
|
+
x.next["language"] = lang
|
35
|
+
x.next.children = hash[x.text]
|
36
|
+
end
|
37
|
+
|
38
|
+
def i18n_tag(k, v)
|
39
|
+
"<localized-string key='#{k}' language='#{@lang}'>#{v}</localized-string>"
|
40
|
+
end
|
41
|
+
|
42
|
+
def i18n_safe(k)
|
43
|
+
k.to_s.gsub(/\s|\./, "_")
|
44
|
+
end
|
45
|
+
|
46
|
+
def i8n_name(h, pref)
|
47
|
+
if h.is_a? Hash then i8n_name1(h, pref)
|
48
|
+
elsif h.is_a? Array
|
49
|
+
h.reject { |a| blank?(a) }.each_with_object([]).
|
50
|
+
with_index do |(v1, g), i|
|
51
|
+
i8n_name(v1, "#{i18n_safe(k)}.#{i}").each { |x| g << x }
|
52
|
+
end
|
53
|
+
else [i18n_tag(pref, h)]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def i8n_name1(h, pref)
|
58
|
+
h.reject { |k, v| blank?(v) }.each_with_object([]) do |(k, v), g|
|
59
|
+
if v.is_a? Hash then i8n_name(v, i18n_safe(k)).each { |x| g << x }
|
60
|
+
elsif v.is_a? Array
|
61
|
+
v.reject { |a| blank?(a) }.each_with_index do |v1, i|
|
62
|
+
i8n_name(v1, "#{i18n_safe(k)}.#{i}").each { |x| g << x }
|
63
|
+
end
|
64
|
+
else
|
65
|
+
g << i18n_tag("#{pref}#{pref.empty? ? "" : "."}#{i18n_safe(k)}", v)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#https://stackoverflow.com/a/31822406
|
71
|
+
def blank?(v)
|
72
|
+
v.nil? || v.respond_to?(:empty?) && v.empty?
|
73
|
+
end
|
74
|
+
|
75
|
+
def trim_hash(h)
|
76
|
+
loop do
|
77
|
+
h_new = trim_hash1(h)
|
78
|
+
break h if h==h_new
|
79
|
+
h = h_new
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def trim_hash1(h)
|
84
|
+
return h unless h.is_a? Hash
|
85
|
+
h.each_with_object({}) do |(k,v), g|
|
86
|
+
next if blank?(v)
|
87
|
+
g[k] = if v.is_a? Hash then trim_hash1(h[k])
|
88
|
+
elsif v.is_a? Array
|
89
|
+
h[k].map { |a| trim_hash1(a) }.reject { |a| blank?(a) }
|
90
|
+
else
|
91
|
+
v
|
92
|
+
end
|
93
|
+
end
|
22
94
|
end
|
23
95
|
end
|
24
96
|
end
|
@@ -1,5 +1,10 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
|
+
def lower2cap(s)
|
4
|
+
return s if /^[[:upper:]][[:upper:]]/.match(s)
|
5
|
+
s.capitalize
|
6
|
+
end
|
7
|
+
|
3
8
|
def figure(docxml)
|
4
9
|
docxml.xpath(ns("//figure")).each do |f|
|
5
10
|
figure1(f)
|
@@ -12,7 +17,7 @@ module IsoDoc
|
|
12
17
|
return if labelled_ancestor(f) && f.ancestors("figure").empty?
|
13
18
|
return if f.at(ns("./figure")) and !f.at(ns("./name"))
|
14
19
|
lbl = @xrefs.anchor(f['id'], :label, false) or return
|
15
|
-
prefix_name(f, " — ", l10n("#{@i18n.figure} #{lbl}"), "name")
|
20
|
+
prefix_name(f, " — ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
16
21
|
end
|
17
22
|
|
18
23
|
def prefix_name(f, delim, number, elem)
|
@@ -36,7 +41,7 @@ module IsoDoc
|
|
36
41
|
return if labelled_ancestor(f)
|
37
42
|
return unless f.ancestors("example").empty?
|
38
43
|
lbl = @xrefs.anchor(f['id'], :label, false) or return
|
39
|
-
prefix_name(f, " — ", l10n("#{@i18n.figure} #{lbl}"), "name")
|
44
|
+
prefix_name(f, " — ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
40
45
|
end
|
41
46
|
|
42
47
|
def formula(docxml)
|
@@ -65,7 +70,7 @@ module IsoDoc
|
|
65
70
|
|
66
71
|
def example1(f)
|
67
72
|
n = @xrefs.get[f["id"]]
|
68
|
-
lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example
|
73
|
+
lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example:
|
69
74
|
l10n("#{@i18n.example} #{n[:label]}")
|
70
75
|
prefix_name(f, " — ", lbl, "name")
|
71
76
|
end
|
@@ -81,7 +86,7 @@ module IsoDoc
|
|
81
86
|
return if f.parent.name == "bibitem"
|
82
87
|
n = @xrefs.get[f["id"]]
|
83
88
|
lbl = (@i18n.note if n.nil? || n[:label].nil? || n[:label].empty?) ?
|
84
|
-
@i18n.note
|
89
|
+
@i18n.note: l10n("#{@i18n.note} #{n[:label]}")
|
85
90
|
prefix_name(f, "", lbl, "name")
|
86
91
|
end
|
87
92
|
|
@@ -94,24 +99,24 @@ module IsoDoc
|
|
94
99
|
# introduce name element
|
95
100
|
def termnote1(f)
|
96
101
|
lbl = l10n(@xrefs.anchor(f['id'], :label) || '???')
|
97
|
-
prefix_name(f, "", lbl, "name")
|
102
|
+
prefix_name(f, "", lower2cap(lbl), "name")
|
98
103
|
end
|
99
104
|
|
100
105
|
def recommendation(docxml)
|
101
106
|
docxml.xpath(ns("//recommendation")).each do |f|
|
102
|
-
recommendation1(f, @i18n.recommendation)
|
107
|
+
recommendation1(f, lower2cap(@i18n.recommendation))
|
103
108
|
end
|
104
109
|
end
|
105
110
|
|
106
111
|
def requirement(docxml)
|
107
112
|
docxml.xpath(ns("//requirement")).each do |f|
|
108
|
-
recommendation1(f, @i18n.requirement)
|
113
|
+
recommendation1(f, lower2cap(@i18n.requirement))
|
109
114
|
end
|
110
115
|
end
|
111
116
|
|
112
117
|
def permission(docxml)
|
113
118
|
docxml.xpath(ns("//permission")).each do |f|
|
114
|
-
recommendation1(f, @i18n.permission)
|
119
|
+
recommendation1(f, lower2cap(@i18n.permission))
|
115
120
|
end
|
116
121
|
end
|
117
122
|
|
@@ -132,7 +137,7 @@ module IsoDoc
|
|
132
137
|
return if labelled_ancestor(f)
|
133
138
|
return if f["unnumbered"] && !f.at(ns("./name"))
|
134
139
|
n = @xrefs.anchor(f['id'], :label, false)
|
135
|
-
prefix_name(f, " — ", l10n("#{@i18n.table} #{n}"), "name")
|
140
|
+
prefix_name(f, " — ", l10n("#{lower2cap @i18n.table} #{n}"), "name")
|
136
141
|
end
|
137
142
|
|
138
143
|
# we use this to eliminate the semantic amend blocks from rendering
|