isodoc 2.1.0.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +6 -3
  3. data/lib/isodoc/base_style/blocks.scss +7 -0
  4. data/lib/isodoc/class_utils.rb +1 -1
  5. data/lib/isodoc/function/blocks.rb +1 -1
  6. data/lib/isodoc/function/cleanup.rb +1 -1
  7. data/lib/isodoc/function/inline.rb +4 -2
  8. data/lib/isodoc/function/lists.rb +24 -9
  9. data/lib/isodoc/function/table.rb +1 -1
  10. data/lib/isodoc/function/to_word_html.rb +3 -2
  11. data/lib/isodoc/function/utils.rb +18 -8
  12. data/lib/isodoc/gem_tasks.rb +19 -10
  13. data/lib/isodoc/html_function/html.rb +2 -2
  14. data/lib/isodoc/i18n.rb +19 -0
  15. data/lib/isodoc/metadata.rb +2 -2
  16. data/lib/isodoc/presentation_function/block.rb +3 -3
  17. data/lib/isodoc/presentation_function/image.rb +1 -1
  18. data/lib/isodoc/presentation_function/inline.rb +13 -6
  19. data/lib/isodoc/presentation_function/section.rb +3 -1
  20. data/lib/isodoc/presentation_function/xrefs.rb +22 -6
  21. data/lib/isodoc/presentation_xml_convert.rb +1 -0
  22. data/lib/isodoc/version.rb +1 -1
  23. data/lib/isodoc/word_function/body.rb +9 -6
  24. data/lib/isodoc/word_function/postprocess.rb +1 -1
  25. data/lib/isodoc/word_function/postprocess_cover.rb +5 -5
  26. data/lib/isodoc/xref/xref_gen.rb +4 -4
  27. metadata +5 -66
  28. data/.github/workflows/rake.yml +0 -15
  29. data/.github/workflows/release.yml +0 -24
  30. data/.hound.yml +0 -5
  31. data/.oss-guides.rubocop.yml +0 -1077
  32. data/.rubocop.yml +0 -10
  33. data/Rakefile +0 -8
  34. data/bin/rspec +0 -17
  35. data/spec/assets/header.html +0 -7
  36. data/spec/assets/html.scss +0 -20
  37. data/spec/assets/html_override.css +0 -1
  38. data/spec/assets/htmlcover.html +0 -4
  39. data/spec/assets/htmlintro.html +0 -5
  40. data/spec/assets/i18n.yaml +0 -41
  41. data/spec/assets/iso.xml +0 -8
  42. data/spec/assets/odf.emf +0 -0
  43. data/spec/assets/odf.svg +0 -1
  44. data/spec/assets/odf1.svg +0 -4
  45. data/spec/assets/outputtest/a.xml +0 -66
  46. data/spec/assets/outputtest/iso.international-standard.xsl +0 -3011
  47. data/spec/assets/rice_image1 +0 -0
  48. data/spec/assets/rice_image1.png +0 -0
  49. data/spec/assets/scripts.html +0 -3
  50. data/spec/assets/scripts_override.html +0 -3
  51. data/spec/assets/std.css +0 -2
  52. data/spec/assets/word.css +0 -2
  53. data/spec/assets/word_override.css +0 -1
  54. data/spec/assets/wordcover.html +0 -3
  55. data/spec/assets/wordintro.html +0 -4
  56. data/spec/isodoc/blocks_spec.rb +0 -2934
  57. data/spec/isodoc/cleanup_spec.rb +0 -1056
  58. data/spec/isodoc/footnotes_spec.rb +0 -264
  59. data/spec/isodoc/form_spec.rb +0 -160
  60. data/spec/isodoc/i18n_spec.rb +0 -1201
  61. data/spec/isodoc/inline_spec.rb +0 -2301
  62. data/spec/isodoc/lists_spec.rb +0 -469
  63. data/spec/isodoc/metadata_spec.rb +0 -401
  64. data/spec/isodoc/postproc_spec.rb +0 -2941
  65. data/spec/isodoc/presentation_xml_spec.rb +0 -1476
  66. data/spec/isodoc/ref_spec.rb +0 -955
  67. data/spec/isodoc/section_spec.rb +0 -2123
  68. data/spec/isodoc/table_spec.rb +0 -588
  69. data/spec/isodoc/terms_spec.rb +0 -712
  70. data/spec/isodoc/utils_spec.rb +0 -57
  71. data/spec/isodoc/xref_numbering_spec.rb +0 -378
  72. data/spec/isodoc/xref_spec.rb +0 -1837
  73. data/spec/isodoc/xslfo_convert_spec.rb +0 -103
  74. data/spec/spec_helper.rb +0 -81
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc4bad696f0cd3e8c530eaf2c0b7722379d8412a055a2431d6367a9a0d6a939b
4
- data.tar.gz: 2529ca812cfe2e7c229c03fd9e9e2d0d367ccb92d9413837fa22446955519417
3
+ metadata.gz: 28ac8ba37e46dab584c5c8b31b651a3c35554c48a286edbe27380837d8cf2bcb
4
+ data.tar.gz: b8aa34af74f5ea34f01a8e80e5c9d3d9d1c8f04623e490efcd4ef405fa3d9d89
5
5
  SHA512:
