isodoc 1.7.7 → 1.8.2.1

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +2 -2
  3. data/lib/isodoc/class_utils.rb +1 -1
  4. data/lib/isodoc/convert.rb +8 -0
  5. data/lib/isodoc/function/cleanup.rb +4 -0
  6. data/lib/isodoc/function/inline.rb +3 -5
  7. data/lib/isodoc/html_function/html.rb +1 -0
  8. data/lib/isodoc/html_function/postprocess.rb +4 -6
  9. data/lib/isodoc/metadata_date.rb +13 -11
  10. data/lib/isodoc/presentation_function/bibdata.rb +2 -2
  11. data/lib/isodoc/presentation_function/block.rb +0 -36
  12. data/lib/isodoc/presentation_function/inline.rb +2 -3
  13. data/lib/isodoc/presentation_function/terms.rb +223 -0
  14. data/lib/isodoc/presentation_xml_convert.rb +11 -4
  15. data/lib/isodoc/version.rb +1 -1
  16. data/lib/isodoc/word_function/body.rb +24 -14
  17. data/lib/isodoc/word_function/comments.rb +0 -4
  18. data/lib/isodoc/word_function/postprocess.rb +184 -176
  19. data/lib/isodoc/xref/xref_gen.rb +18 -22
  20. data/lib/isodoc/xref/xref_gen_seq.rb +10 -16
  21. data/lib/isodoc/xslfo_convert.rb +9 -6
  22. data/lib/isodoc-yaml/i18n-ar.yaml +25 -0
  23. data/lib/isodoc-yaml/i18n-de.yaml +23 -0
  24. data/lib/isodoc-yaml/i18n-en.yaml +23 -0
  25. data/lib/isodoc-yaml/i18n-es.yaml +23 -0
  26. data/lib/isodoc-yaml/i18n-fr.yaml +23 -0
  27. data/lib/isodoc-yaml/i18n-ru.yaml +24 -1
  28. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +24 -0
  29. data/lib/metanorma/output/xslfo.rb +4 -11
  30. data/spec/isodoc/blocks_spec.rb +14 -8
  31. data/spec/isodoc/i18n_spec.rb +20 -15
  32. data/spec/isodoc/inline_spec.rb +71 -3
  33. data/spec/isodoc/lists_spec.rb +344 -222
  34. data/spec/isodoc/section_spec.rb +23 -22
  35. data/spec/isodoc/table_spec.rb +71 -73
  36. data/spec/isodoc/terms_spec.rb +498 -124
  37. data/spec/isodoc/xref_numbering_spec.rb +347 -0
  38. data/spec/isodoc/xref_spec.rb +274 -353
  39. data/spec/isodoc/xslfo_convert_spec.rb +20 -7
  40. metadata +12 -11
  41. data/lib/isodoc/presentation_function/concept.rb +0 -68
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5df030f2a89267d4acde57361f2c6338b29bf5928b5bb3c7b24a18903adf1531
4
- data.tar.gz: 7e1923d7293b6b0703a15799e9bc3334637145adf8219c4230c63809267770cf
3
+ metadata.gz: dee14fd22318290ef7a79cd3dff9b69c65bb5f9ea22160255d81c6f34fb6ac82
4
+ data.tar.gz: 879a52fc92753e7311f102963a3eb2db76115e6ec5add68edf9a4733dbab954e
5
5
  SHA512:
6
- metadata.gz: 24e8cf7a71167da62d5bdea85b009f982996e1513db82b42d6c01edf031b045dac7f9992a10e29946368df70dc32301e5edfa5937fad11e49e661edf8311058c
7
- data.tar.gz: f61bb6a9b3833c0c4080c0804ae12869f15051ebec0f3fa6b3cc7d925b44de41559d472dde0ad737f54b02b040532a0a944e90a563fd1fcec4566965bda26fa4
6
+ metadata.gz: 7e345be88c816bbebe4ec66aaf9e7dcc9273c4f539152c77b6500dd14a12db3cd61befc9d2702feef2c6e4d43c158ca23cab8621452ed815b1cfd6aa3197e023
7
+ data.tar.gz: 3fb800c7c1b9ec54faec69ef936b95bfdf64f9d5de2b02177edf5422bd05d0f379aed55dabe4cd2ee12ac2eb29052d761ec3b4d00984d03052e9e02083d556b1
data/isodoc.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
30
30
 
