isodoc 3.4.1 → 3.4.3

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/lib/isodoc/base_style/typography.scss +5 -0
  3. data/lib/isodoc/convert.rb +3 -2
  4. data/lib/isodoc/function/blocks.rb +33 -5
  5. data/lib/isodoc/function/blocks_example_note.rb +5 -3
  6. data/lib/isodoc/function/cleanup.rb +5 -4
  7. data/lib/isodoc/function/inline.rb +9 -27
  8. data/lib/isodoc/function/inline_simple.rb +25 -0
  9. data/lib/isodoc/function/references.rb +11 -4
  10. data/lib/isodoc/function/setup.rb +2 -1
  11. data/lib/isodoc/function/table.rb +2 -2
  12. data/lib/isodoc/function/to_word_html.rb +1 -0
  13. data/lib/isodoc/function/utils.rb +1 -1
  14. data/lib/isodoc/init.rb +17 -7
  15. data/lib/isodoc/metadata.rb +10 -6
  16. data/lib/isodoc/metadata_contributor.rb +15 -2
  17. data/lib/isodoc/presentation_function/autonum.rb +65 -4
  18. data/lib/isodoc/presentation_function/bibdata.rb +15 -4
  19. data/lib/isodoc/presentation_function/block.rb +36 -78
  20. data/lib/isodoc/presentation_function/docid.rb +18 -10
  21. data/lib/isodoc/presentation_function/erefs.rb +55 -28
  22. data/lib/isodoc/presentation_function/erefs_locality.rb +18 -10
  23. data/lib/isodoc/presentation_function/footnotes.rb +2 -1
  24. data/lib/isodoc/presentation_function/image.rb +15 -5
  25. data/lib/isodoc/presentation_function/index.rb +1 -5
  26. data/lib/isodoc/presentation_function/inline.rb +2 -20
  27. data/lib/isodoc/presentation_function/list.rb +3 -3
  28. data/lib/isodoc/presentation_function/metadata.rb +50 -32
  29. data/lib/isodoc/presentation_function/refs.rb +70 -86
  30. data/lib/isodoc/presentation_function/section.rb +0 -3
  31. data/lib/isodoc/presentation_function/section_refs.rb +55 -0
  32. data/lib/isodoc/presentation_function/source.rb +73 -0
  33. data/lib/isodoc/presentation_function/terms.rb +7 -5
  34. data/lib/isodoc/presentation_function/xrefs.rb +17 -6
  35. data/lib/isodoc/presentation_xml_convert.rb +10 -4
  36. data/lib/isodoc/version.rb +1 -1
  37. data/lib/isodoc/word_function/lists.rb +4 -2
  38. data/lib/isodoc/word_function/postprocess_table.rb +3 -1
  39. data/lib/isodoc/xref/xref_gen.rb +72 -119
  40. data/lib/isodoc/xref/xref_gen_seq.rb +18 -14
  41. data/lib/isodoc/xref/xref_list_gen.rb +107 -0
  42. data/lib/isodoc/xref/xref_sect_asset.rb +0 -1
  43. data/lib/isodoc/xref/xref_sect_gen.rb +0 -2
  44. data/lib/isodoc/xref.rb +1 -0
  45. data/lib/isodoc/xslfo_convert.rb +5 -1
  46. data/lib/isodoc-yaml/i18n-ar.yaml +9 -0
  47. data/lib/isodoc-yaml/i18n-de.yaml +9 -0
  48. data/lib/isodoc-yaml/i18n-en.yaml +9 -0
  49. data/lib/isodoc-yaml/i18n-es.yaml +9 -0
  50. data/lib/isodoc-yaml/i18n-fr.yaml +9 -0
  51. data/lib/isodoc-yaml/i18n-ja.yaml +9 -0
  52. data/lib/isodoc-yaml/i18n-ru.yaml +9 -0
  53. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -0
  54. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18d33859f89e36a66412218c04370f02c727fe131dd91b73fd3671ab25cf228f