6
- metadata.gz: 42adec43794af927dcba7cb365d0044d2b1544a13a63f11fee15e66096e42329c6dea9949b2b4d70a2689a81daffe8d7b87772d4131199688fe4abfc88104d24
7
- data.tar.gz: b352d2087309de8f6b478835419ebddbdf31f5dee372de95276072381332a6836d971446fe61efe4ede949c6f7798e1e34c8d6462cf41543278667242596f2ca
6
+ metadata.gz: 48b4097c940f272ce85bb6ccce887df0640525d90176246b00772f2b858daf1a8a3710ccd06766048a2c57030abbed6a72f122dddd084717604e30d08290b01d
7
+ data.tar.gz: 21cc6a5137d95431098706c1f0a71f2ce759da10fdd892bb8cf7fcbc7a74dbc671a5d8bb90d7e1ec072d7eb3a3aa618112dade4dda0a3944a4a9e95455bd1748
data/isodoc.gemspec CHANGED
@@ -24,12 +24,15 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.bindir = "bin"
26
26
  spec.require_paths = ["lib"]
27
- spec.files = `git ls-files`.split("\n")
27
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
28
+ f.match(%r{^(test|spec|features|.github)/}) \
29
+ || f.match(%r{\.[a-zA-Z0-9_-]+\.yml|Rakefile|bin/rspec})
30
+ end
28
31
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
29
32
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
30
33
 
31
34
  spec.add_dependency "asciimath"
32
- spec.add_dependency "html2doc", "~> 1.4.0"
35
+ spec.add_dependency "html2doc", "~> 1.4.1"
33
36
  spec.add_dependency "htmlentities", "~> 4.3.4"
34
37
  spec.add_dependency "isodoc-i18n", "~> 1.0.0"
35
38
  spec.add_dependency "liquid", "~> 4"
@@ -37,7 +40,7 @@ Gem::Specification.new do |spec|
37
40
  spec.add_dependency "emf2svg"
38
41
  spec.add_dependency "mathml2asciimath"
39
42
  spec.add_dependency "metanorma-utils"
40
- spec.add_dependency "nokogiri", "~> 1.12.0"
43
+
41
44
  spec.add_dependency "relaton-cli"
42
45
  spec.add_dependency "relaton-render", ">= 0.3.1"
43
46
  spec.add_dependency "roman-numerals"
@@ -23,6 +23,13 @@
23
23
  }
24
24
  }
25
25
 
