isodoc 3.1.1 → 3.1.2

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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +2 -12
  3. data/lib/isodoc/common.rb +2 -0
  4. data/lib/isodoc/function/blocks.rb +12 -0
  5. data/lib/isodoc/function/cleanup.rb +4 -12
  6. data/lib/isodoc/function/footnotes.rb +57 -0
  7. data/lib/isodoc/function/inline.rb +10 -6
  8. data/lib/isodoc/function/section.rb +7 -0
  9. data/lib/isodoc/function/setup.rb +64 -0
  10. data/lib/isodoc/function/table.rb +2 -0
  11. data/lib/isodoc/function/to_word_html.rb +5 -57
  12. data/lib/isodoc/function/utils.rb +4 -7
  13. data/lib/isodoc/headlesshtml_convert.rb +0 -2
  14. data/lib/isodoc/html_convert.rb +0 -2
  15. data/lib/isodoc/html_function/postprocess.rb +2 -1
  16. data/lib/isodoc/html_function/postprocess_footnotes.rb +2 -1
  17. data/lib/isodoc/pdf_convert.rb +0 -2
  18. data/lib/isodoc/presentation_function/block.rb +21 -25
  19. data/lib/isodoc/presentation_function/concepts.rb +7 -8
  20. data/lib/isodoc/presentation_function/erefs.rb +2 -3
  21. data/lib/isodoc/presentation_function/footnotes.rb +140 -0
  22. data/lib/isodoc/presentation_function/image.rb +0 -18
  23. data/lib/isodoc/presentation_function/inline.rb +11 -13
  24. data/lib/isodoc/presentation_function/refs.rb +9 -4
  25. data/lib/isodoc/presentation_function/sourcecode.rb +2 -19
  26. data/lib/isodoc/presentation_xml_convert.rb +3 -1
  27. data/lib/isodoc/version.rb +1 -1
  28. data/lib/isodoc/word_function/body.rb +5 -3
  29. data/lib/isodoc/word_function/footnotes.rb +57 -68
  30. data/lib/isodoc/word_function/postprocess.rb +6 -2
  31. data/lib/isodoc/xref/xref_gen.rb +1 -9
  32. data/lib/isodoc/xref/xref_gen_seq.rb +47 -92
  33. data/lib/isodoc/xref/xref_util.rb +49 -0
  34. metadata +19 -3
  35. data/lib/isodoc/html_function/footnotes.rb +0 -92
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60e7a916df30b4032fbe9f1b2dcc6cec2563759b21525f9a7aa932f1f0dd2a24
4
- data.tar.gz: 4f4add705922211d501cafbd282df7402cb5228baae6300f62dd1868a42aac2f
3
+ metadata.gz: aa02186be0f73d998dca870f3559df00184697cc3582ef302eb934e4901d1ab1
4
+ data.tar.gz: 54cf027ca0fcab8ec1c97b35d7ada8ec7137a32a2adeecfa2c0cb9b653b3b0f2
5
5
  SHA512:
6
- metadata.gz: 7f4074992a9e19be5425fbf4dcc169ea31f57754261da482b33b5dde2ee14f210f0b4ca3419676268d3fccc9d0aa978e8fe06806d2b3754da6d13116e7332b1b
7
- data.tar.gz: 2b6e8718338825d52344fbda655c4fee4d3593dc46a65879a7b178a111923aeefb78c96f201de2a9b8d982a50f0fe4e83453902312aa7d8150d968d0b0bea6ee
6
+ metadata.gz: 251471002a6b16dd050364344f6a63e99b0e3b266a0dcc65cb4f83382b5ebfece49cc75ea65229282ef61a7206fb1ac4d7aba441b86b19704c6d9d00398ce3f2
7
+ data.tar.gz: 5fde838af0af79d78ccc4fecd730bc64cc60e6afaf68691f5e046d18ada04df54a922b61d98b22632a9395e21caa4c0cbbafceea70c729da839f9b732beb54c9
data/isodoc.gemspec CHANGED
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
44
44
  spec.add_dependency "thread_safe"