31
31
  spec.add_dependency "asciimath"
32
- spec.add_dependency "html2doc", "~> 1.1.1"
32
+ spec.add_dependency "html2doc", "~> 1.2.0"
33
33
  spec.add_dependency "htmlentities", "~> 4.3.4"
34
34
  spec.add_dependency "liquid", "~> 4"
35
35
  # spec.add_dependency "metanorma", ">= 1.2.0"
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
43
43
  spec.add_dependency "twitter_cldr", ">= 6.6.0"
44
44
  spec.add_dependency "uuidtools"
45
45
 
46
- spec.add_development_dependency "byebug", "~> 9.1"
46
+ spec.add_development_dependency "debug"
47
47
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
48
48
  spec.add_development_dependency "guard", "~> 2.14"
49
49
  spec.add_development_dependency "guard-rspec", "~> 4.7"
@@ -16,7 +16,7 @@ module IsoDoc
16
16
  xpath.gsub(%r{/([a-zA-z])}, "/xmlns:\\1")
17
17
  .gsub(%r{::([a-zA-z])}, "::xmlns:\\1")
18
18
  .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]* ?=)}, "[xmlns:\\1")
19
- .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*\])}, "[xmlns:\\1")
19
+ .gsub(%r{\[([a-zA-z][a-z0-9A-Z@/]*[/\]])}, "[xmlns:\\1")
20
20
  end
21
21
 
22
22
  def liquid(doc)
@@ -119,6 +119,7 @@ module IsoDoc
119
119
 
120
120
  def convert1(docxml, filename, dir)
121
121
  @xrefs.parse docxml
122
+ bibitem_lookup(docxml)
122
123
  noko do |xml|
123
124
  xml.html **{ lang: @lang.to_s } do |html|
124
125
  html.parent.add_namespace("epub", "http://www.idpf.org/2007/ops")
@@ -130,6 +131,13 @@ module IsoDoc
130
131
  end.join("\n")
131
132
  end
132
133
 
134
+ def bibitem_lookup(docxml)
135
+ @bibitems = docxml.xpath(ns("//references/bibitem"))
136
+ .each_with_object({}) do |b, m|
137
+ m[b["id"]] = b
138
+ end
139
+ end
140
+
133
141
  def metadata_init(lang, script, i18n)
134
142
  @meta = Metadata.new(lang, script, i18n)
135
143
  end
@@ -165,6 +165,10 @@ module IsoDoc
165
165
  t << a.remove
166
166
  end
167
167
  end
168
+ table_footnote_cleanup_propagate(docxml)
169
+ end
170
+
171
+ def table_footnote_cleanup_propagate(docxml)
168
172
  docxml.xpath("//p[not(self::*[@class])]"\
169
173
  "[ancestor::*[@class = 'TableFootnote']]").each do |p|
170
174
  p["class"] = "TableFootnote"
@@ -5,7 +5,7 @@ module IsoDoc
5
5
  module Inline
6
6
  def link_parse(node, out)
7
7
  url = node["target"]
8
- node["updatetype"] == "true" and url = suffix_url(url)
8
+ node["update-type"] == "true" and url = suffix_url(url)
9
9
  out.a **attr_code(href: url, title: node["alt"]) do |l|
10
10
  if node.text.empty?
11
11
  l << node["target"].sub(/^mailto:/, "")
@@ -41,10 +41,8 @@ module IsoDoc
41
41
  end
42
42
 
43
43
  def eref_target(node)
44
- href = "##{node['bibitemid']}"
45
- url = node.at(ns("//bibitem[@id = '#{node['bibitemid']}']/"\
46
- "uri[@type = 'citation']"))
47
- return href unless url
44
+ return "##{node['bibitemid']}" unless url = @bibitems[node["bibitemid"]]
45
+ &.at(ns("./uri[@type = 'citation']"))
48
46
 
49
47
  href = suffix_url(url.text)
50
48
  anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text&.strip
@@ -5,6 +5,7 @@ module IsoDoc
5
5
  module HtmlFunction