26
+ @mixin listBlock() {
27
+ .ListTitle {
28
+ @include blockTitle();
29
+ text-align: left;
30
+ }
31
+ }
32
+
26
33
  @mixin figureBlock() {
27
34
  .FigureTitle, .figure-title {
28
35
  @include blockTitle();
@@ -7,7 +7,7 @@ module IsoDoc
7
7
  return date.text unless from || on || to
8
8
  return on.text if on
9
9
 
10
- ret = "#{from.text}–"
10
+ ret = "#{from.text}–"
11
11
  ret += to.text if to
12
12
  ret
13
13
  end
@@ -169,7 +169,7 @@ module IsoDoc
169
169
  return if author.nil? && source.nil?
170
170
 
171
171
  out.p **{ class: "QuoteAttribution" } do |p|
172
- p << "&mdash; #{author.text}" if author
172
+ p << "&#x2014; #{author.text}" if author
173
173
  p << ", " if author && source
174
174
  eref_parse(source, p) if source
175
175
  end
@@ -66,7 +66,7 @@ module IsoDoc
66
66
  title = d.at("./title")
67
67
  n = title.next_element
68
68
  n&.children&.first
69
- &.add_previous_sibling("#{title.remove.text}&mdash;")
69
+ &.add_previous_sibling("#{title.remove.text}&#x2014;")
70
70
  end
71
71
  docxml
72
72
  end
@@ -14,6 +14,8 @@ module IsoDoc
14
14
  end
15
15
  end
16
16
 
17
+ def location_parse(node, out); end
18
+
17
19
  def span_parse(node, out)
18
20
  node.children.each { |n| parse(n, out) }
19
21
  end
@@ -134,8 +136,8 @@ module IsoDoc
134
136
 
135
137
  text = node.to_s
136
138
  if in_sourcecode
137
- text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/>&nbsp;")
138
- .gsub(/ (?= )/, "&nbsp;")
139
+ text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/>&#xa0;")
140
+ .gsub(/ (?= )/, "&#xa0;")
139
141
  end
140
142
  out << text
141
143
  end
@@ -1,13 +1,21 @@
1
1
  module IsoDoc
2
2
  module Function
3
3
  module Lists
4
+ def list_title_parse(node, out)
5
+ name = node.at(ns("./name")) or return
6
+ out.p **{ class: "ListTitle" } do |p|
7
+ name&.children&.each { |n| parse(n, p) }
8
+ end
9
+ end
10
+
4
11
  def ul_attrs(node)
5
12
  { id: node["id"], style: keep_style(node) }
6
13
  end
7
14
 
8
15
  def ul_parse(node, out)
16
+ list_title_parse(node, out)
9
17
  out.ul **attr_code(ul_attrs(node)) do |ul|
10
- node.children.each { |n| parse(n, ul) }
18
+ node.children.each { |n| n.name == "name" or parse(n, ul) }
11
19
  end
12
20
  end
13
21
 
@@ -44,8 +52,9 @@ module IsoDoc
44
52
  end
45
53
 
46
54
  def ol_parse(node, out)
55
+ list_title_parse(node, out)
47
56
  out.ol **attr_code(ol_attrs(node)) do |ol|
48
- node.children.each { |n| parse(n, ol) }
57
+ node.children.each { |n| n.name == "name" or parse(n, ol) }
49
58
  end
50
59
  end
51
60
 
@@ -82,17 +91,23 @@ module IsoDoc
82
91
  end
83
92
 
84
93
  def dl_parse(node, out)
94
+ list_title_parse(node, out)
85
95
  out.dl **dl_attrs(node) do |v|
86
96
  node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
87
- v.dt **attr_code(id: dt["id"]) do |term|
88
- dt_parse(dt, term)
89
- end
90
- v.dd **attr_code(id: dd["id"]) do |listitem|
91
- dd.children.each { |n| parse(n, listitem) }
92
- end
97
+ dl_parse1(v, dt, dd)
93
98
  end
94
99
  end
95
- node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, out) }
100
+ node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
101
+ .each { |n| parse(n, out) }
102
+ end
103
+
104
+ def dl_parse1(dlist, dterm, ddef)
105
+ dlist.dt **attr_code(id: dterm["id"]) do |term|
106
+ dt_parse(dterm, term)
107
+ end
108
+ dlist.dd **attr_code(id: ddef["id"]) do |listitem|
109
+ ddef.children.each { |n| parse(n, listitem) }
110
+ end
96
111
  end
