isodoc 1.6.0 → 1.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +2 -12
  3. data/.hound.yml +3 -1
  4. data/.rubocop.yml +4 -8
  5. data/Rakefile +2 -2
  6. data/bin/rspec +1 -2
  7. data/isodoc.gemspec +4 -3
  8. data/lib/isodoc-yaml/i18n-ar.yaml +152 -0
  9. data/lib/isodoc-yaml/i18n-de.yaml +149 -0
  10. data/lib/isodoc-yaml/i18n-en.yaml +1 -0
  11. data/lib/isodoc-yaml/i18n-es.yaml +151 -0
  12. data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
  13. data/lib/isodoc-yaml/i18n-ru.yaml +154 -0
  14. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
  15. data/lib/isodoc.rb +0 -2
  16. data/lib/isodoc/common.rb +2 -0
  17. data/lib/isodoc/convert.rb +10 -4
  18. data/lib/isodoc/css.rb +30 -26
  19. data/lib/isodoc/function/blocks.rb +26 -8
  20. data/lib/isodoc/function/blocks_example_note.rb +2 -2
  21. data/lib/isodoc/function/cleanup.rb +53 -45
  22. data/lib/isodoc/function/form.rb +51 -0
  23. data/lib/isodoc/function/inline.rb +8 -7
  24. data/lib/isodoc/function/references.rb +71 -77
  25. data/lib/isodoc/function/section.rb +28 -16
  26. data/lib/isodoc/function/table.rb +22 -22
  27. data/lib/isodoc/function/terms.rb +6 -7
  28. data/lib/isodoc/function/to_word_html.rb +19 -25
  29. data/lib/isodoc/function/utils.rb +180 -160
  30. data/lib/isodoc/gem_tasks.rb +36 -38
  31. data/lib/isodoc/headlesshtml_convert.rb +8 -7
  32. data/lib/isodoc/html_convert.rb +10 -4
  33. data/lib/isodoc/html_function/comments.rb +14 -12
  34. data/lib/isodoc/html_function/footnotes.rb +14 -7
  35. data/lib/isodoc/html_function/form.rb +62 -0
  36. data/lib/isodoc/html_function/html.rb +30 -26
  37. data/lib/isodoc/html_function/postprocess.rb +191 -226
  38. data/lib/isodoc/html_function/postprocess_footnotes.rb +59 -0
  39. data/lib/isodoc/html_function/sectionsplit.rb +230 -0
  40. data/lib/isodoc/i18n.rb +33 -31
  41. data/lib/isodoc/metadata.rb +22 -20
  42. data/lib/isodoc/metadata_contributor.rb +31 -28
  43. data/lib/isodoc/pdf_convert.rb +11 -13
  44. data/lib/isodoc/presentation_function/bibdata.rb +54 -30
  45. data/lib/isodoc/presentation_function/block.rb +17 -8
  46. data/lib/isodoc/presentation_function/inline.rb +72 -120
  47. data/lib/isodoc/presentation_function/math.rb +84 -0
  48. data/lib/isodoc/presentation_function/section.rb +55 -19
  49. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  50. data/lib/isodoc/sassc_importer.rb +1 -1
  51. data/lib/isodoc/version.rb +1 -1
  52. data/lib/isodoc/word_function/body.rb +28 -24
  53. data/lib/isodoc/word_function/footnotes.rb +22 -15
  54. data/lib/isodoc/word_function/postprocess.rb +50 -36
  55. data/lib/isodoc/xref.rb +11 -10
  56. data/lib/isodoc/xref/xref_counter.rb +32 -17
  57. data/lib/isodoc/xref/xref_gen.rb +33 -21
  58. data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
  59. data/lib/isodoc/xref/xref_sect_gen.rb +37 -35
  60. data/spec/assets/scripts_override.html +3 -0
  61. data/spec/isodoc/blocks_spec.rb +2258 -2622
  62. data/spec/isodoc/cleanup_spec.rb +1103 -1107
  63. data/spec/isodoc/form_spec.rb +156 -0
  64. data/spec/isodoc/i18n_spec.rb +802 -917
  65. data/spec/isodoc/inline_spec.rb +1105 -921
  66. data/spec/isodoc/lists_spec.rb +316 -315
  67. data/spec/isodoc/metadata_spec.rb +384 -379
  68. data/spec/isodoc/postproc_spec.rb +1783 -1549
  69. data/spec/isodoc/presentation_xml_spec.rb +355 -278
  70. data/spec/isodoc/ref_spec.rb +718 -723
  71. data/spec/isodoc/section_spec.rb +216 -199
  72. data/spec/isodoc/sectionsplit_spec.rb +190 -0
  73. data/spec/isodoc/table_spec.rb +41 -42
  74. data/spec/isodoc/terms_spec.rb +84 -84
  75. data/spec/isodoc/xref_spec.rb +1024 -930
  76. metadata +33 -7