4
- data.tar.gz: cc2996c38878a5acacf24932cf2719a1bef922cea11cf5c26411172e9a93032a
3
+ metadata.gz: ab9b39e8179c40594c9f9665530cbbd6e5138379bd61e6b15799770a33032738
4
+ data.tar.gz: 6f3c2bd190862970a129ba9156c67dc4fc2610a90f1d561b8d057258c9f09420
5
5
  SHA512:
6
- metadata.gz: dde602b7132920dff5599dc3da2bb0de9ef027f5b3dd703fadc190adec9fab8e26901798bc208d3b3d279b57c5d19fa7ccbe885c37591da875e79f8dd5c364d4
7
- data.tar.gz: 8d67a2d2518105cf854c7bb7f21a841de922785b0c77060e6002e6023c8de2b14efb8a9cbea25d140101183349b4b346287332eeb230b0c33aa5e0db3dcb3321
6
+ metadata.gz: 5d3f6c2eaaed487ae2c6921fb5ba4adcb52dd44c979e95a599532a0c3ebedf5471c25db030597cdf6dbac5f8eb1f17c0a51c1a9b608e5951226aa5098286b2d5
7
+ data.tar.gz: 51cc8feda89a2c3660723681bfe774cc17a926a8326be96466397c3c9efaa0185215e49e4bac84b8a0790f09e163003dbc1c9abb42838fbd3012285489ef7337
@@ -67,4 +67,9 @@
67
67
  td.header {
68
68
  font-weight: 400;
69
69
  }
70
+
71
+ table.plain, table.plain th, table.plain td {
72
+ border: none !important;
73
+ font-size: 0.95em;
74
+ }
70
75
  }
@@ -88,7 +88,7 @@ module IsoDoc
88
88
  def bibrenderer(options = {})
89
89
  ::Relaton::Render::IsoDoc::General
90
90
  .new(options.merge(language: @lang, script: @script,
91
- i18nhash: @i18n.get))
91
+ i18nhash: @i18n.get, config: @relatonrenderconfig))
92
92
  end
93
93
 
94
94
  def convert1_namespaces(html)
@@ -112,11 +112,12 @@ module IsoDoc
112
112
  docxml = Nokogiri::XML(file, &:huge)
113
113
  filename, dir = init_file(input_filename, debug)
114
114
  docxml.root.default_namespace = ""
115
+ docxml_var_init(docxml)
115
116
  convert_i18n_init(docxml)
116
117
  metadata_init(@lang, @script, @locale, @i18n)
117
118
  xref_init(@lang, @script, self, @i18n,
118
119
  { locale: @locale, bibrender: @bibrender })
119
- toc_init(docxml)
120
+ @xrefs.klass.doctype = @doctype
120
121
  [docxml, filename, dir]
121
122
  end
122
123
 
@@ -118,6 +118,30 @@ module IsoDoc
118
118
  end
119
119
  end
120
120
 
121
+ def key_parse(node, out)
122
+ klass = "key #{node['class']}".strip
123
+ out.div **attr_code(class: klass) do |div|
124
+ node.children.each do |n|
125
+ if n.name == "name"
126
+ key_name_parse(n, div)
127
+ "<p keep-with-next='true'><strong>#{@i18n.key}</strong></p>"
128
+ else parse(n, div)
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ def key_name_parse(node, div)
135
+ a = keep_style(node)
136
+ a&.include?("page-break-after:") or
137
+ a = "page-break-after: avoid;#{a}"
138
+ div.p style: a do |p|
139
+ p.b do |s|
140
+ children_parse(node, s)
141
+ end
142
+ end
143
+ end
144
+
121
145
  def para_class(node)
122
146
  classtype = nil
123
147
  classtype = "MsoCommentText" if in_comment
@@ -137,13 +161,17 @@ module IsoDoc
137
161
 
138
162
  def para_parse(node, out)
139
163
  out.p **attr_code(para_attrs(node)) do |p|
140
- children_parse(node, p)
164
+ para_prefix(node, p)
165
+ node.children.each { |n| parse(n, p) unless n.name == "note" }
141
166
  end
167
+ node.xpath(ns("./note")).each { |n| parse(n, out) }
142
168
  end
143
169
 