6
6
  module Html
7
7
  def convert1(docxml, filename, dir)
8
+ bibitem_lookup(docxml)
8
9
  noko do |xml|
9
10
  xml.html **{ lang: @lang.to_s } do |html|
10
11
  info docxml, nil
@@ -1,5 +1,6 @@
1
1
  require "isodoc/html_function/mathvariant_to_plain"
2
2
  require_relative "postprocess_footnotes"
3
+ require "metanorma-utils"
3
4
 
4
5
  module IsoDoc
5
6
  module HtmlFunction
@@ -74,7 +75,8 @@ module IsoDoc
74
75
  head = docxml.at("//*[local-name() = 'head']")
75
76
  head << htmlstylesheet(@htmlstylesheet)
76
77
  s = htmlstylesheet(@htmlstylesheet_override) and head << s
77
- @bare and head << "<style>body {margin-left: 2em; margin-right: 2em;}</style>"
78
+ @bare and
79
+ head << "<style>body {margin-left: 2em; margin-right: 2em;}</style>"
78
80
  docxml
79
81
  end
80
82
 
@@ -167,11 +169,7 @@ module IsoDoc
167
169
  end
168
170
 
169
171
  def datauri(img)
170
- type = img["src"].split(".")[-1]
171
- supertype = type == "xml" ? "application" : "image"
172
- bin = IO.binread(image_localfile(img))
173
- data = Base64.strict_encode64(bin)
174
- img["src"] = "data:#{supertype}/#{type};base64,#{data}"
172
+ img["src"] = Metanorma::Utils::datauri(img["src"], @localdir)
175
173
  end
176
174
 
177
175
  def image_suffix(img)
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  vote-ended}.freeze
7
7
 
8
8
  def months
9
- {
9
+ {
10
10
  "01": @labels["month_january"],
11
11
  "02": @labels["month_february"],
12
12
  "03": @labels["month_march"],
@@ -19,30 +19,32 @@ module IsoDoc
19
19
  "10": @labels["month_october"],
20
20
  "11": @labels["month_november"],
21
21
  "12": @labels["month_december"],
22
- }
22
+ }
23
23
  end
24
24
 
25
25
  def monthyr(isodate)
26
26
  m = /(?<yr>\d\d\d\d)-(?<mo>\d\d)/.match isodate
27
27
  return isodate unless m && m[:yr] && m[:mo]
28
+
28
29
  l10n("#{months[m[:mo].to_sym]} #{m[:yr]}",
29
- @lang, @script)
30
+ @lang, @script)
30
31
  end
31
32
 
32
33
  def MMMddyyyy(isodate)
33
34
  return nil if isodate.nil?
35
+
34
36
  arr = isodate.split("-")
35
- date = if arr.size == 1 and (/^\d+$/.match isodate)
36
- Date.new(*arr.map(&:to_i)).strftime("%Y")
37
- elsif arr.size == 2
38
- Date.new(*arr.map(&:to_i)).strftime("%B %Y")
39
- else
40
- Date.parse(isodate).strftime("%B %d, %Y")
41
- end
37
+ if arr.size == 1 && (/^\d+$/.match isodate)
38
+ Date.new(*arr.map(&:to_i)).strftime("%Y")
39
+ elsif arr.size == 2
40
+ Date.new(*arr.map(&:to_i)).strftime("%B %Y")
41
+ else
42
+ Date.parse(isodate).strftime("%B %d, %Y")
43
+ end
42
44
  end
43
45
 
44
46
  def bibdate(isoxml, _out)
45
- isoxml.xpath(ns('//bibdata/date')).each do |d|
47
+ isoxml.xpath(ns("//bibdata/date")).each do |d|
46
48
  set("#{d['type'].gsub(/-/, '_')}date".to_sym, Common::date_range(d))
47
49
  end
48
50
  end
@@ -10,7 +10,7 @@ module IsoDoc
10
10
  "</localized-strings>"
11
11
  end
12
12
 
13
- def docid_prefixes(docxml)
13
+ def docid_prefixes(docxml)
14
14
  docxml.xpath(ns("//references/bibitem/docidentifier")).each do |i|