45
45
  spec.add_dependency "twitter_cldr", ">= 6.6.0"
46
46
  spec.add_dependency "uuidtools"
47
+ spec.add_dependency "lutaml-model", "~> 0.6.0"
47
48
 
48
49
  spec.add_development_dependency "bigdecimal"
49
50
  spec.add_development_dependency "debug"
@@ -53,18 +54,7 @@ Gem::Specification.new do |spec|
53
54
  spec.add_development_dependency "rake", "~> 13.0"
54
55
  spec.add_development_dependency "rspec", "~> 3.6"
55
56
  spec.add_development_dependency "rubocop", "~> 1"
56
- spec.add_development_dependency "rubocop-performance"
57
- =begin
58
- if RUBY_VERSION.start_with?("3.1")
59
- spec.add_development_dependency "sassc-embedded", "1.54.0"
60
- spec.add_development_dependency "sass-embedded", "1.54.2"
61
- else
62
- spec.add_development_dependency "sassc-embedded", "~> 1"
63
- spec.add_development_dependency "sass-embedded", "~> 1"
64
- end
65
- #spec.add_development_dependency "sassc-embedded", "~> 1"
66
- =end
67
- #spec.add_development_dependency "sassc"
57
+ spec.add_development_dependency "rubocop-performance"
68
58
  spec.add_development_dependency "sassc-embedded", "~> 1"
69
59
  spec.add_development_dependency "simplecov", "~> 0.15"
70
60
  spec.add_development_dependency "timecop", "~> 0.9"
data/lib/isodoc/common.rb CHANGED
@@ -2,6 +2,7 @@ require_relative "function/blocks"
2
2
  require_relative "function/cleanup"
3
3
  require_relative "function/form"
4
4
  require_relative "function/inline"
5
+ require_relative "function/footnotes"
5
6
  require_relative "function/lists"
6
7
  require_relative "function/references"
7
8
  require_relative "function/section"
@@ -18,6 +19,7 @@ module IsoDoc
18
19
  include Function::Cleanup
19
20
  include Function::Form
20
21
  include Function::Inline
22
+ include Function::Footnotes
21
23
  include Function::Lists
22
24
  include Function::References
23
25
  include Function::Section
@@ -192,6 +192,18 @@ module IsoDoc
192
192
  end
193
193
 
194
194
  def columnbreak_parse(node, out); end
195
+
196
+ # we dont't want figure dl/dd/fmt-fn-body to be processed
197
+ # as actual footnotes
198
+ def fmt_fn_body_parse(node, out)
199
+ node.ancestors("table, figure").empty? and
200
+ node.at(ns(".//fmt-fn-label"))&.remove
201
+ aside = node.parent.name == "fmt-footnote-container"
202
+ tag = aside ? "aside" : "div"
203
+ out.send tag, id: "fn:#{node['reference']}", class: "footnote" do |div|
204
+ node.children.each { |n| parse(n, div) }
205
+ end
206
+ end
195
207
  end
196
208
  end
197
209
  end
@@ -16,7 +16,7 @@ module IsoDoc
16
16
  def cleanup(docxml)
17
17
  @i18n ||= i18n_init(@lang, @script, @locale)
18
18
  comment_cleanup(docxml)
19
- footnote_cleanup(docxml)
19
+ #footnote_cleanup(docxml)
20
20
  inline_header_cleanup(docxml)
21
21
  figure_cleanup(docxml)
22
22
  table_cleanup(docxml)
@@ -58,7 +58,7 @@ module IsoDoc
58
58
  docxml
59
59
  end
60
60
 
61
- # todo PRESENTATION XML
61
+ # KILL
62
62
  def footnote_cleanup(docxml)
63
63
  docxml.xpath('//a[@class = "FootnoteRef"]/sup')
64
64
  .each_with_index do |x, i|
@@ -68,7 +68,7 @@ module IsoDoc
68
68
  end