170
+ def para_prefix(node, out); end
171
+
144
172
  def attribution_parse(node, out)
145
173
  out.div class: "QuoteAttribution" do |div|
146
- children_parse(node, div)
174
+ children_parse(node, div)
147
175
  end
148
176
  end
149
177
 
@@ -167,14 +195,14 @@ module IsoDoc
167
195
 
168
196
  def toc_parse(node, out)
169
197
  out.div class: "toc" do |div|
170
- children_parse(node, div)
198
+ children_parse(node, div)
171
199
  end
172
200
  end
173
201
 
174
202
  def source_parse(node, out)
175
203
  out.div class: "BlockSource" do |d|
176
204
  d.p do |p|
177
- children_parse(node, p)
205
+ children_parse(node, p)
178
206
  end
179
207
  end
180
208
  end
@@ -201,7 +229,7 @@ module IsoDoc
201
229
  tag = node.parent.name == "fmt-footnote-container" ? "aside" : "div"
202
230
  id = node["is_table"] ? node["reference"] : node["id"]
203
231
  out.send tag, id: "fn:#{id}", class: "footnote" do |div|
204
- children_parse(node, div)
232
+ children_parse(node, div)
205
233
  end
206
234
  end
207
235
  end
@@ -4,7 +4,7 @@ module IsoDoc
4
4
  def example_label(_node, div, name)
5
5
  name.nil? and return
6
6
  div.p class: "example-title" do |_p|
7
- children_parse(name, div)
7
+ children_parse(name, div)
8
8
  end
9
9
  end
10
10
 
@@ -64,7 +64,9 @@ module IsoDoc
64
64
  end
65
65
 
66
66
  def starts_with_para?(node)
67
- block_body_first_elem(node)&.name == "p"
67
+ elem = block_body_first_elem(node) or return
68
+ elem.name == "p" || elem.elements.first&.name == "p" ||
69
+ block_body_first_elem(elem)&.name == "p"
68
70
  end
69
71
 
70
72
  def note_p_class
@@ -73,7 +75,7 @@ module IsoDoc
73
75
 
74
76
  def note_p_parse(node, div)
75
77
  name = node.at(ns("./fmt-name"))
76
- para = node.at(ns("./p"))
78
+ para = node.at(ns("./p")) || node.at(ns("./semx/p"))
77
79
  div.p **attr_code(class: note_p_class) do |p|
78
80
  name and p.span class: "note_label" do |s|
79
81
  name.children.each { |n| parse(n, s) }
@@ -8,8 +8,8 @@ module IsoDoc
8
8
  def passthrough_cleanup(docxml)
9
9
  docxml.split(%r{(<passthrough>|</passthrough>)}).each_slice(4)
10
10
  .map do |a|
11
- a.size > 2 and a[2] = HTMLEntities.new.decode(a[2])
12
- [a[0], a[2]]
11
+ a.size > 2 and a[2] = HTMLEntities.new.decode(a[2])
12
+ [a[0], a[2]]
13
13
  end.join
14
14
  end
15
15
 
@@ -112,7 +112,8 @@ module IsoDoc
112
112
  end
113
113
 
114
114
  TABLENOTE_CSS = "div[@class = 'Note' or @class = 'BlockSource' " \
115
- "or @class = 'TableFootnote' or @class = 'figdl']".freeze
115
+ "or @class = 'TableFootnote' or @class = 'figdl' or @class = 'key']"
116
+ .freeze
116
117
 
117
118
  def table_note_cleanup(docxml)
118
119
  docxml.xpath("//table[dl or #{TABLENOTE_CSS}]").each do |t|
@@ -120,7 +121,7 @@ module IsoDoc
120
121
  insert_here = new_fullcolspan_row(t, tfoot)
121
122
  t.xpath("dl | p[@class = 'ListTitle'] | #{TABLENOTE_CSS}")
122
123
  .each do |d|
123
- d.parent = insert_here
124
+ d.parent = insert_here
124
125
  end
125
126
  end
126
127
  end
@@ -4,9 +4,9 @@ module IsoDoc
4
4
  module Function
5
5
  module Inline