@@ -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']}'>&#x21A9;</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
@@ -0,0 +1,230 @@
1
+ require "metanorma"
2
+ require "yaml"
3
+
4
+ module IsoDoc::HtmlFunction
5
+ module Html
6
+ # assume we pass in Presentation XML, but we want to recover Semantic XML
7
+ def sectionsplit_convert(input_filename, file, debug, output_filename = nil)
8
+ input_filename += ".xml" unless input_filename.match?(/\.xml$/)
9
+ File.exist?(input_filename) or
10
+ File.open(input_filename, "w:UTF-8") { |f| f.write(file) }
11
+ presxml = File.read(input_filename, encoding: "utf-8")
12
+ @openmathdelim, @closemathdelim = extract_delims(presxml)
13
+ xml, filename, dir = convert_init(presxml, input_filename, debug)
14
+ build_collection(xml, presxml, output_filename || filename, dir)
15
+ end
16
+
17
+ def build_collection(xml, presxml, filename, dir)
18
+ base = File.basename(filename)
19
+ collection_setup(base, dir)
20
+ files = sectionsplit(xml, base, dir)
21
+ collection_manifest(base, files, xml, presxml, dir).render(
22
+ format: %i(html), output_folder: "#{filename}_collection",
23
+ coverpage: File.join(dir, "cover.html")
24
+ )
25
+ end
26
+
27
+ def collection_manifest(filename, files, origxml, _presxml, dir)
28
+ File.open(File.join(dir, "#{filename}.html.yaml"), "w:UTF-8") do |f|
29
+ f.write(collectionyaml(files, origxml))
30
+ end
31
+ Metanorma::Collection.parse File.join(dir, "#{filename}.html.yaml")
32
+ end
33
+
34
+ def collection_setup(filename, dir)
35
+ FileUtils.mkdir_p "#{filename}_collection"
36
+ FileUtils.mkdir_p dir
37
+ File.open(File.join(dir, "cover.html"), "w:UTF-8") do |f|
38
+ f.write(coll_cover)
39
+ end
40
+ end
41
+
42
+ def coll_cover
43
+ <<~COVER
44
+ <html>
45
+ <head/>
46
+ <body>
47
+ <h1>{{ doctitle }}</h1>
48
+ <h2>{{ docnumber }}</h2>
49
+ <nav>{{ labels["navigation"] }}</nav>
50
+ </body>
51
+ </html>
52
+ COVER
53
+ end
54
+
55
+ def sectionsplit(xml, filename, dir)
56
+ xref_preprocess(xml)
57
+ out = emptydoc(xml)
58
+ [["//preface/*", "preface"], ["//sections/*", "sections"],
59
+ ["//annex", nil],
60
+ ["//bibliography/*[not(@hidden = 'true')]", "bibliography"],
61
+ ["//indexsect", nil]].each_with_object([]) do |n, ret|
62
+ xml.xpath(ns(n[0])).each do |s|
63
+ ret << sectionfile(out, dir, "#{filename}.#{ret.size}", s, n[1])
64
+ end
65
+ end
66
+ end
67
+
68
+ def emptydoc(xml)
69
+ out = xml.dup
70
+ out.xpath(
71
+ ns("//preface | //sections | //annex | //bibliography/clause | "\
72
+ "//bibliography/references[not(@hidden = 'true')] | //indexsect"),
73
+ ).each(&:remove)
74
+ out
75
+ end
76
+
77
+ def sectionfile(xml, dir, file, chunk, parentnode)
78
+ fname = create_sectionfile(xml.dup, dir, file, chunk, parentnode)
79
+ { order: chunk["displayorder"].to_i, url: fname,
80
+ title: titlerender(chunk) }
81
+ end
82
+
83
+ def create_sectionfile(out, dir, file, chunk, parentnode)
84
+ ins = out.at(ns("//misccontainer")) || out.at(ns("//bibdata"))
85
+ if parentnode
86
+ ins.next = "<#{parentnode}/>"
87
+ ins.next.add_child(chunk.dup)
88
+ else
89
+ ins.next = chunk.dup
90
+ end
91
+ outname = "#{file}.xml"
92
+ File.open(File.join(dir, outname), "w:UTF-8") { |f| f.write(out) }
93
+ outname
94
+ end
95
+
96
+ def xref_preprocess(xml)
97
+ svg_preprocess(xml)
98
+ key = (0...8).map { rand(65..90).chr }.join # random string
99
+ refs = eref_to_internal_eref(xml, key)
100
+ refs += xref_to_internal_eref(xml, key)
101
+ xml.root["type"] = key # to force recognition of internal refs
102
+ insert_indirect_biblio(xml, refs, key)
103
+ end
104
+
105
+ def svg_preprocess(xml)
106
+ xml.xpath("//m:svg", "m" => "http://www.w3.org/2000/svg").each do |s|
107
+ m = svgmap_wrap(s)
108
+ s.xpath(".//m:a", "m" => "http://www.w3.org/2000/svg").each do |a|
109
+ next unless /^#/.match? a["href"]
110
+
111
+ a["href"] = a["href"].sub(/^#/, "")
112
+ m << "<target href='#{a['href']}'>"\
113
+ "<xref target='#{a['href']}'/></target>"
114
+ end
115
+ end
116
+ end
117
+
118
+ def svgmap_wrap(svg)
119
+ ret = svg.at("./ancestor::xmlns:svgmap") and return ret
120
+ ret = svg.at("./ancestor::xmlns:figure")
121
+ ret.wrap("<svgmap/>")
122
+ svg.at("./ancestor::xmlns:svgmap")
123
+ end
124
+
125
+ def make_anchor(anchor)
126
+ "<localityStack><locality type='anchor'><referenceFrom>"\
127
+ "#{anchor}</referenceFrom></locality></localityStack>"
128
+ end
129
+
130
+ def xref_to_internal_eref(xml, key)
131
+ xml.xpath(ns("//xref")).each_with_object({}) do |x, m|
132
+ x["bibitemid"] = "#{key}_#{x['target']}"
133
+ x << make_anchor(x["target"])
134
+ m[x["bibitemid"]] = true
135
+ x.delete("target")
136
+ x["type"] = key
137
+ x.name = "eref"
138
+ end.keys
139
+ end
140
+
141
+ def eref_to_internal_eref(xml, key)
142
+ eref_to_internal_eref_select(xml).each_with_object([]) do |x, m|
143
+ url = xml.at(ns("//bibitem[@id = '#{x}']/url[@type = 'citation']"))
144
+ xml.xpath(("//*[@bibitemid = '#{x}']")).each do |e|
145
+ id = eref_to_internal_eref1(e, key, url)
146
+ id and m << id
147
+ end
148
+ end
149
+ end
150
+
151
+ def eref_to_internal_eref1(elem, key, url)
152
+ if url
153
+ elem.name = "link"
154
+ elem["target"] = url
155
+ nil
156
+ else
157
+ elem["bibitemid"] = "#{key}_#{elem['bibitemid']}"
158
+ elem << make_anchor(elem["bibitemid"])
159
+ elem["type"] = key
160
+ elem["bibitemid"]
161
+ end
162
+ end
163
+
164
+ def eref_to_internal_eref_select(xml)
165
+ refs = xml.xpath(("//*/@bibitemid")).map { |x| x.text } # rubocop:disable Style/SymbolProc
166
+ refs.uniq.reject do |x|
167
+ xml.at(ns("//bibitem[@id = '#{x}'][@type = 'internal']"))
168
+ end
169
+ end
170
+
171
+ # from standoc
172
+ def insert_indirect_biblio(xmldoc, refs, prefix)
173
+ ins = xmldoc.at("bibliography") or
174
+ xmldoc.root << "<bibliography/>" and ins = xmldoc.at("bibliography")
175
+ ins = ins.add_child("<references hidden='true' normative='false'/>").first
176
+ refs.each do |x|
177
+ ins << <<~BIBENTRY
178
+ <bibitem id="#{x}" type="internal">
179
+ <docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
180
+ </bibitem>
181
+ BIBENTRY
182
+ end
183
+ end
184
+
185
+ def recursive_string_keys(hash)
186
+ case hash
187
+ when Hash then Hash[
188
+ hash.map { |k, v| [k.to_s, recursive_string_keys(v)] }
189
+ ]
190
+ when Enumerable then hash.map { |v| recursive_string_keys(v) }
191
+ else
192
+ hash
193
+ end
194
+ end
195
+
196
+ def titlerender(section)
197
+ title = section.at(ns("./title")) or return "[Untitled]"
198
+ t = title.dup
199
+ t.xpath(ns(".//tab | .//br")).each { |x| x.replace(" ") }
200
+ t.xpath(ns(".//strong")).each { |x| x.replace(x.children) }
201
+ t.children.to_xml
202
+ end
203
+
204
+ def collectionyaml(files, xml)
205
+ ret = {
206
+ directives: ["presentation-xml", "bare-after-first"],
207
+ bibdata: {
208
+ title: {
209
+ type: "title-main",
210
+ language: @lang,
211
+ content: xml.at(ns("//bibdata/title")).text,
212
+ },
213
+ type: "collection",
214
+ docid: {
215
+ type: xml.at(ns("//bibdata/docidentifier/@type")).text,
216
+ id: xml.at(ns("//bibdata/docidentifier")).text,
217
+ },
218
+ },
219
+ manifest: {
220
+ level: "collection",
221
+ title: "Collection",
222
+ docref: files.sort_by { |f| f[:order] }.each.map do |f|
223
+ { fileref: f[:url], identifier: f[:title] }
224
+ end,
225
+ },
226
+ }
227
+ recursive_string_keys(ret).to_yaml
228
+ end
229
+ end
230
+ 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
- if ret.is_a? Hash
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
- 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
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
- if lang == "en"
26
- YAML.load_file(File.join(File.dirname(__FILE__),
27
- "../isodoc-yaml/i18n-en.yaml"))
28
- elsif lang == "fr"
29
- YAML.load_file(File.join(File.dirname(__FILE__),
30
- "../isodoc-yaml/i18n-fr.yaml"))
31
- elsif lang == "zh" && script == "Hans"
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
- YAML.load_file(File.join(File.dirname(__FILE__),
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(x, y)
45
- @labels[x] = y
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(x, lang = @lang, script = @script)
61
- l10n(x, lang, script)
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(x, lang = @lang, script = @script)
70
+ def l10n(text, lang = @lang, script = @script)
68
71
  if lang == "zh" && script == "Hans"
69
- xml = Nokogiri::HTML::DocumentFragment.parse(x)
72
+ xml = Nokogiri::HTML::DocumentFragment.parse(text)
70
73
  xml.traverse do |n|
71
74
  next unless n.text?
72
- n.replace(n.text.gsub(/ /, "").gsub(/:/, ":").gsub(/,/, "、").
73
- gsub(/\(/, "").gsub(/\)/, "").
74
- gsub(/\[/, "【").gsub(/\]/, "】"))
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 '' if names.empty?
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(', ') + " #{andword} #{names[-1]}", @lang, @script)
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './metadata_date'
4
- require_relative './metadata_contributor'
3
+ require_relative "./metadata_date"
4
+ require_relative "./metadata_contributor"
5
5
 
6
6
  module IsoDoc
7
7
  class Metadata
@@ -17,7 +17,7 @@ module IsoDoc
17
17
 
18
18
  def initialize(lang, script, i18n, fonts_options = {})
19
19
  @metadata = { lang: lang, script: script }
20
- DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = 'XXX' }
20
+ DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = "XXX" }
21
21
  @lang = lang