15
15
  i.children = @xrefs.klass.docid_prefix(i["type"], i.text)
16
16
  end
@@ -97,7 +97,7 @@ module IsoDoc
97
97
 
98
98
  # https://stackoverflow.com/a/31822406
99
99
  def blank?(elem)
100
- elem.nil? || elem.respond_to?(:empty?) && elem.empty?
100
+ elem.nil? || (elem.respond_to?(:empty?) && elem.empty?)
101
101
  end
102
102
 
103
103
  def trim_hash(hash)
@@ -54,12 +54,6 @@ module IsoDoc
54
54
  end
55
55
  end
56
56
 
57
- def termexample(docxml)
58
- docxml.xpath(ns("//termexample")).each do |f|
59
- example1(f)
60
- end
61
- end
62
-
63
57
  def example1(elem)
64
58
  n = @xrefs.get[elem["id"]]
65
59
  lbl = if n.nil? || n[:label].nil? || n[:label].empty?
@@ -89,36 +83,6 @@ module IsoDoc
89
83
  prefix_name(elem, "", lbl, "name")
90
84
  end
91
85
 
92
- def termnote(docxml)
93
- docxml.xpath(ns("//termnote")).each do |f|
94
- termnote1(f)
95
- end
96
- end
97
-
98
- # introduce name element
99
- def termnote1(elem)
100
- lbl = l10n(@xrefs.anchor(elem["id"], :label) || "???")
101
- prefix_name(elem, "", lower2cap(lbl), "name")
102
- end
103
-
104
- def termdefinition(docxml)
105
- docxml.xpath(ns("//term[definition]")).each do |f|
106
- termdefinition1(f)
107
- end
108
- end
109
-
110
- def termdefinition1(elem)
111
- return unless elem.xpath(ns("./definition")).size > 1
112
-
113
- d = elem.at(ns("./definition"))
114
- d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
115
- elem.xpath(ns("./definition")).each do |f|
116
- f = f.replace("<li>#{f.children.to_xml}</li>").first
117
- d << f
118
- end
119
- d.wrap("<definition></definition>")
120
- end
121
-
122
86
  def recommendation(docxml)
123
87
  docxml.xpath(ns("//recommendation")).each do |f|
124
88
  recommendation1(f, lower2cap(@i18n.recommendation))
@@ -1,5 +1,4 @@
1
1
  require "metanorma-utils"
2
- require_relative "./concept"
3
2
 
4
3
  module IsoDoc
5
4
  class PresentationXMLConvert < ::IsoDoc::Convert
@@ -35,8 +34,8 @@ module IsoDoc
35
34
 
36
35
  def capitalise_xref(node, linkend, label)
37
36
  linktext = linkend.gsub(/<[^>]+>/, "")