69
69
 
70
70
  def merge_fnref_into_fn_text(elem)
71
- fn = elem.at('.//span[@class="TableFootnoteRef"]/..')
71
+ fn = elem.at('.//span[@class="TableFootnoteRef"]/..') or return
72
72
  n = fn.next_element
73
73
  n&.children&.first&.add_previous_sibling(fn.remove)
74
74
  end
@@ -80,7 +80,7 @@ module IsoDoc
80
80
  merge_fnref_into_fn_text(a)
81
81
  a.name = "div"
82
82
  a["class"] = "TableFootnote"
83
- t << a.remove
83
+ t << a.remove # this is redundant
84
84
  end
85
85
  end
86
86
  table_footnote_cleanup_propagate(docxml)
@@ -142,14 +142,6 @@ module IsoDoc
142
142
  end
143
143
 
144
144
  def symbols_cleanup(docxml); end
145
-
146
- def table_footnote_reference_format(link)
147
- link
148
- end
149
-
150
- def footnote_reference_format(link)
151
- link
152
- end
153
145
  end
154
146
  end
155
147
  end
@@ -0,0 +1,57 @@
1
+ module IsoDoc
2
+ module Function
3
+ module Footnotes
4
+ def make_table_footnote_link(out, fnid, node)
5
+ attrs = { href: "##{fnid}", class: "TableFootnoteRef" }
6
+ sup = node.at(ns("./sup")) and sup.replace(sup.children)
7
+ out.a **attrs do |a|
8
+ children_parse(node, a)
9
+ end
10
+ end
11
+
12
+ def get_table_ancestor_id(node)
13
+ table = node.ancestors("table")
14
+ table.empty? and table = node.ancestors("figure")
15
+ table.empty? and return [nil, UUIDTools::UUID.random_create.to_s]
16
+ [table.last, table.last["id"]]
17
+ end
18
+
19
+ # @seen_footnote:
20
+ # do not output footnote text if we have already seen it for this table
21
+
22
+ def table_footnote_parse(node, out)
23
+ fn = node["reference"] || UUIDTools::UUID.random_create.to_s
24
+ table, tid = get_table_ancestor_id(node)
25
+ make_table_footnote_link(out, tid + fn, node.at(ns("./fmt-fn-label")))
26
+ # do not output footnote text if we have already seen it for this table
27
+ @seen_footnote.include?(tid + fn) and return
28
+ update_table_fn_body_ref(node, table, tid + fn)
29
+ @seen_footnote << (tid + fn)
30
+ end
31
+
32
+ def update_table_fn_body_ref(fnote, table, reference)
33
+ fnbody = table.at(ns(".//fmt-fn-body[@id = '#{fnote['target']}']")) or return
34
+ fnbody["reference"] = reference
35
+ sup = fnbody.at(ns(".//fmt-fn-label/sup")) and sup.replace(sup.children)
36
+ fnbody.xpath(ns(".//fmt-fn-label")).each do |s|
37
+ s["class"] = "TableFootnoteRef"
38
+ s.name = "span"
39
+ d = s.at(ns("./span[@class = 'fmt-caption-delim']")) and
40
+ s.next = d
41
+ end
42
+ end
43
+
44
+ def footnote_parse(node, out)
45
+ return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
46
+ !node.ancestors.map(&:name).include?("fmt-name")
47
+
48
+ fn = node["reference"] || UUIDTools::UUID.random_create.to_s
49
+ attrs = { class: "FootnoteRef", href: "#fn:#{fn}" }
50
+ f = node.at(ns("./fmt-fn-label"))
51
+ out.a **attrs do |a|
52
+ children_parse(f, a)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -15,8 +15,6 @@ module IsoDoc
15
15
  end
16
16
  end
17
17
 
18
- def location_parse(node, out); end
19
-
20
18
  # Presentation XML classes which we need not pass on to HTML or DOC
21
19
  SPAN_UNWRAP_CLASSES =