22
22
  @script = script
23
23
  @c = HTMLEntities.new
@@ -38,7 +38,7 @@ module IsoDoc
38
38
  @metadata[key] = value
39
39
  end
40
40
 
41
- NOLANG = "[not(@language) or @language = '']".freeze
41
+ NOLANG = "[not(@language) or @language = '']"
42
42
 
43
43
  def currlang
44
44
  "[@language = '#{@lang}']"
@@ -54,6 +54,7 @@ module IsoDoc
54
54
  def docstatus(xml, _out)
55
55
  set(:unpublished, true)
56
56
  return unless s = xml.at(ns("//bibdata/status/stage#{NOLANG}"))
57
+
57
58
  s1 = xml.at(ns("//bibdata/status/stage#{currlang}")) || s
58
59
  set(:stage, status_print(s.text))
59
60
  s1 and set(:stage_display, status_print(s1.text))
@@ -61,26 +62,26 @@ module IsoDoc
61
62
  set(:substage, i)
62
63
  (i1 = xml&.at(ns("//bibdata/status/substage#{currlang}"))&.text || i) and
63
64
  set(:substage_display, i1)
64
- (i2 = xml&.at(ns('//bibdata/status/iteration'))&.text) and
65
+ (i2 = xml&.at(ns("//bibdata/status/iteration"))&.text) and
65
66
  set(:iteration, i2)