6
6
  def link_parse(node, out)
7
- url = node["target"]
8
- node["update-type"] == "true" and url = suffix_url(url)
9
- out.a **attr_code(href: url, title: node["alt"]) do |l|
7
+ url = link_parse_url(node)
8
+ out.a **attr_code(href: url, title: node["alt"],
9
+ class: node["style"]) do |l|
10
10
  if node.elements.empty? && node.text.strip.empty?
11
11
  l << @c.encode(node["target"].sub(/^mailto:/, ""), :basic,
12
12
  :hexadecimal)
@@ -15,6 +15,12 @@ module IsoDoc
15
15
  end
16
16
  end
17
17
 
18
+ def link_parse_url(node)
19
+ url = node["target"]
20
+ node["update-type"] == "true" and url = suffix_url(url)
21
+ url
22
+ end
23
+
18
24
  # Presentation XML classes which we need not pass on to HTML or DOC
19
25
  SPAN_UNWRAP_CLASSES =
20
26
  %w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim
@@ -213,30 +219,6 @@ module IsoDoc
213
219
  children_parse(node, s)
214
220
  end
215
221
  end
216
-
217
- def fmt_concept_parse(node, out)
218
- children_parse(node, out)
219
- end
220
-
221
- def fmt_date_parse(node, out)
222
- children_parse(node, out)
223
- end
224
-
225
- def fmt_fn_label_parse(node, out)
226
- children_parse(node, out)
227
- end
228
-
229
- def fmt_footnote_container_parse(node, out)
230
- children_parse(node, out)
231
- end
232
-
233
- def fmt_annotation_start_parse(node, out)
234
- children_parse(node, out)
235
- end
236
-
237
- def fmt_annotation_end_parse(node, out)
238
- children_parse(node, out)
239
- end
240
222
  end
241
223
  end
242
224
  end
@@ -98,6 +98,31 @@ module IsoDoc
98
98
  def semx_sourcecode_parse(node, out); end
99
99
  def annotation_note_parse(node, out); end
100
100
  def semx_source_parse(node, out); end
101
+
102
+ def fmt_concept_parse(node, out)
103
+ children_parse(node, out)
104
+ end
105
+
106
+ def fmt_date_parse(node, out)
107
+ children_parse(node, out)
108
+ end
109
+
110
+ def fmt_fn_label_parse(node, out)
111
+ children_parse(node, out)
112
+ end
113
+
114
+ def fmt_footnote_container_parse(node, out)
115
+ children_parse(node, out)
116
+ end
117
+
118
+ def fmt_annotation_start_parse(node, out)
119
+ children_parse(node, out)
120
+ end
121
+
122
+ def fmt_annotation_end_parse(node, out)
123
+ children_parse(node, out)
124
+ end
125
+
101
126
  end
102
127
  end
103
128
  end
@@ -3,10 +3,17 @@ module IsoDoc
3
3
  module References
4
4
  def bibitem_entry(list, bib, _ordinal, biblio)
5
5
  list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
6
- tag = bib.at(ns("./biblio-tag"))
7
- tag&.children&.each { |n| parse(n, ref) }
6
+ children_parse(bib.at(ns("./biblio-tag")), ref)
8
7
  reference_format(bib, ref)
9
8
  end
9
+ bibitem_notes(list, bib, _ordinal, biblio)
10
+ end
11
+
12
+ def bibitem_notes(list, bib, _ordinal, biblio)
13
+ bib.xpath(ns("./formattedref/note")).each do |n|
14
+ parse(n, list)
15
+ list.parent.elements[-1]["class"] += biblio ? " Biblio" : " NormRef"
16
+ end
10
17
  end
11
18
 
12
19
  def iso_bibitem_entry_attrs(bib, biblio)
@@ -14,8 +21,8 @@ module IsoDoc
14
21
  end
15
22
 
16
23
  def reference_format(bib, out)
17
- ftitle = bib.at(ns("./formattedref"))
18
- ftitle&.children&.each { |n| parse(n, out) }
24
+ ftitle = bib.at(ns("./formattedref")) or return
25
+ ftitle.children.each { |n| n.name == "note" or parse(n, out) }
19
26
  end
