isodoc 1.5.5 → 1.6.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/.github/workflows/rake.yml +2 -12
- data/.hound.yml +3 -1
- data/.rubocop.yml +3 -7
- data/Gemfile +2 -2
- data/Rakefile +2 -2
- data/bin/rspec +1 -2
- data/isodoc.gemspec +11 -11
- data/lib/isodoc-yaml/i18n-ar.yaml +152 -0
- data/lib/isodoc-yaml/i18n-de.yaml +149 -0
- data/lib/isodoc-yaml/i18n-es.yaml +151 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +154 -0
- data/lib/isodoc.rb +0 -2
- data/lib/isodoc/base_style/all.css +7 -0
- data/lib/isodoc/base_style/metanorma_word.css +7 -0
- data/lib/isodoc/base_style/metanorma_word.scss +8 -0
- data/lib/isodoc/base_style/reset.css +7 -0
- data/lib/isodoc/base_style/reset.scss +9 -0
- data/lib/isodoc/base_style/scripts.html +187 -0
- data/lib/isodoc/class_utils.rb +6 -5
- data/lib/isodoc/common.rb +2 -0
- data/lib/isodoc/convert.rb +30 -17
- data/lib/isodoc/css.rb +43 -34
- data/lib/isodoc/function/blocks.rb +21 -4
- data/lib/isodoc/function/blocks_example_note.rb +2 -2
- data/lib/isodoc/function/cleanup.rb +53 -45
- data/lib/isodoc/function/form.rb +51 -0
- data/lib/isodoc/function/inline.rb +37 -15
- data/lib/isodoc/function/references.rb +55 -42
- data/lib/isodoc/function/section.rb +29 -16
- data/lib/isodoc/function/table.rb +1 -0
- data/lib/isodoc/function/to_word_html.rb +33 -29
- data/lib/isodoc/function/utils.rb +180 -159
- data/lib/isodoc/gem_tasks.rb +30 -31
- data/lib/isodoc/headlesshtml_convert.rb +8 -7
- data/lib/isodoc/html_convert.rb +6 -4
- data/lib/isodoc/html_function/comments.rb +2 -0
- data/lib/isodoc/html_function/footnotes.rb +14 -7
- data/lib/isodoc/html_function/form.rb +62 -0
- data/lib/isodoc/html_function/html.rb +30 -26
- data/lib/isodoc/html_function/postprocess.rb +41 -82
- data/lib/isodoc/html_function/postprocess_footnotes.rb +59 -0
- data/lib/isodoc/i18n.rb +33 -31
- data/lib/isodoc/pdf_convert.rb +12 -16
- data/lib/isodoc/presentation_function/bibdata.rb +54 -30
- data/lib/isodoc/presentation_function/block.rb +17 -8
- data/lib/isodoc/presentation_function/inline.rb +84 -120
- data/lib/isodoc/presentation_function/math.rb +84 -0
- data/lib/isodoc/presentation_function/section.rb +20 -22
- data/lib/isodoc/presentation_xml_convert.rb +2 -1
- data/lib/isodoc/sassc_importer.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +28 -24
- data/lib/isodoc/word_function/footnotes.rb +22 -15
- data/lib/isodoc/word_function/postprocess.rb +50 -36
- data/lib/isodoc/xref.rb +9 -10
- data/lib/isodoc/xref/xref_counter.rb +32 -17
- data/lib/isodoc/xref/xref_gen.rb +33 -21
- data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
- data/lib/isodoc/xref/xref_sect_gen.rb +37 -35
- data/lib/isodoc/xslfo_convert.rb +36 -27
- data/spec/assets/scripts_override.html +3 -0
- data/spec/isodoc/blocks_spec.rb +2490 -2591
- data/spec/isodoc/cleanup_spec.rb +1107 -1109
- data/spec/isodoc/footnotes_spec.rb +1 -16
- data/spec/isodoc/form_spec.rb +156 -0
- data/spec/isodoc/i18n_spec.rb +984 -972
- data/spec/isodoc/inline_spec.rb +1129 -912
- data/spec/isodoc/lists_spec.rb +316 -315
- data/spec/isodoc/postproc_spec.rb +1751 -1540
- data/spec/isodoc/presentation_xml_spec.rb +403 -323
- data/spec/isodoc/ref_spec.rb +718 -723
- data/spec/isodoc/section_spec.rb +910 -902
- data/spec/isodoc/table_spec.rb +566 -556
- data/spec/isodoc/terms_spec.rb +251 -255
- data/spec/isodoc/xref_spec.rb +3041 -2992
- data/spec/isodoc/xslfo_convert_spec.rb +39 -0
- data/spec/spec_helper.rb +30 -29
- metadata +77 -65
@@ -0,0 +1,59 @@
|
|
1
|
+
module IsoDoc::HtmlFunction
|
2
|
+
module Html
|
3
|
+
def update_footnote_filter(fn, x, i, seen)
|
4
|
+
if seen[fn.text]
|
5
|
+
x.at("./sup").content = seen[fn.text][:num].to_s
|
6
|
+
fn.remove unless x["href"] == seen[fn.text][:href]
|
7
|
+
x["href"] = seen[fn.text][:href]
|
8
|
+
else
|
9
|
+
seen[fn.text] = { num: i, href: x["href"] }
|
10
|
+
x.at("./sup").content = i.to_s
|
11
|
+
i += 1
|
12
|
+
end
|
13
|
+
[i, seen]
|
14
|
+
end
|
15
|
+
|
16
|
+
def html_footnote_filter(docxml)
|
17
|
+
seen = {}
|
18
|
+
i = 1
|
19
|
+
docxml.xpath('//a[@class = "FootnoteRef"]').each do |x|
|
20
|
+
fn = docxml.at(%<//*[@id = '#{x['href'].sub(/^#/, '')}']>) || next
|
21
|
+
i, seen = update_footnote_filter(fn, x, i, seen)
|
22
|
+
end
|
23
|
+
docxml
|
24
|
+
end
|
25
|
+
|
26
|
+
def footnote_backlinks1(x, fn)
|
27
|
+
xdup = x.dup
|
28
|
+
xdup.remove["id"]
|
29
|
+
if fn.elements.empty?
|
30
|
+
fn.children.first.previous = xdup
|
31
|
+
else
|
32
|
+
fn.elements.first.children.first.previous = xdup
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def footnote_backlinks(docxml)
|
37
|
+
seen = {}
|
38
|
+
docxml.xpath('//a[@class = "FootnoteRef"]').each_with_index do |x, i|
|
39
|
+
seen[x["href"]] and next or seen[x["href"]] = true
|
40
|
+
fn = docxml.at(%<//*[@id = '#{x['href'].sub(/^#/, '')}']>) || next
|
41
|
+
footnote_backlinks1(x, fn)
|
42
|
+
x["id"] ||= "fnref:#{i + 1}"
|
43
|
+
fn.add_child "<a href='##{x['id']}'>↩</a>"
|
44
|
+
end
|
45
|
+
docxml
|
46
|
+
end
|
47
|
+
|
48
|
+
def footnote_format(docxml)
|
49
|
+
docxml.xpath("//a[@class = 'FootnoteRef']/sup").each do |x|
|
50
|
+
footnote_reference_format(x)
|
51
|
+
end
|
52
|
+
docxml.xpath("//a[@class = 'TableFootnoteRef'] | "\
|
53
|
+
"//span[@class = 'TableFootnoteRef']").each do |x|
|
54
|
+
table_footnote_reference_format(x)
|
55
|
+
end
|
56
|
+
docxml
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/isodoc/i18n.rb
CHANGED
@@ -5,44 +5,47 @@ module IsoDoc
|
|
5
5
|
def load_yaml(lang, script, i18nyaml = nil)
|
6
6
|
ret = load_yaml1(lang, script)
|
7
7
|
return normalise_hash(ret.merge(YAML.load_file(i18nyaml))) if i18nyaml
|
8
|
+
|
8
9
|
normalise_hash(ret)
|
9
10
|
end
|
10
11
|
|
11
12
|
def normalise_hash(ret)
|
12
|
-
|
13
|
+
case ret
|
14
|
+
when Hash
|
13
15
|
ret.each do |k, v|
|
14
16
|
ret[k] = normalise_hash(v)
|
15
17
|
end
|
16
18
|
ret
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
ret
|
19
|
+
when Array then ret.map { |n| normalise_hash(n) }
|
20
|
+
when String then ret.unicode_normalize(:nfc)
|
21
|
+
else ret
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def load_yaml1(lang, script)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
YAML.load_file(File.join(File.dirname(__FILE__),
|
33
|
-
"../isodoc-yaml/i18n-zh-Hans.yaml"))
|
26
|
+
case lang
|
27
|
+
when "en", "fr", "ru", "de", "es", "ar"
|
28
|
+
load_yaml2(lang)
|
29
|
+
when "zh"
|
30
|
+
if script == "Hans" then load_yaml2("zh-Hans")
|
31
|
+
else load_yaml2("en")
|
32
|
+
end
|
34
33
|
else
|
35
|
-
|
36
|
-
"../isodoc-yaml/i18n-en.yaml"))
|
34
|
+
load_yaml2("en")
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
38
|
+
def load_yaml2(str)
|
39
|
+
YAML.load_file(File.join(File.dirname(__FILE__),
|
40
|
+
"../isodoc-yaml/i18n-#{str}.yaml"))
|
41
|
+
end
|
42
|
+
|
40
43
|
def get
|
41
44
|
@labels
|
42
45
|
end
|
43
46
|
|
44
|
-
def set(
|
45
|
-
@labels[
|
47
|
+
def set(key, val)
|
48
|
+
@labels[key] = val
|
46
49
|
end
|
47
50
|
|
48
51
|
def initialize(lang, script, i18nyaml = nil)
|
@@ -57,37 +60,36 @@ module IsoDoc
|
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
60
|
-
def self.l10n(
|
61
|
-
l10n(
|
63
|
+
def self.l10n(text, lang = @lang, script = @script)
|
64
|
+
l10n(text, lang, script)
|
62
65
|
end
|
63
66
|
|
64
67
|
# TODO: move to localization file
|
65
68
|
# function localising spaces and punctuation.
|
66
69
|
# Not clear if period needs to be localised for zh
|
67
|
-
def l10n(
|
70
|
+
def l10n(text, lang = @lang, script = @script)
|
68
71
|
if lang == "zh" && script == "Hans"
|
69
|
-
xml = Nokogiri::HTML::DocumentFragment.parse(
|
72
|
+
xml = Nokogiri::HTML::DocumentFragment.parse(text)
|
70
73
|
xml.traverse do |n|
|
71
74
|
next unless n.text?
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
|
76
|
+
n.replace(n.text.gsub(/ /, "").gsub(/:/, ":").gsub(/,/, "、")
|
77
|
+
.gsub(/\(/, "(").gsub(/\)/, ")").gsub(/\[/, "【").gsub(/\]/, "】"))
|
75
78
|
end
|
76
79
|
xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
|
77
|
-
else
|
78
|
-
x
|
80
|
+
else text
|
79
81
|
end
|
80
82
|
end
|
81
83
|
|
82
84
|
def multiple_and(names, andword)
|
83
|
-
return
|
85
|
+
return "" if names.empty?
|
84
86
|
return names[0] if names.length == 1
|
87
|
+
|
85
88
|
(names.length == 2) &&
|
86
89
|
(return l10n("#{names[0]} #{andword} #{names[1]}", @lang, @script))
|
87
|
-
l10n(names[0..-2].join(
|
90
|
+
l10n(names[0..-2].join(", ") + " #{andword} #{names[-1]}", @lang, @script)
|
88
91
|
end
|
89
92
|
|
90
|
-
#module_function :l10n
|
91
|
-
|
93
|
+
# module_function :l10n
|
92
94
|
end
|
93
95
|
end
|
data/lib/isodoc/pdf_convert.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require_relative "html_function/comments
|
2
|
-
require_relative "html_function/footnotes
|
3
|
-
require_relative "html_function/html
|
1
|
+
require_relative "html_function/comments"
|
2
|
+
require_relative "html_function/footnotes"
|
3
|
+
require_relative "html_function/html"
|
4
4
|
require "metanorma"
|
5
5
|
|
6
6
|
module IsoDoc
|
7
7
|
class PdfConvert < ::IsoDoc::Convert
|
8
|
-
|
9
8
|
include HtmlFunction::Comments
|
10
9
|
include HtmlFunction::Footnotes
|
11
10
|
include HtmlFunction::Html
|
@@ -13,6 +12,8 @@ module IsoDoc
|
|
13
12
|
def initialize(options)
|
14
13
|
@standardstylesheet = nil
|
15
14
|
super
|
15
|
+
@format = :pdf
|
16
|
+
@suffix = "pdf"
|
16
17
|
@scripts = @scripts_pdf if @scripts_pdf
|
17
18
|
@maxwidth = 500
|
18
19
|
@maxheight = 800
|
@@ -22,29 +23,24 @@ module IsoDoc
|
|
22
23
|
"_pdfimages"
|
23
24
|
end
|
24
25
|
|
25
|
-
def initialize(options)
|
26
|
-
@format = :pdf
|
27
|
-
@suffix = "pdf"
|
28
|
-
super
|
29
|
-
end
|
30
|
-
|
31
26
|
def convert(input_filename, file = nil, debug = false, output_filename = nil)
|
32
27
|
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
33
28
|
@openmathdelim, @closemathdelim = extract_delims(file)
|
34
29
|
docxml, filename, dir = convert_init(file, input_filename, debug)
|
35
30
|
result = convert1(docxml, filename, dir)
|
36
31
|
return result if debug
|
37
|
-
|
32
|
+
|
33
|
+
postprocess(result, "#{filename}.tmp.html", dir)
|
38
34
|
FileUtils.rm_rf dir
|
39
|
-
::Metanorma::Output::Pdf.new.convert(
|
40
|
-
|
35
|
+
::Metanorma::Output::Pdf.new.convert(
|
36
|
+
"#{filename}.tmp.html",
|
37
|
+
output_filename || "#{filename}.#{@suffix}",
|
38
|
+
)
|
41
39
|
FileUtils.rm_rf ["#{filename}.tmp.html", tmpimagedir]
|
42
40
|
end
|
43
41
|
|
44
42
|
def xref_parse(node, out)
|
45
|
-
|
46
|
-
"##{node["target"]}"
|
47
|
-
out.a(**{ "href": target }) { |l| l << get_linkend(node) }
|
43
|
+
out.a(**{ "href": target_pdf(node) }) { |l| l << get_linkend(node) }
|
48
44
|
end
|
49
45
|
end
|
50
46
|
end
|
@@ -2,12 +2,32 @@ module IsoDoc
|
|
2
2
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
3
3
|
def bibdata(docxml)
|
4
4
|
a = bibdata_current(docxml) or return
|
5
|
+
address_precompose(a)
|
5
6
|
bibdata_i18n(a)
|
6
7
|
a.next =
|
7
|
-
"<localized-strings>#{i8n_name(trim_hash(@i18n.get),
|
8
|
+
"<localized-strings>#{i8n_name(trim_hash(@i18n.get), '').join('')}"\
|
8
9
|
"</localized-strings>"
|
9
10
|
end
|
10
11
|
|
12
|
+
def address_precompose(bib)
|
13
|
+
bib.xpath(ns("//bibdata//address")).each do |b|
|
14
|
+
next if b.at(ns("./formattedAddress"))
|
15
|
+
|
16
|
+
x = address_precompose1(b)
|
17
|
+
b.children = "<formattedAddress>#{x}</formattedAddress>"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def address_precompose1(addr)
|
22
|
+
ret = []
|
23
|
+
addr.xpath(ns("./street")).each { |s| ret << s.children.to_xml }
|
24
|
+
a = addr.at(ns("./city")) and ret << a.children.to_xml
|
25
|
+
addr.xpath(ns("./state")).each { |s| ret << s.children.to_xml }
|
26
|
+
a = addr.at(ns("./country")) and ret << a.children.to_xml
|
27
|
+
a = addr.at(ns("./postcode")) and ret[-1] += " #{a.children.to_xml}"
|
28
|
+
ret.join("<br/>")
|
29
|
+
end
|
30
|
+
|
11
31
|
def bibdata_current(docxml)
|
12
32
|
a = docxml.at(ns("//bibdata")) or return
|
13
33
|
a.xpath(ns("./language")).each do |l|
|
@@ -19,10 +39,10 @@ module IsoDoc
|
|
19
39
|
a
|
20
40
|
end
|
21
41
|
|
22
|
-
def bibdata_i18n(
|
23
|
-
hash_translate(
|
24
|
-
hash_translate(
|
25
|
-
hash_translate(
|
42
|
+
def bibdata_i18n(bib)
|
43
|
+
hash_translate(bib, @i18n.get["doctype_dict"], "./ext/doctype")
|
44
|
+
hash_translate(bib, @i18n.get["stage_dict"], "./status/stage")
|
45
|
+
hash_translate(bib, @i18n.get["substage_dict"], "./status/substage")
|
26
46
|
end
|
27
47
|
|
28
48
|
def hash_translate(bibdata, hash, xpath, lang = @lang)
|
@@ -35,58 +55,62 @@ module IsoDoc
|
|
35
55
|
x.next.children = hash[x.text]
|
36
56
|
end
|
37
57
|
|
38
|
-
def i18n_tag(
|
39
|
-
"<localized-string key='#{
|
58
|
+
def i18n_tag(key, value)
|
59
|
+
"<localized-string key='#{key}' language='#{@lang}'>#{value}"\
|
60
|
+
"</localized-string>"
|
40
61
|
end
|
41
62
|
|
42
|
-
def i18n_safe(
|
43
|
-
|
63
|
+
def i18n_safe(key)
|
64
|
+
key.to_s.gsub(/\s|\./, "_")
|
44
65
|
end
|
45
66
|
|
46
|
-
def i8n_name(
|
47
|
-
if
|
48
|
-
elsif
|
49
|
-
|
50
|
-
with_index do |(v1, g), i|
|
67
|
+
def i8n_name(hash, pref)
|
68
|
+
if hash.is_a? Hash then i8n_name1(hash, pref)
|
69
|
+
elsif hash.is_a? Array
|
70
|
+
hash.reject { |a| blank?(a) }.each_with_object([])
|
71
|
+
.with_index do |(v1, g), i|
|
51
72
|
i8n_name(v1, "#{i18n_safe(k)}.#{i}").each { |x| g << x }
|
52
73
|
end
|
53
|
-
else [i18n_tag(pref,
|
74
|
+
else [i18n_tag(pref, hash)]
|
54
75
|
end
|
55
76
|
end
|
56
77
|
|
57
|
-
def i8n_name1(
|
58
|
-
|
78
|
+
def i8n_name1(hash, pref)
|
79
|
+
hash.reject { |_k, v| blank?(v) }.each_with_object([]) do |(k, v), g|
|
59
80
|
if v.is_a? Hash then i8n_name(v, i18n_safe(k)).each { |x| g << x }
|
60
81
|
elsif v.is_a? Array
|
61
82
|
v.reject { |a| blank?(a) }.each_with_index do |v1, i|
|
62
83
|
i8n_name(v1, "#{i18n_safe(k)}.#{i}").each { |x| g << x }
|
63
84
|
end
|
64
85
|
else
|
65
|
-
g << i18n_tag("#{pref}#{pref.empty? ?
|
86
|
+
g << i18n_tag("#{pref}#{pref.empty? ? '' : '.'}#{i18n_safe(k)}", v)
|
66
87
|
end
|
67
88
|
end
|
68
89
|
end
|
69
90
|
|
70
|
-
#https://stackoverflow.com/a/31822406
|
71
|
-
def blank?(
|
72
|
-
|
91
|
+
# https://stackoverflow.com/a/31822406
|
92
|
+
def blank?(elem)
|
93
|
+
elem.nil? || elem.respond_to?(:empty?) && elem.empty?
|
73
94
|
end
|
74
95
|
|
75
|
-
def trim_hash(
|
96
|
+
def trim_hash(hash)
|
76
97
|
loop do
|
77
|
-
h_new = trim_hash1(
|
78
|
-
break
|
79
|
-
|
98
|
+
h_new = trim_hash1(hash)
|
99
|
+
break hash if hash == h_new
|
100
|
+
|
101
|
+
hash = h_new
|
80
102
|
end
|
81
103
|
end
|
82
104
|
|
83
|
-
def trim_hash1(
|
84
|
-
return
|
85
|
-
|
105
|
+
def trim_hash1(hash)
|
106
|
+
return hash unless hash.is_a? Hash
|
107
|
+
|
108
|
+
hash.each_with_object({}) do |(k, v), g|
|
86
109
|
next if blank?(v)
|
87
|
-
|
110
|
+
|
111
|
+
g[k] = if v.is_a? Hash then trim_hash1(hash[k])
|
88
112
|
elsif v.is_a? Array
|
89
|
-
|
113
|
+
hash[k].map { |a| trim_hash1(a) }.reject { |a| blank?(a) }
|
90
114
|
else
|
91
115
|
v
|
92
116
|
end
|
@@ -3,7 +3,8 @@ require "base64"
|
|
3
3
|
module IsoDoc
|
4
4
|
class PresentationXMLConvert < ::IsoDoc::Convert
|
5
5
|
def lower2cap(s)
|
6
|
-
return s if /^[[:upper:]][[:upper:]]/.match(s)
|
6
|
+
return s if /^[[:upper:]][[:upper:]]/.match?(s)
|
7
|
+
|
7
8
|
s.capitalize
|
8
9
|
end
|
9
10
|
|
@@ -19,8 +20,10 @@ module IsoDoc
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def svg_extract(f)
|
22
|
-
return unless %r{^data:image/svg\+xml;base64,}.match(f["src"])
|
23
|
-
|
23
|
+
return unless %r{^data:image/svg\+xml;base64,}.match?(f["src"])
|
24
|
+
|
25
|
+
svg = Base64.strict_decode64(f["src"]
|
26
|
+
.sub(%r{^data:image/svg\+xml;base64,}, ""))
|
24
27
|
f.replace(svg.sub(/<\?xml[^>]*>/, ""))
|
25
28
|
end
|
26
29
|
|
@@ -28,12 +31,15 @@ module IsoDoc
|
|
28
31
|
return sourcecode1(f) if f["class"] == "pseudocode" || f["type"] == "pseudocode"
|
29
32
|
return if labelled_ancestor(f) && f.ancestors("figure").empty?
|
30
33
|
return if f.at(ns("./figure")) and !f.at(ns("./name"))
|
34
|
+
|
31
35
|
lbl = @xrefs.anchor(f['id'], :label, false) or return
|
32
|
-
prefix_name(f, " — ",
|
36
|
+
prefix_name(f, " — ",
|
37
|
+
l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
33
38
|
end
|
34
39
|
|
35
40
|
def prefix_name(f, delim, number, elem)
|
36
41
|
return if number.nil? || number.empty?
|
42
|
+
|
37
43
|
unless name = f.at(ns("./#{elem}"))
|
38
44
|
f.children.empty? and f.add_child("<#{elem}></#{elem}>") or
|
39
45
|
f.children.first.previous = "<#{elem}></#{elem}>"
|
@@ -52,6 +58,7 @@ module IsoDoc
|
|
52
58
|
def sourcecode1(f)
|
53
59
|
return if labelled_ancestor(f)
|
54
60
|
return unless f.ancestors("example").empty?
|
61
|
+
|
55
62
|
lbl = @xrefs.anchor(f['id'], :label, false) or return
|
56
63
|
prefix_name(f, " — ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
|
57
64
|
end
|
@@ -96,6 +103,7 @@ module IsoDoc
|
|
96
103
|
# introduce name element
|
97
104
|
def note1(f)
|
98
105
|
return if f.parent.name == "bibitem"
|
106
|
+
|
99
107
|
n = @xrefs.get[f["id"]]
|
100
108
|
lbl = (@i18n.note if n.nil? || n[:label].nil? || n[:label].empty?) ?
|
101
109
|
@i18n.note: l10n("#{@i18n.note} #{n[:label]}")
|
@@ -110,7 +118,7 @@ module IsoDoc
|
|
110
118
|
|
111
119
|
# introduce name element
|
112
120
|
def termnote1(f)
|
113
|
-
lbl = l10n(@xrefs.anchor(f[
|
121
|
+
lbl = l10n(@xrefs.anchor(f["id"], :label) || "???")
|
114
122
|
prefix_name(f, "", lower2cap(lbl), "name")
|
115
123
|
end
|
116
124
|
|
@@ -134,7 +142,7 @@ module IsoDoc
|
|
134
142
|
|
135
143
|
# introduce name element
|
136
144
|
def recommendation1(f, type)
|
137
|
-
n = @xrefs.anchor(f[
|
145
|
+
n = @xrefs.anchor(f["id"], :label, false)
|
138
146
|
lbl = (n.nil? ? type : l10n("#{type} #{n}"))
|
139
147
|
prefix_name(f, "", lbl, "name")
|
140
148
|
end
|
@@ -148,7 +156,8 @@ module IsoDoc
|
|
148
156
|
def table1(f)
|
149
157
|
return if labelled_ancestor(f)
|
150
158
|
return if f["unnumbered"] && !f.at(ns("./name"))
|
151
|
-
|
159
|
+
|
160
|
+
n = @xrefs.anchor(f["id"], :label, false)
|
152
161
|
prefix_name(f, " — ", l10n("#{lower2cap @i18n.table} #{n}"), "name")
|
153
162
|
end
|
154
163
|
|
@@ -160,7 +169,7 @@ module IsoDoc
|
|
160
169
|
end
|
161
170
|
|
162
171
|
def amend1(f)
|
163
|
-
f.xpath(ns("./autonumber")).each
|
172
|
+
f.xpath(ns("./autonumber")).each(&:remove)
|
164
173
|
f.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
|
165
174
|
f.xpath(ns("./description")).each { |a| a.replace(a.children) }
|
166
175
|
f.replace(f.children)
|