66
67
  set(:unpublished, unpublished(s.text))
67
68
  unpublished(s.text) && set(:stageabbr, stage_abbr(s.text))
68
69
  end
69
70
 
70
71
  def stage_abbr(docstatus)
71
- status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join('')
72
+ status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join("")
72
73
  end
73
74
 
74
75
  def unpublished(status)
75
- !status.casecmp('published').zero?
76
+ !status.casecmp("published").zero?
76
77
  end
77
78
 
78
79
  def status_print(status)
79
- status.split(/[- ]/).map(&:capitalize).join(' ')
80
+ status.split(/[- ]/).map(&:capitalize).join(" ")
80
81
  end
81
82
 
82
83
  def docid(isoxml, _out)
83
- dn = isoxml.at(ns('//bibdata/docidentifier'))
84
+ dn = isoxml.at(ns("//bibdata/docidentifier"))
84
85
  set(:docnumber, dn&.text)
85
86
  end
86
87
 
@@ -92,23 +93,24 @@ module IsoDoc
92
93
  end
93
94
 
94
95
  def docnumeric(isoxml, _out)
95
- dn = isoxml.at(ns('//bibdata/docnumber'))
96
+ dn = isoxml.at(ns("//bibdata/docnumber"))
96
97
  set(:docnumeric, dn&.text)