97
112
  end
98
113
  end
@@ -82,7 +82,7 @@ module IsoDoc
82
82
  node.xpath(ns("./note")).each { |n| parse(n, out) }
83
83
  end
84
84
  @in_table = false
85
- # out.p { |p| p << "&nbsp;" }
85
+ # out.p { |p| p << "&#xa0;" }
86
86
  end
87
87
 
88
88
  SW = "solid windowtext".freeze
@@ -73,14 +73,14 @@ module IsoDoc
73
73
 
74
74
  def make_body1(body, _docxml)
75
75
  body.div **{ class: "title-section" } do |div1|
76
- div1.p { |p| p << "&nbsp;" } # placeholder
76
+ div1.p { |p| p << "&#xa0;" } # placeholder
77
77
  end
78
78
  section_break(body)
79
79
  end
80
80
 
81
81
  def make_body2(body, _docxml)
82
82
  body.div **{ class: "prefatory-section" } do |div2|
83
- div2.p { |p| p << "&nbsp;" } # placeholder
83
+ div2.p { |p| p << "&#xa0;" } # placeholder
84
84
  end
85
85
  section_break(body)
86
86
  end
@@ -231,6 +231,7 @@ module IsoDoc
231
231
  when "toc" then toc_parse(node, out)
232
232
  when "variant-title" then variant_title(node, out)
233
233
  when "span" then span_parse(node, out)
234
+ when "location" then location_parse(node, out)
234
235
  else error_parse(node, out)
235
236
  end
236
237
  end
@@ -12,7 +12,7 @@ module IsoDoc
12
12
  end
13
13
 
14
14
  def insert_tab(out, count)
15
- tab = %w(Hans Hant).include?(@script) ? "&#x3000;" : "&nbsp; "
15
+ tab = %w(Hans Hant).include?(@script) ? "&#x3000;" : "&#xa0; "
16
16
  [1..count].each { out << tab }
17
17
  end
18
18
 
@@ -58,24 +58,30 @@ module IsoDoc
58
58
  end
59
59
  end
60
60
 