20
27
 
21
28
  def biblio_list(refs, div, biblio)
@@ -42,6 +42,7 @@ module IsoDoc
42
42
 
43
43
  def info(isoxml, out)
44
44
  @meta.localdir = @localdir
45
+ @meta.presentation isoxml, out
45
46
  @meta.code_css isoxml, out
46
47
  @meta.title isoxml, out
47
48
  @meta.subtitle isoxml, out
@@ -57,7 +58,7 @@ module IsoDoc
57
58
  @meta.url isoxml, out
58
59
  @meta.keywords isoxml, out
59
60
  @meta.note isoxml, out
60
- @meta.presentation isoxml, out
61
+ @meta.images isoxml, out
61
62
  @meta.get
62
63
  end
63
64
  end
@@ -51,7 +51,7 @@ module IsoDoc
51
51
  c = node["class"]
52
52
  style = table_attrs_style(node, c)
53
53
  attr_code(id: node["id"],
54
- class: node["plain"] == "true" ? nil : (c || "MsoISOTable"),
54
+ class: node["plain"] == "true" ? "plain" : (c || "MsoISOTable"),
55
55
  style: style, title: node["alt"])
56
56
  end
57
57
 
@@ -93,7 +93,7 @@ module IsoDoc
93
93
  end
94
94
 
95
95
  def table_parse_tail(node, out)
96
- (dl = node.at(ns("./dl"))) && parse(dl, out)
96
+ (dl = node.at(ns("./key"))) && parse(dl, out)
97
97
  node.xpath(ns("./fmt-source")).each { |n| parse(n, out) }
98
98
  node.xpath(ns("./note")).each { |n| parse(n, out) }
99
99
  node.xpath(ns("./fmt-footnote-container/fmt-fn-body"))
@@ -241,6 +241,7 @@ module IsoDoc
241
241
  when "fmt-annotation-start" then fmt_annotation_start_parse(node, out)
242
242
  when "fmt-annotation-end" then fmt_annotation_end_parse(node, out)
243
243
  when "fmt-annotation-body" then fmt_annotation_body_parse(node, out)
244
+ when "key" then key_parse(node, out)
244
245
  else error_parse(node, out)
245
246
  end
246
247
  end
@@ -84,7 +84,7 @@ module IsoDoc
84
84
  end
85
85
 
86
86
  NOTE_CONTAINER_ANCESTOR = <<~XPATH.strip.freeze
87
- .//ancestor::*[local-name() = 'annex' or local-name() = 'foreword' or local-name() = 'appendix' or local-name() = 'introduction' or local-name() = 'terms' or local-name() = 'acknowledgements' or local-name() = 'executivesummary' or local-name() = 'term' or local-name() = 'clause' or local-name() = 'references' or local-name() = 'figure' or local-name() = 'formula' or local-name() = 'table' or local-name() = 'example']/@id
87
+ .//ancestor::*[local-name() = 'annex' or local-name() = 'foreword' or local-name() = 'appendix' or local-name() = 'introduction' or local-name() = 'terms' or local-name() = 'acknowledgements' or local-name() = 'executivesummary' or local-name() = 'term' or local-name() = 'clause' or local-name() = 'references' or local-name() = 'figure' or local-name() = 'formula' or local-name() = 'table' or local-name() = 'example' or local-name() = 'bibitem']/@id
88
88
  XPATH
89
89
 
90
90
  # no recursion on references
data/lib/isodoc/init.rb CHANGED
@@ -19,15 +19,24 @@ module IsoDoc
19
19
  @i18n.l10n(expr, lang, script, opt)
20
20
  end
21
21
 
22
- def toc_init(docxml)
22
+ def docxml_var_init(docxml)
23
+ doctype_init(docxml)
24
+ toc_init(docxml)
25
+ end
26
+
27
+ def doctype_init(docxml)
23
28
  @doctype = docxml.at(ns("//bibdata/ext/doctype"))&.text
24
29
  @subdoctype = docxml.at(ns("//bibdata/ext/subdoctype"))&.text