22
20
  %w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim
@@ -189,8 +187,6 @@ module IsoDoc
189
187
  end
190
188
  end
191
189
 
192
- def author_parse(node, out); end
193
-
194
190
  def semx_parse(node, out)
195
191
  children_parse(node, out)
196
192
  end
@@ -199,8 +195,9 @@ module IsoDoc
199
195
  node.children.each { |n| parse(n, out) }
200
196
  end
201
197
 
198
+ def location_parse(node, out); end
199
+ def author_parse(node, out); end
202
200
  def xref_label_parse(node, out); end
203
-
204
201
  def name_parse(node, out); end
205
202
  def semx_definition_parse(node, out); end
206
203
  def semx_xref_parse(node, out); end
@@ -209,7 +206,6 @@ module IsoDoc
209
206
  def semx_origin_parse(node, out); end
210
207
  def date_parse(node, out); end
211
208
  def semx_stem_parse(node, out); end
212
-
213
209
  def floating_title_parse(node, out); end
214
210
  def identifier_parse(node, out); end
215
211
  def concept_parse(node, out); end
@@ -233,6 +229,14 @@ module IsoDoc
233
229
  def fmt_date_parse(node, out)
234
230
  children_parse(node, out)
235
231
  end
232
+
233
+ def fmt_fn_label_parse(node, out)
234
+ children_parse(node, out)
235
+ end
236
+
237
+ def fmt_footnote_container_parse(node, out)
238
+ children_parse(node, out)
239
+ end
236
240
  end
237
241
  end
238
242
  end
@@ -219,6 +219,13 @@ module IsoDoc
219
219
  node.children.each { |n| parse(n, div) }
220
220
  end
221
221
  end
222
+
223
+ def footnotes(docxml, div)
224
+ docxml.xpath(ns("/*/fmt-footnote-container"))
225
+ .each do |fn|
226
+ fn.children.each { |n| parse(n, div) }
227
+ end
228
+ end
222
229
  end
223
230
  end
224
231
  end
@@ -0,0 +1,64 @@
1
+ require "fileutils"
2
+ require "pathname"
3
+
4
+ module IsoDoc
5
+ module Function
6
+ module ToWordHtml
7
+ def note?
8
+ @note
9
+ end
10
+
11
+ def init_file(filename, debug)
12
+ filepath = Pathname.new(filename)
13
+ filename = filepath.sub_ext("").sub(/\.presentation$/, "").to_s
14
+ dir = init_dir(filename, debug)
15
+ @filename = filename
16
+ @localdir = @baseassetpath || filepath.parent.to_s
17
+ @localdir += "/"
18
+ @sourcedir = @localdir
19
+ @sourcefilename and
20
+ @sourcedir = "#{Pathname.new(@sourcefilename).parent}/"
21
+ [filename, dir]
22
+ end
23
+
24
+ def init_dir(filename, debug)
25
+ dir = "#{filename}#{@tmpfilesdir_suffix}"
26
+ unless debug
27
+ FileUtils.mkdir_p(dir)
28
+ FileUtils.chmod 0o777, dir
29
+ FileUtils.rm_rf "#{dir}/*"
30
+ end
31
+ dir
32
+ end
33
+
34
+ # tmp image dir is same directory as @filename
35
+ def tmpimagedir
36
+ @filename + @tmpimagedir_suffix
37
+ end
38
+
39
+ def rel_tmpimagedir
40
+ Pathname.new(@filename).basename.to_s + @tmpimagedir_suffix
41
+ end
42
+
43
+ def info(isoxml, out)
44
+ @meta.code_css isoxml, out
45
+ @meta.title isoxml, out
46
+ @meta.subtitle isoxml, out
47
+ @meta.docstatus isoxml, out
48
+ @meta.docid isoxml, out
49
+ @meta.otherid isoxml, out
50
+ @meta.docnumeric isoxml, out
51
+ @meta.doctype isoxml, out
52
+ @meta.author isoxml, out
53
+ @meta.bibdate isoxml, out
54
+ @meta.relations isoxml, out
55
+ @meta.version isoxml, out
56
+ @meta.url isoxml, out
57
+ @meta.keywords isoxml, out
58
+ @meta.note isoxml, out
59
+ @meta.presentation isoxml, out
60
+ @meta.get
61
+ end
62
+ end
63
+ end
64
+ end
@@ -86,6 +86,8 @@ module IsoDoc
86
86
  (dl = node.at(ns("./dl"))) && parse(dl, out)