97
98
  end
98
99
 
99
100
  def draftinfo(draft, revdate)
100
101
  return "" unless draft
102
+
101
103
  draftinfo = " (#{@labels['draft_label']} #{draft}"
102
104
  draftinfo += ", #{revdate}" if revdate
103
- draftinfo += ')'
105
+ draftinfo += ")"
104
106
  l10n(draftinfo, @lang, @script)
105
107
  end
106
108
 
107
109
  def version(isoxml, _out)
108
- set(:edition, isoxml&.at(ns('//bibdata/edition'))&.text)
109
- set(:docyear, isoxml&.at(ns('//bibdata/copyright/from'))&.text)
110
- set(:draft, isoxml&.at(ns('//version/draft'))&.text)
111
- revdate = isoxml&.at(ns('//version/revision-date'))&.text
110
+ set(:edition, isoxml&.at(ns("//bibdata/edition"))&.text)
111
+ set(:docyear, isoxml&.at(ns("//bibdata/copyright/from"))&.text)
112
+ set(:draft, isoxml&.at(ns("//bibdata/version/draft"))&.text)
113
+ revdate = isoxml&.at(ns("//bibdata/version/revision-date"))&.text
112
114
  set(:revdate, revdate)
113
115
  set(:revdate_monthyear, monthyr(revdate))
114
116
  set(:draftinfo,
@@ -131,20 +133,20 @@ module IsoDoc
131
133
 
132
134
  def relations_partof(isoxml)
133
135
  std = isoxml.at(ns("//bibdata/relation[@type = 'partOf']")) || return
134
- id = std.at(ns('.//docidentifier'))
136
+ id = std.at(ns(".//docidentifier"))
135
137
  set(:partof, id.text) if id
136
138
  end
137
139
 
138
140
  def relations_obsoletes(isoxml)
139
141
  std = isoxml.at(ns("//bibdata/relation[@type = 'obsoletes']")) || return
140
- locality = std.at(ns('.//locality'))
141
- id = std.at(ns('.//docidentifier'))
142
+ locality = std.at(ns(".//locality"))
143
+ id = std.at(ns(".//docidentifier"))
142
144
  set(:obsoletes, id.text) if id
143
145
  set(:obsoletes_part, locality.text) if locality
144
146
  end
145
147
 
146
148
  def url(xml, _out)
147
- (a = xml.at(ns('//bibdata/uri[not(@type)]'))) && set(:url, a.text)
149
+ (a = xml.at(ns("//bibdata/uri[not(@type)]"))) && set(:url, a.text)
148
150
  (a = xml.at(ns("//bibdata/uri[@type = 'html']"))) && set(:html, a.text)
149
151
  (a = xml.at(ns("//bibdata/uri[@type = 'xml']"))) && set(:xml, a.text)
150
152
  (a = xml.at(ns("//bibdata/uri[@type = 'pdf']"))) && set(:pdf, a.text)
@@ -153,7 +155,7 @@ module IsoDoc
153
155
 
154
156
  def keywords(isoxml, _out)
155
157
  ret = []
156
- isoxml.xpath(ns('//bibdata/keyword')).each { |kw| ret << kw.text }
158
+ isoxml.xpath(ns("//bibdata/keyword")).each { |kw| ret << kw.text }
157
159
  set(:keywords, ret)
158
160
  end
159
161