25
- @xrefs.klass.doctype = @doctype
26
- x = "//metanorma-extension/presentation-metadata" \
27
- "[name[text() = 'TOC Heading Levels']]/value"
28
- n = docxml.at(ns(x.sub("TOC", "DOC TOC"))) and
30
+ @docscheme = docxml.at(ns("//metanorma-extension/presentation-metadata/"\
31
+ "document-scheme"))&.text
32
+ end
33
+
34
+ def toc_init(docxml)
35
+ x = "//metanorma-extension/presentation-metadata/" \
36
+ "toc-heading-levels"
37
+ n = docxml.at(ns(x.sub("toc", "doc-toc"))) and
29
38
  @wordToClevels = n.text.to_i
30
- n = docxml.at(ns(x.sub("TOC", "HTML TOC"))) and
39
+ n = docxml.at(ns(x.sub("toc", "html-toc"))) and
31
40
  @htmlToClevels = n.text.to_i
32
41
  end
33
42
 
@@ -80,6 +89,7 @@ module IsoDoc
80
89
  @script = options[:script] || "Latn"
81
90
  @locale = options[:locale]
82
91
  @localizenumber = options[:localizenumber]
92
+ @relatonrenderconfig = options[:relatonrenderconfig]
83
93
  end
84
94
 
85
95
  def init_locations(options)
@@ -186,7 +196,7 @@ module IsoDoc
186
196
  def omit_docid_prefix(prefix)
187
197
  prefix.nil? || prefix.empty? and return true
188
198
  %w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal
189
- title).include? prefix
199
+ author-date title).include? prefix
190
200
  end
191
201
 
192
202
  def connectives_spans(text)
@@ -9,7 +9,7 @@ module IsoDoc
9
9
  Common::ns(xpath)
10
10
  end
11
11
 
12
- def l10n(expr, lang = @lang, script = @script, opt = {})
12
+ def l10n(expr, lang = @lang, script = @script, opt = {})
13
13
  opt[:locale] ||= @locale
14
14
  @i18n.l10n(expr, lang, script, opt)
15
15
  end
@@ -52,6 +52,8 @@ module IsoDoc
52
52
  def doctype(isoxml, _out)
53
53
  b = isoxml.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
54
54
  set(:doctype, status_print(b.text))
55
+ ba = isoxml.at(ns("//bibdata/ext/doctype/@abbreviation")) and
56
+ set(:doctype_abbr, status_print(ba.text))
55
57
  b1 = isoxml.at(ns("//bibdata/ext/doctype#{currlang}")) || b
56
58
  set(:doctype_display, status_print(b1.text))
57
59
  b = isoxml.at(ns("//bibdata/ext/subdoctype#{NOLANG}")) || return
@@ -113,7 +115,7 @@ module IsoDoc
113
115
  def draftinfo(draft, revdate)
114
116
  return "" unless draft
115
117
 
116
- draftinfo = " (#{@labels['draft_label']} #{draft}"
118
+ draftinfo = " (#{@labels['draft_label']} <esc>#{draft}</esc>"
117
119
  draftinfo += ", #{revdate}" if revdate
118
120
  draftinfo += ")"
119
121
  l10n(draftinfo, @lang, @script)
@@ -182,17 +184,19 @@ module IsoDoc
182
184
  set(:title_footnote, ret)
183
185
  end
184
186
 
187
+ def images(_isoxml, _out)
188
+ end
189
+
185
190
  def code_css(isoxml, _out)
186
191
  c = isoxml.at(ns("//metanorma-extension/source-highlighter-css")) or return
187
192
  set(:code_css, c.text)
188
193
  end
189
194
 
190
195
  def presentation(xml, _out)
191
- xml.xpath(ns("//metanorma-extension/presentation-metadata")).each do |p|
192
- ((n = p.at(ns("./name"))) && (v = p.at(ns("./value")))) or next
193
- lbl = "presentation_metadata_#{n.text}".to_sym
196
+ xml.xpath(ns("//metanorma-extension/presentation-metadata/*")).each do |p|
197
+ lbl = "presentation_metadata_#{p.name}".to_sym
194
198
  m = get[lbl] || []