87
87
  node.xpath(ns("./source")).each { |n| parse(n, out) }
88
88
  node.xpath(ns("./note")).each { |n| parse(n, out) }
89
+ node.xpath(ns("./fmt-footnote-container/fmt-fn-body"))
90
+ .each { |n| parse(n, out) }
89
91
  end
90
92
 
91
93
  def table_parse_core(node, out)
@@ -1,45 +1,10 @@
1
1
  require "fileutils"
2
2
  require "pathname"
3
+ require_relative "setup"
3
4
 
4
5
  module IsoDoc
5
6
  module Function
6
7
  module ToWordHtml
7
- def note?
8
- @note
9
- end
10
-
11
- def init_file(filename, debug)
12
- filepath = Pathname.new(filename)
13
- filename = filepath.sub_ext("").sub(/\.presentation$/, "").to_s
14
- dir = init_dir(filename, debug)
15
- @filename = filename
16
- @localdir = @baseassetpath || filepath.parent.to_s
17
- @localdir += "/"
18
- @sourcedir = @localdir
19
- @sourcefilename and
20
- @sourcedir = "#{Pathname.new(@sourcefilename).parent}/"
21
- [filename, dir]
22
- end
23
-
24
- def init_dir(filename, debug)
25
- dir = "#{filename}#{@tmpfilesdir_suffix}"
26
- unless debug
27
- FileUtils.mkdir_p(dir)
28
- FileUtils.chmod 0o777, dir
29
- FileUtils.rm_rf "#{dir}/*"
30
- end
31
- dir
32
- end
33
-
34
- # tmp image dir is same directory as @filename
35
- def tmpimagedir
36
- @filename + @tmpimagedir_suffix
37
- end
38
-
39
- def rel_tmpimagedir
40
- Pathname.new(@filename).basename.to_s + @tmpimagedir_suffix
41
- end
42
-
43
8
  # isodoc.css overrides any CSS injected by Html2Doc, which
44
9
  # is inserted before this CSS.
45
10
  def define_head(head, _filename, _dir)
@@ -88,7 +53,7 @@ module IsoDoc
88
53
  body.div class: "main-section" do |div3|
89
54
  boilerplate docxml, div3
90
55
  content(div3, docxml, ns(self.class::TOP_ELEMENTS))
91
- footnotes div3
56
+ footnotes docxml, div3
92
57
  comments div3
93
58
  end
94
59
  end
@@ -129,26 +94,6 @@ module IsoDoc
129
94
  end
130
95
  end
131
96
 
132
- def info(isoxml, out)
133
- @meta.code_css isoxml, out
134
- @meta.title isoxml, out
135
- @meta.subtitle isoxml, out
136
- @meta.docstatus isoxml, out
137
- @meta.docid isoxml, out
138
- @meta.otherid isoxml, out
139
- @meta.docnumeric isoxml, out
140
- @meta.doctype isoxml, out
141
- @meta.author isoxml, out
142
- @meta.bibdate isoxml, out
143
- @meta.relations isoxml, out
144
- @meta.version isoxml, out
145
- @meta.url isoxml, out
146
- @meta.keywords isoxml, out
147
- @meta.note isoxml, out
148
- @meta.presentation isoxml, out
149
- @meta.get
150
- end
151
-
152
97
  def cross_align(isoxml, out)
153
98
  isoxml.xpath(ns("//cross-align")).each do |c|
154
99
  parse(c, out)