38
- (label && !label.empty? && /^#{Regexp.escape(label)}/.match?(linktext) ||
39
- linktext[0, 1].match?(/\p{Upper}/)) and return linkend
37
+ (label && !label.empty? && /^#{Regexp.escape(label)}/.match?(linktext)) ||
38
+ linktext[0, 1].match?(/\p{Upper}/) and return linkend
40
39
  node["case"] and
41
40
  return Common::case_with_markup(linkend, node["case"], @script)
42
41
 
@@ -0,0 +1,223 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def concept(docxml)
4
+ docxml.xpath(ns("//concept")).each { |f| concept1(f) }
5
+ end
6
+
7
+ def concept1(node)
8
+ xref = node&.at(ns("./xref/@target"))&.text or
9
+ return concept_render(node, ital: node["ital"] || "true",
10
+ ref: node["ref"] || "true",
11
+ linkref: node["linkref"] || "true",
12
+ linkmention: node["linkmention"] || "false")
13
+ if node.at(ns("//definitions//dt[@id = '#{xref}']"))
14
+ concept_render(node, ital: node["ital"] || "false",
15
+ ref: node["ref"] || "false",
16
+ linkref: node["linkref"] || "true",
17
+ linkmention: node["linkmention"] || "false")
18
+ else concept_render(node, ital: node["ital"] || "true",
19
+ ref: node["ref"] || "true",
20
+ linkref: node["linkref"] || "true",
21
+ linkmention: node["linkmention"] || "false")
22
+ end
23
+ end
24
+
25
+ def concept_render(node, opts)
26
+ node&.at(ns("./refterm"))&.remove
27
+ r = node.at(ns("./renderterm"))
28
+ ref = node.at(ns("./xref | ./eref | ./termref"))
29
+ ref && opts[:ref] != "false" and r&.next = " "
30
+ opts[:ital] == "true" and r&.name = "em"
31
+ concept1_linkmention(ref, r, opts)
32
+ concept1_ref(node, ref, opts)
33
+ if opts[:ital] == "false"
34
+ r = node.at(ns(".//renderterm"))
35
+ r&.replace(r&.children)
36
+ end
37
+ node.replace(node.children)
38
+ end
39
+
40
+ def concept1_linkmention(ref, renderterm, opts)
41
+ if opts[:linkmention] == "true" && !renderterm.nil? && !ref.nil?
42
+ ref2 = ref.clone
43
+ r2 = renderterm.clone
44
+ renderterm.replace(ref2).children = r2
45
+ end
46
+ end
47
+
48
+ def concept1_ref(_node, ref, opts)
49
+ ref.nil? and return
50
+ return ref.remove if opts[:ref] == "false"
51
+
52
+ r = concept1_ref_content(ref)
53
+ ref = r.at("./descendant-or-self::xmlns:xref | "\
54
+ "./descendant-or-self::xmlns:eref | "\
55
+ "./descendant-or-self::xmlns:termref")
56
+ %w(xref eref).include? ref&.name and get_linkend(ref)
57
+ if opts[:linkref] == "false" && %w(xref eref).include?(ref&.name)
58
+ ref.replace(ref.children)
59
+ end
60
+ end
61
+
62
+ def concept1_ref_content(ref)
63
+ if non_locality_elems(ref).select do |c|
64
+ !c.text? || /\S/.match(c)
65
+ end.empty?
66
+ ref.replace(@i18n.term_defined_in.sub(/%/,
67
+ ref.to_xml))
68
+ else ref.replace("[#{ref.to_xml}]")
69
+ end
70
+ end
71
+
72
+ def related(docxml)
73
+ docxml.xpath(ns("//related")).each { |f| related1(f) }
74
+ end
75
+
76
+ def related1(node)
77
+ p = node.at(ns("./preferred"))
78
+ ref = node.at(ns("./xref | ./eref | ./termref"))
79
+ label = @i18n.relatedterms[node["type"]].upcase
80
+ node.replace(l10n("<p><strong>#{label}:</strong> "\
81
+ "<em>#{p.to_xml}</em> (#{ref.to_xml})</p>"))
82
+ end
83
+
84
+ def designation(docxml)
85
+ docxml.xpath(ns("//term")).each do |t|
86
+ merge_second_preferred(t)
87
+ end
88
+ docxml.xpath(ns("//preferred | //admitted | //deprecates")).each do |p|
89
+ designation1(p)
90
+ end
91
+ end
92
+
93
+ def merge_second_preferred(term)
94
+ pref = nil
95
+ term.xpath(ns("./preferred[expression/name]")).each_with_index do |p, i|
96
+ if i.zero? then pref = p
97
+ elsif merge_preferred_eligible?(pref, p)
98
+ pref.at(ns("./expression/name")) <<
99
+ l10n("; #{p.at(ns('./expression/name')).children.to_xml}")
100
+ p.remove
101
+ end
102
+ end
103
+ end
104
+
105
+ def merge_preferred_eligible?(first, second)
106
+ firstex = first.at(ns("./expression")) || {}
107
+ secondex = second.at(ns("./expression")) || {}
108
+ first["geographic-area"] == second["geographic-area"] &&
109
+ firstex["language"] == secondex["language"] &&
110
+ !first.at(ns("./pronunciation | ./grammar")) &&
111
+ !second.at(ns("./pronunciation | ./grammar"))
112
+ end
113
+
114
+ def designation1(desgn)
115
+ s = desgn.at(ns("./termsource"))
116
+ name = desgn.at(ns("./expression/name | ./letter-symbol/name | "\
117
+ "./graphical-symbol")) or return
118
+
119
+ designation_annotate(desgn, name)
120
+ s and desgn.next = s
121
+ end
122
+
123
+ def designation_annotate(desgn, name)
124
+ designation_field(desgn, name)
125
+ designation_boldface(desgn)
126
+ g = desgn.at(ns("./expression/grammar")) and
127
+ name << ", #{designation_grammar(g).join(', ')}"
128
+ designation_localization(desgn, name)
129
+ designation_pronunciation(desgn, name)
130
+ desgn.children = name.children
131
+ end
132
+
133
+ def designation_boldface(desgn)
134
+ desgn.name == "preferred" or return
135
+ name = desgn.at(ns("./expression/name | ./letter-symbol/name")) or return
136
+ name.children = "<strong>#{name.children}</strong>"
137
+ end
138
+
139
+ def designation_field(desgn, name)
140
+ f = desgn.xpath(ns("./field-of-application | ./usage-info"))
141
+ &.map { |u| u.children.to_xml }&.join(", ")
142
+ return nil if f&.empty?
143
+
144
+ name << ", &#x3c;#{f}&#x3e;"
145
+ end
146
+
147
+ def designation_grammar(grammar)
148
+ ret = []
149
+ grammar.xpath(ns("./gender | ./number")).each do |x|
150
+ ret << @i18n.grammar_abbrevs[x.text]
151
+ end
152
+ %w(isPreposition isParticiple isAdjective isVerb isAdverb isNoun)
153
+ .each do |x|
154
+ grammar.at(ns("./#{x}[text() = 'true']")) and
155
+ ret << @i18n.grammar_abbrevs[x]
156
+ end
157
+ ret
158
+ end
159
+
160
+ def designation_localization(desgn, name)
161
+ loc = [desgn&.at(ns("./expression/@language"))&.text,
162
+ desgn&.at(ns("./expression/@script"))&.text,
163
+ desgn&.at(ns("./@geographic-area"))&.text].compact
164
+ return if loc.empty?
165
+
166
+ name << ", #{loc.join(' ')}"
167
+ end
168
+
169
+ def designation_pronunciation(desgn, name)
170
+ f = desgn.at(ns("./expression/pronunciation")) or return
171
+
172
+ name << ", /#{f.children.to_xml}/"
173
+ end
174
+
175
+ def termexample(docxml)
176
+ docxml.xpath(ns("//termexample")).each do |f|
177
+ example1(f)
178
+ end
179
+ end
180
+
181
+ def termnote(docxml)
182
+ docxml.xpath(ns("//termnote")).each do |f|
183
+ termnote1(f)
184
+ end
185
+ end
186
+
187
+ # introduce name element
188
+ def termnote1(elem)
189
+ lbl = l10n(@xrefs.anchor(elem["id"], :label) || "???")
190
+ prefix_name(elem, "", lower2cap(lbl), "name")
191
+ end
192
+
193
+ def termdefinition(docxml)
194
+ docxml.xpath(ns("//term[definition]")).each do |f|
195
+ termdefinition1(f)
196
+ end
197
+ end
198
+
199
+ def termdefinition1(elem)
200
+ unwrap_definition(elem)
201
+ multidef(elem) if elem.xpath(ns("./definition")).size > 1
202
+ end
203
+
204
+ def multidef(elem)
205
+ d = elem.at(ns("./definition"))
206
+ d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
207
+ elem.xpath(ns("./definition")).each do |f|
208
+ f = f.replace("<li>#{f.children.to_xml}</li>").first
209
+ d << f
210
+ end
211
+ d.wrap("<definition></definition>")
212
+ end
213
+
214
+ def unwrap_definition(elem)
215
+ elem.xpath(ns("./definition")).each do |d|
216
+ %w(verbal-definition non-verbal-representation).each do |e|
217
+ v = d&.at(ns("./#{e}"))
218
+ v&.replace(v.children)
219
+ end
220
+ end
221
+ end
222
+ end
223
+ end
@@ -1,4 +1,5 @@
1
1
  require_relative "presentation_function/block"
2
+ require_relative "presentation_function/terms"
2
3
  require_relative "presentation_function/inline"
3
4
  require_relative "presentation_function/math"
4
5
  require_relative "presentation_function/section"
@@ -25,6 +26,7 @@ module IsoDoc
25
26
  @xrefs.parse docxml
26
27
  section docxml
27
28
  block docxml
29
+ terms docxml
28
30
  inline docxml
29
31
  end
30
32
 
@@ -46,17 +48,13 @@ module IsoDoc
46
48
  sourcecode docxml
47
49
  formula docxml
48
50
  example docxml
49
- termexample docxml
50
51
  note docxml
51
- termnote docxml
52
- termdefinition docxml
53
52
  permission docxml
54
53
  requirement docxml
55
54
  recommendation docxml
56
55
  end
57
56
 
58
57
  def inline(docxml)
59
- concept docxml
60
58
  xref docxml
61
59
  eref docxml
62
60
  origin docxml
@@ -65,6 +63,15 @@ module IsoDoc
65
63
  variant docxml
66
64
  end
67
65
 
66
+ def terms(docxml)
67
+ termexample docxml
68
+ termnote docxml
69
+ termdefinition docxml
70
+ designation docxml
71
+ concept docxml
72
+ related docxml
73
+ end
74
+
68
75
  def postprocess(result, filename, _dir)
69
76
  toXML(result, filename)
70
77
  @files_to_delete.each { |f| FileUtils.rm_rf f }
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.7.7".freeze
2
+ VERSION = "1.8.2.1".freeze
3
3
  end
@@ -54,11 +54,11 @@ module IsoDoc
54
54
  end
55
55
 
56
56
  def para_class(_node)
57
- classtype = nil
58
- classtype = "Note" if @note
59
- classtype = "MsoCommentText" if in_comment
60
- classtype = "Sourcecode" if @annotation
61
- classtype
57
+ return "Sourcecode" if @annotation
58
+ return "MsoCommentText" if @in_comment
59
+ return "Note" if @note
60
+
61
+ nil
62
62
  end
63
63
 
64
64
  def para_parse(node, out)
@@ -86,21 +86,31 @@ module IsoDoc
86
86
  end
87
87
 
88
88
  def dl_parse(node, out)
89
+ return super unless node.ancestors("table, dl").empty?
90
+
91
+ dl_parse_table(node, out)
92
+ end
93
+
94
+ def dl_parse_table(node, out)
89
95
  out.table **{ class: "dl" } do |v|
90
96
  node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
91
- v.tr do |tr|
92
- tr.td **{ valign: "top", align: "left" } do |term|
93
- dt_parse(dt, term)
94
- end
95
- tr.td **{ valign: "top" } do |listitem|
96
- dd.children.each { |n| parse(n, listitem) }
97
- end
98
- end
97
+ dl_parse_table1(v, dt, dd)
99
98
  end
100
99
  dl_parse_notes(node, v)
101
100
  end
102
101
  end
103
102
 
103
+ def dl_parse_table1(table, dterm, ddefn)
104
+ table.tr do |tr|
105
+ tr.td **{ valign: "top", align: "left" } do |term|
106
+ dt_parse(dterm, term)
107
+ end
108
+ tr.td **{ valign: "top" } do |listitem|
109
+ ddefn.children.each { |n| parse(n, listitem) }
110
+ end
111
+ end
112
+ end
113
+
104
114
  def dl_parse_notes(node, out)
105
115
  return if node.elements.reject { |n| dt_dd? n }.empty?
106
116
 
@@ -120,8 +130,8 @@ module IsoDoc
120
130
  dl
121
131
  end
122
132
 
133
+ # get rid of footnote link, it is in diagram
123
134
  def figure_aside_process(fig, aside, key)
124
- # get rid of footnote link, it is in diagram
125
135
  fig&.at("./a[@class='TableFootnoteRef']")&.remove
126
136
  fnref = fig.at(".//span[@class='TableFootnoteRef']/..")
127
137
  tr = key.add_child("<tr></tr>").first
@@ -1,10 +1,6 @@
1
1
  module IsoDoc
2
2
  module WordFunction
3
3
  module Comments
4
- def in_comment
5
- @in_comment
6
- end
7
-
8
4
  def comments(div)
9
5
  return if @comments.empty?
10
6