61
- def to_xhtml_prep(xml)
62
- xml.gsub!(/<\?xml[^>]*>/, "")
63
- /<!DOCTYPE /.match(xml) || (xml = DOCTYPE_HDR + xml)
61
+ def numeric_escapes(xml)
62
+ c = HTMLEntities.new
64
63
  xml.split(/(&[^ \r\n\t#;]+;)/).map do |t|
65
64
  if /^(&[^ \t\r\n#;]+;)/.match?(t)
66
- HTMLEntities.new.encode(HTMLEntities.new.decode(t), :hexadecimal)
65
+ c.encode(c.decode(t), :hexadecimal)
67
66
  else t
68
67
  end
69
68
  end.join
70
69
  end
71
70
 
71
+ def to_xhtml_prep(xml)
72
+ xml.gsub!(/<\?xml[^>]*>/, "")
73
+ /<!DOCTYPE /.match(xml) || (xml = DOCTYPE_HDR + xml)
74
+ numeric_escapes(xml)
75
+ end
76
+
72
77
  def to_xhtml_fragment(xml)
73
78
  doc = ::Nokogiri::XML.parse(NOKOHEAD)
74
79
  doc.fragment(xml)
75
80
  end
76
81
 
77
82
  def from_xhtml(xml)
78
- xml.to_xml.sub(%r{ xmlns="http://www.w3.org/1999/xhtml"}, "")
83
+ numeric_escapes(xml.to_xml
84
+ .sub(%r{ xmlns="http://www.w3.org/1999/xhtml"}, ""))
79
85
  end
80
86
 
81
87
  CLAUSE_ANCESTOR =
@@ -100,8 +106,12 @@ module IsoDoc
100
106
  "local-name() = 'figure' or local-name() = 'formula' or "\
101
107
  "local-name() = 'table' or local-name() = 'example']/@id"
102
108
 
103
- def get_note_container_id(node)
104
- container = node.xpath(NOTE_CONTAINER_ANCESTOR)
109
+ # no recursion on references
110
+ def get_note_container_id(node, type)
111
+ xpath = NOTE_CONTAINER_ANCESTOR.dup
112
+ %w(figure table example).include?(type) and
113
+ xpath.sub!(%r[ or local-name\(\) = '#{type}'], "")
114
+ container = node.xpath(xpath)
105
115
  container&.last&.text || nil
106
116
  end
107
117
 
@@ -8,14 +8,20 @@ module IsoDoc
8
8
  module GemTasks
9
9
  extend Rake::DSL if defined? Rake::DSL
10
10
 
11
+ @@css_list = []
12
+
11
13
  module_function
12
14
 
15
+ def self.css_list
16
+ @@css_list
17
+ end
18
+
13
19
  def install
14
20
  rule ".css" => [proc { |tn| tn.sub(/\.css$/, ".scss") }] do |current_task|
15
21
  puts(current_task)
16
22
  compile_scss_task(current_task)
17
23
  rescue StandardError => e
18
- notify_borken_compilation(e, current_task)
24
+ notify_broken_compilation(e, current_task)
19
25
  end
20
26
 
21
27
  scss_files = Rake::FileList["lib/**/*.scss"]
@@ -40,25 +46,27 @@ module IsoDoc
40
46
  end
41
47
  end
42
48
 
43
- def notify_borken_compilation(error, current_task)
49
+ def interactive?
50
+ ENV["CI"] == nil
51
+ end
52
+
53
+ def notify_broken_compilation(error, current_task)
44
54
  puts("Cannot compile #{current_task} because of #{error.message}")
55
+ return unless interactive?
56
+
45
57
  puts("continue anyway[y|n]?")
46
- answer = STDIN.gets.strip
47
- if %w[y yes].include?(answer.strip.downcase)
48
- puts("Cannot compile #{current_task} because of #{error.message}")
49
- else
50
- exit(0)
51
- end
58
+ answer = $stdin.gets.strip
59
+ exit(0) unless %w[y yes].include?(answer.strip.downcase)
52
60
  end
53
61
 
54
62
  def git_cache_compiled_files
55
- CLEAN.each do |css_file|
63
+ @@css_list.each do |css_file|
56
64
  sh "git add #{css_file}"
57
65
  end
58
66
  end
59
67
 
60
68
  def git_rm_compiled_files
61
- CLEAN.each do |css_file|
69
+ @@css_list.each do |css_file|
62
70
  sh "git rm --cached #{css_file}"
63
71
  end
64
72
  end
@@ -129,6 +137,7 @@ module IsoDoc
129
137
  File.open(compiled_path, "w:UTF-8") do |f|
130
138
  f.write(content)
131
139
  end
140
+ @@css_list << compiled_path
132
141
  CLEAN << compiled_path
133
142
  end
134
143
  end
@@ -20,7 +20,7 @@ module IsoDoc
20
20
  return if @bare
21
21
 
22
22
  body.div **{ class: "title-section" } do |div1|
23
- div1.p { |p| p << "&nbsp;" } # placeholder
23
+ div1.p { |p| p << "&#xa0;" } # placeholder
24
24
  end
25
25
  section_break(body)
26
26
  end
@@ -29,7 +29,7 @@ module IsoDoc
29
29
  return if @bare
30
30
 
31
31
  body.div **{ class: "prefatory-section" } do |div2|
32
- div2.p { |p| p << "&nbsp;" } # placeholder
32
+ div2.p { |p| p << "&#xa0;" } # placeholder
33
33
  end
34
34
  section_break(body)
35
35
  end
data/lib/isodoc/i18n.rb CHANGED
@@ -23,3 +23,22 @@ module IsoDoc
23
23
  end
24
24
  end
25
25
  end
26
+
27
+ class ::Hash
28
+ def deep_merge(second)
29
+ merger = proc { |_, v1, v2|
30
+ if Hash === v1 && Hash === v2
31
+ v1.merge(v2, &merger)
32
+ elsif Array === v1 && Array === v2
33
+ v1 | v2
34
+ elsif [:undefined, nil,
35
+ :nil].include?(v2)
36
+ v1
37
+ else
38
+ v2
39
+ end
40
+ }
41
+ merge(second.to_h, &merger)
42
+ end
43
+ end
44
+
@@ -11,8 +11,8 @@ module IsoDoc
11
11
  Common::ns(xpath)
12
12
  end
13
13
 
14
- def l10n(a, b, c)
15
- @i18n.l10n(a, b, c)
14
+ def l10n(expr, lang, script)
15
+ @i18n.l10n(expr, lang, script)
16
16
  end
17
17
 
18
18
  def initialize(lang, script, i18n, fonts_options = {})
@@ -31,7 +31,7 @@ module IsoDoc
31
31
  return if labelled_ancestor(elem)
32
32
 
33
33
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
34
- prefix_name(elem, "&nbsp;&mdash; ",
34
+ prefix_name(elem, "&#xa0;&#x2014; ",
35
35
  l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
36
36
  end
37
37
 
@@ -60,7 +60,7 @@ module IsoDoc
60
60
  else
61
61
  l10n("#{@i18n.example} #{n[:label]}")
62
62
  end
63
- prefix_name(elem, "&nbsp;&mdash; ", lbl, "name")
63
+ prefix_name(elem, "&#xa0;&#x2014; ", lbl, "name")
64
64
  end
65
65
 
66
66
  def note(docxml)
@@ -130,7 +130,7 @@ module IsoDoc
130
130
  return if elem["unnumbered"] && !elem.at(ns("./name"))
131
131
 
132
132
  n = @xrefs.anchor(elem["id"], :label, false)
133
- prefix_name(elem, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.table} #{n}"),
133
+ prefix_name(elem, "&#xa0;&#x2014; ", l10n("#{lower2cap @i18n.table} #{n}"),
134
134
  "name")
135
135
  end
136
136
 
@@ -32,7 +32,7 @@ module IsoDoc
32
32
  return if elem.at(ns("./figure")) && !elem.at(ns("./name"))
33
33
 
34
34
  lbl = @xrefs.anchor(elem["id"], :label, false) or return
35
- prefix_name(elem, "&nbsp;&mdash; ",
35
+ prefix_name(elem, "&#xa0;&#x2014; ",
36
36
  l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
37
37
  end
38
38
 
@@ -158,7 +158,7 @@ module IsoDoc
158
158
  # TODO: move to localization file
159
159
  def eref_localities1_zh(_target, type, from, upto, node)
160
160
  ret = "第#{from}" if from
161
- ret += "&ndash;#{upto}" if upto
161
+ ret += "&#x2013;#{upto}" if upto
162
162
  loc = eref_locality_populate(type, node)
163
163
  ret += " #{loc}" unless node["droploc"] == "true"
164
164
  ret
@@ -172,19 +172,20 @@ module IsoDoc
172
172
  return l10n(eref_localities1_zh(target, type, from, upto, node))
173
173
  ret = eref_locality_populate(type, node)
174
174
  ret += " #{from}" if from
175
- ret += "&ndash;#{upto}" if upto
175
+ ret += "&#x2013;#{upto}" if upto
176
176
  l10n(ret)
177
177
  end
178
178
 
179
179
  def eref_locality_populate(type, node)
180
180
  return "" if node["droploc"] == "true"
181
181
 
182
- loc = @i18n.locality[type] || type.sub(/^locality:/, "")
183
- loc = case node["case"]
182
+ loc = type.sub(/^locality:/, "")
183
+ ret = @i18n.locality[loc] || loc
184
+ ret = case node["case"]
184
185
  when "lowercase" then loc.downcase
185
- else Metanorma::Utils.strict_capitalize_first(loc)
186
+ else Metanorma::Utils.strict_capitalize_first(ret)
186
187
  end
187
- " #{loc}"
188
+ " #{ret}"
188
189
  end
189
190
 
190
191
  def xref(docxml)
@@ -226,6 +227,12 @@ module IsoDoc
226
227
  end
227
228
  end
228
229
 
230
+ def identifier(docxml)
231
+ docxml.xpath(ns("//identifier")).each do |n|
232
+ n.name = "tt"
233
+ end
234
+ end
235
+
229
236
  private
230
237
 
231
238
  def found_matching_variant_sibling(node)
@@ -56,7 +56,7 @@ module IsoDoc
56
56
 
57
57
  def single_term_clause(elem)
58
58
  t = elem.at(ns("./terms | ./definitions | ./references"))
59
- t.at(ns("./title")).remove
59
+ t.at(ns("./title"))&.remove
60
60
  t.xpath(ns(".//clause | .//terms | .//definitions | .//references"))
61
61
  .each do |c|
62
62
  tit = c.at(ns("./title")) or return
@@ -84,6 +84,8 @@ module IsoDoc
84
84
  end
85
85
 
86
86
  def bibitem(xml)
87
+ @xrefs.klass.implicit_reference(xml) and
88
+ xml["hidden"] = "true"
87
89
  bibrender(xml)
88
90
  end
89
91
 
@@ -26,24 +26,39 @@ module IsoDoc
26
26
  def anchor_linkend1(node)
27
27
  linkend = @xrefs.anchor(node["target"], :xref)
28
28
  container = @xrefs.anchor(node["target"], :container, false)
29
- (container && get_note_container_id(node) != container &&
30
- @xrefs.get[node["target"]]) and
29
+ prefix_container?(container, node) and
31
30
  linkend = prefix_container(container, linkend, node["target"])
32
31
  capitalise_xref(node, linkend, anchor_value(node["target"]))
33
32
  end
34
33
 
34
+ def prefix_container?(container, node)
35
+ type = @xrefs.anchor(node["target"], :type)
36
+ container &&
37
+ get_note_container_id(node, type) != container &&
38
+ @xrefs.get[node["target"]]
39
+ end
40
+
35
41
  def combine_xref_locations(node)
36
42
  locs = gather_xref_locations(node)
37
43
  linkend = if can_conflate_xref_rendering?(locs)
38
- out = locs.each { |l| l[:target] = anchor_value(l[:target]) }
39
- l10n("#{locs.first[:elem]} #{combine_conn(out)}")
44
+ combine_conflated_xref_locations(locs)
40
45
  else
41
- out = locs.each { |l| l[:target] = anchor_linked1(l[:node]) }
46
+ out = locs.each { |l| l[:target] = anchor_linkend1(l[:node]) }
42
47
  l10n(combine_conn(out))
43
48
  end
44
49
  capitalise_xref(node, linkend, anchor_value(node["target"]))
45
50
  end
46
51
 
52
+ def combine_conflated_xref_locations(locs)
53
+ out = locs.each { |l| l[:target] = anchor_value(l[:target]) }
54
+ ret = l10n("#{locs.first[:elem]} #{combine_conn(out)}")
55
+ container = @xrefs.anchor(locs.first[:node]["target"], :container,
56
+ false)
57
+ prefix_container?(container, locs.first[:node]) and
58
+ ret = prefix_container(container, ret, locs.first[:node]["target"])
59
+ ret
60
+ end
61
+
47
62
  def gather_xref_locations(node)
48
63
  node.xpath(ns("./location")).each_with_object([]) do |l, m|
49
64
  type = @xrefs.anchor(l["target"], :type)
@@ -74,7 +89,8 @@ module IsoDoc
74
89
  end
75
90
 
76
91
  def can_conflate_xref_rendering?(locs)
77
- !locs.all? { |l| l[:container].nil? } &&
92
+ (locs.all? { |l| l[:container].nil? } ||
93
+ locs.all? { |l| l[:container] == locs.first[:container] }) &&
78
94
  locs.all? { |l| l[:type] == locs[0][:type] }
79
95
  end
80
96
 
@@ -68,6 +68,7 @@ module IsoDoc
68
68
  quotesource docxml
69
69
  mathml docxml
70
70
  variant docxml
71
+ identifier docxml
71
72
  end
72
73
 
73
74
  def terms(docxml)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.1.0.1".freeze
2
+ VERSION = "2.1.2".freeze
3
3
  end
@@ -20,7 +20,7 @@ module IsoDoc
20
20
 
21
21
  def make_body1(body, _docxml)
22
22
  body.div **{ class: "WordSection1" } do |div1|
23
- div1.p { |p| p << "&nbsp;" } # placeholder
23
+ div1.p { |p| p << "&#xa0;" } # placeholder
24
24
  end
25
25
  section_break(body)
26
26
  end
@@ -34,7 +34,7 @@ module IsoDoc
34
34
  introduction docxml, div2
35
35
  preface docxml, div2
36
36
  acknowledgements docxml, div2
37
- div2.p { |p| p << "&nbsp;" } # placeholder
37
+ div2.p { |p| p << "&#xa0;" } # placeholder
38
38
  end
39
39
  section_break(body)
40
40
  end
@@ -64,7 +64,7 @@ module IsoDoc
64
64
  def para_parse(node, out)
65
65
  out.p **attr_code(para_attrs(node)) do |p|
66
66
  unless @termdomain.empty?
67
- p << "&lt;#{@termdomain}&gt; "
67
+ p << "&#x3c;#{@termdomain}&#x3e; "
68
68
  @termdomain = ""
69
69
  end
70
70
  node.children.each { |n| parse(n, p) unless n.name == "note" }
@@ -92,8 +92,10 @@ module IsoDoc
92
92
  end
93
93
 
94
94
  def dl_parse_table(node, out)
95
+ list_title_parse(node, out)
95
96
  out.table **{ class: "dl" } do |v|
96
- node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
97
+ node.elements.select { |n| dt_dd?(n) }
98
+ .each_slice(2) do |dt, dd|
97
99
  dl_parse_table1(v, dt, dd)
98
100
  end
99
101
  dl_parse_notes(node, v)
@@ -112,11 +114,12 @@ module IsoDoc
112
114
  end
113
115
 
114
116
  def dl_parse_notes(node, out)
115
- return if node.elements.reject { |n| dt_dd? n }.empty?
117
+ remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
118
+ return if remainder.empty?
116
119
 
117
120
  out.tr do |tr|
118
121
  tr.td **{ colspan: 2 } do |td|
119
- node.elements.reject { |n| dt_dd? n }.each { |n| parse(n, td) }
122
+ remainder.each { |n| parse(n, td) }
120
123
  end
121
124
  end
122
125
  end
@@ -187,7 +187,7 @@ module IsoDoc
187
187
  next unless t.children.empty?
188
188
 
189
189
  t["style"] = t["style"].sub(/;?$/, ";font-size:0pt;")
190
- t.children = "&nbsp;"
190
+ t.children = "&#xa0;"
191
191
  end
192
192
  end
193
193