@@ -286,6 +231,9 @@ module IsoDoc
286
231
  when "amend" then amend_parse(node, out)
287
232
  when "date" then date_parse(node, out)
288
233
  when "fmt-date" then fmt_date_parse(node, out)
234
+ when "fmt-fn-body" then fmt_fn_body_parse(node, out)
235
+ when "fmt-fn-label" then fmt_fn_label_parse(node, out)
236
+ when "fmt-footnote-container" then fmt_footnote_container_parse(node, out)
289
237
  else error_parse(node, out)
290
238
  end
291
239
  end
@@ -107,8 +107,7 @@ module IsoDoc
107
107
  end
108
108
 
109
109
  def sentence_join(array)
110
- return "" if array.nil? || array.empty?
111
-
110
+ array.nil? || array.empty? and return ""
112
111
  if array.length == 1 then array[0]
113
112
  else
114
113
  @i18n.l10n("#{array[0..-2].join(', ')} " \
@@ -242,11 +241,9 @@ module IsoDoc
242
241
  def external_path(path)
243
242
  win = !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) ||
244
243
  (RUBY_PLATFORM =~ /mswin|mingw/))
245
- if win
246
- path.tr!(%{/}, "\\")
247
- path[/\s/] ? "\"#{path}\"" : path
248
- else path
249
- end
244
+ win or return path
245
+ path.tr!(%{/}, "\\")
246
+ path[/\s/] ? "\"#{path}\"" : path
250
247
  end
251
248
  end
252
249
  end
@@ -1,12 +1,10 @@
1
1
  require_relative "html_function/comments"
2
- require_relative "html_function/footnotes"
3
2
  require_relative "html_function/html"
4
3
  require "fileutils"
5
4
 
6
5
  module IsoDoc
7
6
  class HeadlessHtmlConvert < ::IsoDoc::Convert
8
7
  include HtmlFunction::Comments
9
- include HtmlFunction::Footnotes
10
8
  include HtmlFunction::Html
11
9
 
12
10
  def tmpimagedir_suffix
@@ -1,5 +1,4 @@
1
1
  require_relative "html_function/comments"
2
- require_relative "html_function/footnotes"
3
2
  require_relative "html_function/html"
4
3
  require_relative "html_function/postprocess"
5
4
  require_relative "html_function/form"
@@ -8,7 +7,6 @@ module IsoDoc
8
7
  class HtmlConvert < ::IsoDoc::Convert
9
8
 
10
9
  include HtmlFunction::Comments
11
- include HtmlFunction::Footnotes
12
10
  include HtmlFunction::Form
13
11
  include HtmlFunction::Html
14
12
 
@@ -26,7 +26,8 @@ module IsoDoc
26
26
 
27
27
  def html_cleanup(html)
28
28
  html = term_header(html_footnote_filter(html_preface(htmlstyle(html))))
29
- html = footnote_format(footnote_backlinks(html))
29
+ #html = footnote_format(footnote_backlinks(html))
30
+ html = (footnote_backlinks(html))
30
31
  html = mathml(html_list_clean(remove_placeholder_paras(html)))
31
32
  html_toc(heading_anchors(sourcecode_cleanup(html)))
32
33
  end
@@ -49,7 +49,8 @@ module IsoDoc
49
49
  docxml
50
50
  end
51
51
 
52
- def footnote_format(docxml)
52
+ # KILL
53
+ def footnote_formatx(docxml)
53
54
  docxml.xpath("//a[@class = 'FootnoteRef']/sup").each do |x|
54
55
  footnote_reference_format(x)
55
56
  end
@@ -1,11 +1,9 @@
1
1
  require_relative "html_function/comments"
2
- require_relative "html_function/footnotes"
3
2
  require_relative "html_function/html"
4
3
 
5
4
  module IsoDoc
6
5
  class PdfConvert < ::IsoDoc::Convert
7
6
  include HtmlFunction::Comments
8
- include HtmlFunction::Footnotes
9
7
  include HtmlFunction::Html