195
- set(lbl, m << v.text)
199
+ set(lbl, m << p.text)
196
200
  end
197
201
  end
198
202
 
@@ -53,6 +53,19 @@ module IsoDoc
53
53
  def author(xml, _out)
54
54
  personal_authors(xml)
55
55
  agency(xml)
56
+ contributor_role(xml, "authorizer")
57
+ contributor_role(xml, "enabler")
58
+ end
59
+
60
+ def contributor_role(xml, role)
61
+ ret = xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = " \
62
+ "'#{role}']/organization"))
63
+ .each_with_object([]) do |org, m|
64
+ name = org.at(ns("./name[@language = '#{@lang}']")) ||
65
+ org.at(ns("./name"))
66
+ m << name.text
67
+ end
68
+ ret.empty? or set(role.to_sym, ret)
56
69
  end
57
70
 
58
71
  def iso?(org)
@@ -66,8 +79,8 @@ module IsoDoc
66
79
  logos = []
67
80
  agency_data(xml).each do |org|
68
81
  agency1 = org[:abbr] || org[:name]
69
- org[:name] and publisher << org[:name]
70
- org[:logo] and logos << org[:logo]
82
+ org[:name] && !org[:name].empty? and publisher << org[:name]
83
+ org[:logo] && !org[:logo].empty? and logos << org[:logo]
71
84
  agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
72
85
  end
73
86
  [agency.sub(%r{/$}, ""), publisher, logos]
@@ -1,6 +1,7 @@
1
1
  module IsoDoc
2
2
  class PresentationXMLConvert < ::IsoDoc::Convert
3
3
  def prefix_name(node, delims, label, elem)
4
+ sem_xml_descendant?(node) and return
4
5
  label, delims = prefix_name_defaults(node, delims, label, elem)
5
6
  name, ins, ids, number = prefix_name_prep(node, elem)
6
7
  ins.next = fmt_xref_label(label, number, ids)
@@ -30,7 +31,6 @@ module IsoDoc
30
31
  end
31
32
 
32
33
  def prefix_name_labels(node)
33
- #@new_ids ||= {}
34
34
  id = "_#{UUIDTools::UUID.random_create}"
35
35
  @new_ids[id] = nil
36
36
  { elem: node["id"], name: id }
@@ -78,7 +78,7 @@ module IsoDoc
78
78
  end
79
79
 
80
80
  def semx(node, label, element = "autonum")
81
- id = node["id"] || node[:id] || elem['original-id']
81
+ id = node["id"] || node[:id] || elem["original-id"]
82
82
  /<semx element='[^']+' source='#{id}'/.match?(label) and return label
83
83
  l = stripsemx(label)
84
84
  %(<semx element='#{element}' source='#{id}'>#{l}</semx>)
@@ -113,13 +113,22 @@ module IsoDoc
113
113
 
114
114
  def prefix_container_fmt_xref_label(container, xref)
115
115
  container or return xref
116
- container_container = @xrefs.anchor(container, :container, false)
116
+ container_container = prefix_container_container(container)
117
117
  container_label =
118
118
  prefix_container_fmt_xref_label(container_container,
119
119
  @xrefs.anchor(container, :xref, false))
120
120
  l10n(connectives_spans(@i18n.nested_xref
121
121
  .sub("%1", "<span class='fmt-xref-container'>#{esc container_label}</span>")
122
- .sub("%2", xref)))
122
+ .sub("%2", xref || "[Unknown]")))
123
+ end
124
+
125
+ def prefix_container_container(container)
126
+ container_container = @xrefs.anchor(container, :container, false)
127
+ if @xrefs.anchor(container, :type) == "bibitem"
128
+ p = @bibitem_lookup[container].parent
129
+ p and container_container ||= p["id"]
130
+ end
131
+ container_container
123
132
  end
124
133
 
125
134
  # detect whether string which may contain XML markup is empty
@@ -160,5 +169,57 @@ module IsoDoc
160
169
  text.nil? || text.empty? and return text