10
8
 
11
9
  def initialize(options)
@@ -8,7 +8,8 @@ module IsoDoc
8
8
  def lower2cap(text)
9
9
  text.nil? and return text
10
10
  x = Nokogiri::XML("<a>#{text}</a>")
11
- firsttext = x.at(".//text()[string-length(normalize-space(.))>0]") or return text
11
+ firsttext = x.at(".//text()[string-length(normalize-space(.))>0]") or
12
+ return text
12
13
  /^[[:upper:]][[:upper:]]/.match?(firsttext.text) and return text
13
14
  firsttext.replace(firsttext.text.capitalize)
14
15
  to_xml(x.root.children)
@@ -80,7 +81,6 @@ module IsoDoc
80
81
  end
81
82
 
82
83
  def admonition_numbered1(elem)
83
- # elem["unnumbered"] && !elem.at(ns("./name")) and return
84
84
  label = admonition_label(elem, @xrefs.anchor(elem["id"], :label, false))
85
85
  prefix_name(elem, { caption: block_delim }, label, "name")
86
86
  end
@@ -88,8 +88,6 @@ module IsoDoc
88
88
  def admonition_label(elem, num)
89
89
  lbl = if elem["type"] == "box" then @i18n.box
90
90
  else @i18n.admonition[elem["type"]]&.upcase end
91
- #lbl &&= "<span class='fmt-element-name'>#{lbl}</span>"
92
- #num and lbl = l10n("#{lbl} #{autonum(elem['id'], num)}")
93
91
  labelled_autonum(lbl, elem["id"], num)
94
92
  end
95
93
 
@@ -107,8 +105,6 @@ module IsoDoc
107
105
  labelled_ancestor(elem) and return
108
106
  elem["unnumbered"] && !elem.at(ns("./name")) and return
109
107
  n = @xrefs.anchor(elem["id"], :label, false)
110
- #lbl = "<span class='fmt-element-name'>#{lower2cap @i18n.table}</span> "\
111
- #"#{autonum(elem['id'], n)}"
112
108
  lbl = labelled_autonum(lower2cap(@i18n.table), elem["id"], n)
113
109
  prefix_name(elem, { caption: table_delim }, l10n(lbl), "name")
114
110
  end
@@ -128,15 +124,6 @@ module IsoDoc
128
124
  end
129
125
  end
130
126
 
131
- def table_fn(elem)
132
- (elem.xpath(ns(".//fn")) - elem.xpath(ns("./name//fn")))
133
- .each_with_index do |f, i|
134
- table_fn1(elem, f, i)
135
- end
136
- end
137
-
138
- def table_fn1(table, fnote, idx); end
139
-
140
127
  def amend(docxml)
141
128
  docxml.xpath(ns("//amend")).each { |f| amend1(f) }
142
129
  end
@@ -233,19 +220,28 @@ module IsoDoc
233
220
  author = elem.at(ns("./author"))
234
221
  source = elem.at(ns("./source"))
235
222
  author.nil? && source.nil? and return
223
+ p = quote_attribution(author, source, elem)
224
+ elem << "<attribution><p>#{l10n p}</p></attribution>"
225
+ end
226
+
227
+ # e["deleteme"]: duplicate of source, will be duplicated in fmt-eref,
228
+ # need to delete after
229
+ def quote_attribution(author, source, elem)
236
230
  p = "&#x2014; "
237
231
  p += to_xml(semx_fmt_dup(author)) if author
238
232
  p += ", " if author && source
239
- if source
240
- s = semx_fmt_dup(source)
241
- e = Nokogiri::XML::Node.new("eref", elem.document)
242
- e << s.children
243
- s << e
244
- source.attributes.each_key { |k| e[k] = source[k] }
245
- e["deleteme"] = "true" # duplicate of source, will be duplicated in fmt-eref, need to delete after
246
- p += to_xml(s)
247
- end
248
- elem << "<attribution><p>#{l10n p}</p></attribution>"
233
+ source or return p
234
+ p + to_xml(quote_source(source, elem))
235
+ end
236
+
237
+ def quote_source(source, elem)
238
+ s = semx_fmt_dup(source)
239
+ e = Nokogiri::XML::Node.new("eref", elem.document)
240
+ e << s.children
241
+ s << e
242
+ source.attributes.each_key { |k| e[k] = source[k] }
243
+ e["deleteme"] = "true"
244
+ s
249
245
  end
250
246
  end
251
247
  end
@@ -20,7 +20,6 @@ module IsoDoc
20
20
  end
21
21
 
22
22
  def concept_render(node, defaults)
23
- #require "debug"; binding.b
24
23
  opts, render, ref, ret = concept_render_init(node, defaults)
25
24
  ret&.at(ns("./refterm"))&.remove
26
25
  ref && opts[:ref] != "false" and render&.next = " "
@@ -31,7 +30,8 @@ module IsoDoc
31
30
  end
32
31
 
33
32
  def concept_dup(node, ret)
34
- node.xpath(".//xmlns:semx[xmlns:fmt-xref | xmlns:fmt-eref | xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
33
+ node.xpath(".//xmlns:semx[xmlns:fmt-xref | xmlns:fmt-eref | " \
34
+ "xmlns:fmt-origin | xmlns:fmt-link]").each(&:remove)
35
35
  ret.xpath(ns(".//xref | .//eref | .//origin | .//link")).each(&:remove)
36
36
  ret.xpath(ns(".//semx")).each do |s|
37
37
  s.children.empty? and s.remove
@@ -66,10 +66,11 @@ module IsoDoc
66
66
  (opts[:linkmention] == "true" && !renderterm.nil? && !ref.nil?) or return
67
67
  ref2 = ref.clone
68
68
  r2 = renderterm.clone
69
- #renderterm.replace(ref2).children = r2
70
69
  ref2.children = r2
71
70
  if ref.parent.name == "semx"
72
- renderterm.replace("<semx element='#{ref.parent['element']}' source='#{ref.parent['source']}'>#{to_xml(ref2)}</semx>")
71
+ renderterm.replace(<<~SEMX)
72
+ <semx element='#{ref.parent['element']}' source='#{ref.parent['source']}'>#{to_xml(ref2)}</semx>
73
+ SEMX
73
74
  else
74
75
  renderterm.replace(ref2)
75
76
  end
@@ -103,7 +104,7 @@ module IsoDoc
103
104
  p, ref, orig = related1_prep(node)
104
105
  label = @i18n.relatedterms[orig["type"]].upcase
105
106
  if p && ref
106
- node.children =(l10n("<p><strong>#{label}:</strong> " \
107
+ node.children = (l10n("<p><strong>#{label}:</strong> " \
107
108
  "<em>#{to_xml(p)}</em> (#{Common::to_xml(ref)})</p>"))
108
109
  else
109
110
  node.children = (l10n("<p><strong>#{label}:</strong> " \
@@ -198,8 +199,6 @@ module IsoDoc
198
199
  def designation_annotate(desgn, name, orig)
199
200
  designation_boldface(desgn)
200
201
  designation_field(desgn, name, orig)
201
- #g = desgn.at(ns("./expression/grammar")) and
202
- #name << ", #{designation_grammar(g).join(', ')}"
203
202
  designation_grammar(desgn, name)
204
203
  designation_localization(desgn, name, orig)
205
204
  designation_pronunciation(desgn, name)
@@ -213,7 +212,7 @@ module IsoDoc
213
212
  name.children = "<strong>#{name.children}</strong>"
214
213
  end
215
214
 
216
- def designation_field(desgn, name, orig)
215
+ def designation_field(_desgn, name, orig)
217
216
  f = orig.xpath(ns("./field-of-application | ./usage-info"))
218
217
  &.map { |u| to_xml(semx_fmt_dup(u)) }&.join(", ")
219
218
  f&.empty? and return nil