161
170
  "<esc>#{text}</esc>"
162
171
  end
172
+
173
+ # do not change to Presentation XML rendering
174
+ # this is sensitive to ordering of Presentation XML processing:
175
+ # blocks > terms > inline
176
+ def sem_xml_descendant?(node)
177
+ ancestor_names = node.ancestors.map(&:name)
178
+ sem_xml_descendant_terms?(node, ancestor_names) and return true
179
+ sem_xml_descendant_inline?(node, ancestor_names) and return true
180
+ sem_xml_descendant_bibitem?(node, ancestor_names) and return true
181
+ sem_xml_descendant_provision?(node, ancestor_names) and return true
182
+ false
183
+ end
184
+
185
+ # keep Presentation XML blocks within provisions,
186
+ # they are processed separately
187
+ # into distinct Presentation XML fmt-provision later
188
+ def sem_xml_descendant_provision?(node, ancestor_names)
189
+ block?(node) and return false
190
+ (ancestor_names & %w[requirement recommendation permission]).any? &&
191
+ !ancestor_names.include?("fmt-provision")
192
+ end
193
+
194
+ def sem_xml_descendant_bibitem?(_node, ancestor_names)
195
+ ancestor_names.include?("bibitem") &&
196
+ %w[formattedref biblio-tag].none? do |name|
197
+ ancestor_names.include?(name)
198
+ end
199
+ end
200
+
201
+ def sem_xml_descendant_inline?(_node, ancestor_names)
202
+ %w[xref eref origin link name title newcontent]
203
+ .any? do |name|
204
+ ancestor_names.include?(name)
205
+ end and return true
206
+ end
207
+
208
+ # keep Presentation XML blocks within designations,
209
+ # they are processed separately
210
+ # into distinct Presentation XML fmt-* designations later
211
+ def sem_xml_descendant_terms?(node, ancestor_names)
212
+ block?(node) and return false
213
+ %w[preferred admitted deprecated related definition source]
214
+ .any? do |name|
215
+ ancestor_names.include?(name)
216
+ end
217
+ end
218
+
219
+ def block?(node)
220
+ %w(figure table note example termnote termexample formula sourcecode
221
+ admonition ul ol dl quote permission requirement recommendation)
222
+ .include?(node.name)
223
+ end
163
224
  end
164
225
  end
@@ -42,7 +42,8 @@ module IsoDoc
42
42
  def bibdata_i18n(bib)
43
43
  hash_translate(bib, @i18n.get["doctype_dict"], "./ext/doctype",
44
44
  "//presentation-metadata/doctype-alias", @lang)
45
- hash_translate(bib, @i18n.get["stage_dict"], "./status/stage", nil, @lang)
45
+ hash_translate(bib, @i18n.get["stage_dict"], "./status/stage",
46
+ "//presentation-metadata/stage-alias", @lang)
46
47
  hash_translate(bib, @i18n.get["substage_dict"], "./status/substage", nil,
47
48
  @lang)
48
49
  edition_translate(bib)
@@ -63,10 +64,20 @@ module IsoDoc
63
64
  # to be mixed
64
65
  def edition_translate(bibdata)
65
66
  x = bibdata.at(ns("./edition")) or return
67
+ if @i18n.edition_ordinal && num = edition_integer?(bibdata)
68
+ tag_translate(x, @lang, @i18n
69
+ .populate("edition_ordinal", { "var1" => num }))
70
+ elsif @i18n.edition_cardinal
71
+ tag_translate(x, @lang, @i18n
72
+ .populate("edition_cardinal", { "var1" => x.text }))
73
+ end
74
+ end
75
+
76
+ def edition_integer?(bibdata)
77
+ x = bibdata.at(ns("./edition[not(@language) or @language = '']"))
78
+ x or return
66
79
  /^\d+$/.match?(x.text) or return
67
- @i18n.edition_ordinal or return
68
- tag_translate(x, @lang, @i18n
69
- .populate("edition_ordinal", { "var1" => x.text.to_i }))
80
+ x.text.to_i
70
81
  end
71
82
 
72
83
  def tag_translate(tag, lang, value)