isodoc 2.5.10 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +1 -1
  3. data/lib/isodoc/base_style/metanorma_word.css +3 -3
  4. data/lib/isodoc/base_style/metanorma_word.scss +5 -3
  5. data/lib/isodoc/common.rb +13 -13
  6. data/lib/isodoc/convert.rb +4 -2
  7. data/lib/isodoc/function/blocks.rb +1 -4
  8. data/lib/isodoc/function/blocks_example_note.rb +1 -7
  9. data/lib/isodoc/function/inline.rb +2 -2
  10. data/lib/isodoc/function/references.rb +13 -15
  11. data/lib/isodoc/function/section.rb +35 -63
  12. data/lib/isodoc/function/section_titles.rb +0 -14
  13. data/lib/isodoc/function/to_word_html.rb +44 -21
  14. data/lib/isodoc/function/utils.rb +1 -0
  15. data/lib/isodoc/html_function/footnotes.rb +2 -2
  16. data/lib/isodoc/html_function/html.rb +0 -10
  17. data/lib/isodoc/init.rb +11 -3
  18. data/lib/isodoc/metadata.rb +3 -3
  19. data/lib/isodoc/metadata_contributor.rb +7 -1
  20. data/lib/isodoc/presentation_function/erefs.rb +2 -2
  21. data/lib/isodoc/presentation_function/image.rb +22 -10
  22. data/lib/isodoc/presentation_function/inline.rb +12 -13
  23. data/lib/isodoc/presentation_function/refs.rb +16 -3
  24. data/lib/isodoc/presentation_function/section.rb +39 -20
  25. data/lib/isodoc/presentation_function/terms.rb +7 -0
  26. data/lib/isodoc/presentation_function/xrefs.rb +4 -4
  27. data/lib/isodoc/presentation_xml_convert.rb +3 -1
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_function/body.rb +15 -6
  30. data/lib/isodoc/word_function/inline.rb +3 -3
  31. data/lib/isodoc/word_function/postprocess.rb +20 -4
  32. data/lib/isodoc/xref/xref_gen.rb +5 -5
  33. data/lib/isodoc/xref/xref_sect_gen.rb +90 -34
  34. data/lib/isodoc-yaml/i18n-ar.yaml +1 -1
  35. data/lib/isodoc-yaml/i18n-de.yaml +1 -1
  36. data/lib/isodoc-yaml/i18n-en.yaml +1 -1
  37. data/lib/isodoc-yaml/i18n-es.yaml +1 -1
  38. data/lib/isodoc-yaml/i18n-fr.yaml +1 -1
  39. data/lib/isodoc-yaml/i18n-ja.yaml +1 -1
  40. data/lib/isodoc-yaml/i18n-ru.yaml +1 -1
  41. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -1
  42. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a73625d6e0b342e44b34e2c93ef6df6126e1694dbcd9475cc52168da86a8cb8b
4
- data.tar.gz: 58bed9e6bd9f0a5812a6e7ee46e90ea2c4e2dc4bf1592a66db4302dd4d579f5c
3
+ metadata.gz: 7b149d913a483c336d7463e587e980fe234f4d1e32d8d683a070d919b0ce7429
4
+ data.tar.gz: 46e568e2b91f13069f62131ab1b86e28fd74416c55ae0937935575927a578430
5
5
  SHA512:
6
- metadata.gz: 28274dab0c28284a969ae3caf93e2065447c8b70b9166385e972b610014eb6bdeea8de3ec25273dfa1aea7fb78eaea463e894a0feeef18b82f0be3f2f479ff7c
7
- data.tar.gz: 87c56a3f6c1aefd791ae520d2e3c1e0c7d7060b5d81aca3e64096294cd3c5de28cd71d70ad04db8823457bc90773a8f6b1d427a43e1cdd3ed067b5ab72099c29
6
+ metadata.gz: ae43a3f990e70f7d1929357172ca48b4cbc5db2750e61d1f91768c8087e796f5e333de64b60fc928434862e1fb874151c6a00a0cd41e25d491fe79e8604dfa9d
7
+ data.tar.gz: 9abab47db0d610e3971c1f9a19af240449dc11d6cd1d8d0f9e1e860f4b00e4a6947cce60d8483ba8701a180472278badaee6d431a07bd32ba1727ea5ad4d9a16
data/isodoc.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  end
29
29
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
30
30
 
31
- spec.add_dependency "html2doc", "~> 1.5.3"
31
+ spec.add_dependency "html2doc", "~> 1.6.0"
32
32
  spec.add_dependency "htmlentities", "~> 4.3.4"
33
33
  # spec.add_dependency "isodoc-i18n", "~> 1.1.0" # already in relaton-render and mn-requirements
34
34
  spec.add_dependency "emf2svg"
@@ -1,6 +1,3 @@
1
- div.table_container {
2
- margin-bottom: 14pt; }
3
-
4
1
  ol {
5
2
  margin-bottom: 0cm; }
6
3
 
@@ -54,3 +51,6 @@ table.rouge-line-table {
54
51
 
55
52
  td.rouge-code p.Sourcecode {
56
53
  margin: 0px; }
54
+
55
+ div.table_container {
56
+ margin-bottom: 14pt; }
@@ -1,6 +1,4 @@
1
- div.table_container {
2
- margin-bottom: 14pt;
3
- }
1
+
4
2
 
5
3
  ol
6
4
  {margin-bottom:0cm;}
@@ -53,3 +51,7 @@ table.rouge-line-table {
53
51
  td.rouge-code p.Sourcecode {
54
52
  margin: 0px;
55
53
  }
54
+
55
+ div.table_container {
56
+ margin-bottom: 14pt;
57
+ }
data/lib/isodoc/common.rb CHANGED
@@ -1,16 +1,16 @@
1
- require_relative "./function/blocks"
2
- require_relative "./function/cleanup"
3
- require_relative "./function/form"
4
- require_relative "./function/inline"
5
- require_relative "./function/lists"
6
- require_relative "./function/references"
7
- require_relative "./function/section"
8
- require_relative "./function/table"
9
- require_relative "./function/terms"
10
- require_relative "./function/to_word_html"
11
- require_relative "./function/utils"
12
- require_relative "./function/reqt"
13
- require_relative "./class_utils"
1
+ require_relative "function/blocks"
2
+ require_relative "function/cleanup"
3
+ require_relative "function/form"
4
+ require_relative "function/inline"
5
+ require_relative "function/lists"
6
+ require_relative "function/references"
7
+ require_relative "function/section"
8
+ require_relative "function/table"
9
+ require_relative "function/terms"
10
+ require_relative "function/to_word_html"
11
+ require_relative "function/utils"
12
+ require_relative "function/reqt"
13
+ require_relative "class_utils"
14
14
 
15
15
  module IsoDoc
16
16
  class Common
@@ -113,6 +113,8 @@ module IsoDoc
113
113
  docxml = Nokogiri::XSLT(x).transform(docxml)
114
114
  end
115
115
  docxml
116
+ rescue
117
+ require "debug"; binding.b
116
118
  end
117
119
 
118
120
  def extract_preprocess_xslt(docxml)
@@ -156,11 +158,11 @@ module IsoDoc
156
158
 
157
159
  def middle_clause(_docxml = nil)
158
160
  "//clause[parent::sections][not(@type = 'scope')]" \
159
- "[not(descendant::terms)]"
161
+ "[not(descendant::terms)][not(descendant::references)]"
160
162
  end
161
163
 
162
164
  def target_pdf(node)
163
- if /#/.match?(node["target"]) then node["target"].sub(/#/, ".pdf#")
165
+ if node["target"].include?("#") then node["target"].sub("#", ".pdf#")
164
166
  else "##{node['target']}"
165
167
  end
166
168
  end
@@ -5,10 +5,6 @@ module IsoDoc
5
5
  module Blocks
6
6
  @annotation = false
7
7
 
8
- def middle_title(_isoxml, out)
9
- out.p(class: "zzSTDTitle1") { |p| p << @meta.get[:doctitle] }
10
- end
11
-
12
8
  def figure_name_parse(_node, div, name)
13
9
  name.nil? and return
14
10
  div.p class: "FigureTitle", style: "text-align:center;" do |p|
@@ -140,6 +136,7 @@ module IsoDoc
140
136
  if node["type"] == "floating-title"
141
137
  classtype = "h#{node['depth']}"
142
138
  end
139
+ classtype ||= node["class"]
143
140
  classtype
144
141
  end
145
142
 
@@ -71,7 +71,7 @@ module IsoDoc
71
71
  end
72
72
 
73
73
  def note_parse1(node, div)
74
- name = node&.at(ns("./name"))&.remove
74
+ name = node.at(ns("./name"))&.remove
75
75
  name and div.p do |p|
76
76
  p.span class: "note_label" do |s|
77
77
  name.children.each { |n| parse(n, s) }
@@ -110,12 +110,6 @@ module IsoDoc
110
110
  @note = false
111
111
  end
112
112
 
113
- def middle_admonitions(isoxml, out)
114
- isoxml.xpath(ns("//sections/note | //sections/admonition")).each do |x|
115
- parse(x, out)
116
- end
117
- end
118
-
119
113
  def admonition_name_parse(_node, div, name)
120
114
  div.p class: "AdmonitionTitle", style: "text-align:center;" do |p|
121
115
  name.children.each { |n| parse(n, p) }
@@ -38,7 +38,7 @@ module IsoDoc
38
38
 
39
39
  def xref_parse(node, out)
40
40
  target = if /#/.match?(node["target"])
41
- node["target"].sub(/#/, ".html#")
41
+ node["target"].sub("#", ".html#")
42
42
  else
43
43
  "##{node['target']}"
44
44
  end
@@ -150,7 +150,7 @@ module IsoDoc
150
150
  end
151
151
 
152
152
  def error_parse(node, out)
153
- text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
153
+ text = node.to_xml.gsub("<", "&lt;").gsub(">", "&gt;")
154
154
  out.para do |p|
155
155
  p.b(role: "strong") { |e| e << text }
156
156
  end
@@ -145,21 +145,20 @@ module IsoDoc
145
145
 
146
146
  def norm_ref_xpath
147
147
  "//bibliography/references[@normative = 'true'] | " \
148
- "//bibliography/clause[.//references[@normative = 'true']]"
148
+ "//bibliography/clause[.//references[@normative = 'true']] | " \
149
+ "//sections/references[@normative = 'true'] | " \
150
+ "//sections/clause[.//references[@normative = 'true']]"
149
151
  end
150
152
 
151
- def norm_ref(isoxml, out, num)
152
- (f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true") or
153
- return num
153
+ def norm_ref(node, out)
154
+ node["hidden"] != "true" or return
154
155
  out.div do |div|
155
- num += 1
156
- clause_name(f, f.at(ns("./title")), div, nil)
157
- if f.name == "clause"
158
- f.elements.each { |e| parse(e, div) unless e.name == "title" }
159
- else biblio_list(f, div, false)
156
+ clause_name(node, node.at(ns("./title")), div, nil)
157
+ if node.name == "clause"
158
+ node.elements.each { |e| parse(e, div) unless e.name == "title" }
159
+ else biblio_list(node, div, false)
160
160
  end
161
161
  end
162
- num
163
162
  end
164
163
 
165
164
  def bibliography_xpath
@@ -168,15 +167,14 @@ module IsoDoc
168
167
  "//bibliography/references[@normative = 'false']"
169
168
  end
170
169
 
171
- def bibliography(isoxml, out)
172
- (f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true") or
173
- return
170
+ def bibliography(node, out)
171
+ node["hidden"] != "true" or return
174
172
  page_break(out)
175
173
  out.div do |div|
176
174
  div.h1 class: "Section3" do |h1|
177
- f.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
175
+ node.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
178
176
  end
179
- biblio_list(f, div, true)
177
+ biblio_list(node, div, true)
180
178
  end
181
179
  end
182
180
 
@@ -17,13 +17,11 @@ module IsoDoc
17
17
  end
18
18
  end
19
19
 
20
- def clause(isoxml, out)
21
- isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
22
- out.div **attr_code(clause_attrs(c)) do |s|
23
- clause_name(c, c.at(ns("./title")), s, nil)
24
- c.elements.reject { |c1| c1.name == "title" }.each do |c1|
25
- parse(c1, s)
26
- end
20
+ def clause(node, out)
21
+ out.div **attr_code(clause_attrs(node)) do |s|
22
+ clause_name(node, node.at(ns("./title")), s, nil)
23
+ node.elements.reject { |c1| c1.name == "title" }.each do |c1|
24
+ parse(c1, s)
27
25
  end
28
26
  end
29
27
  end
@@ -32,44 +30,40 @@ module IsoDoc
32
30
  { id: node["id"], class: "Section3" }
33
31
  end
34
32
 
35
- def annex(isoxml, out)
36
- isoxml.xpath(ns("//annex")).each do |c|
37
- page_break(out)
38
- out.div **attr_code(annex_attrs(c)) do |s|
39
- c.elements.each do |c1|
40
- if c1.name == "title" then annex_name(c, c1, s)
41
- else parse(c1, s)
42
- end
33
+ def annex(node, out)
34
+ page_break(out)
35
+ out.div **attr_code(annex_attrs(node)) do |s|
36
+ node.elements.each do |c1|
37
+ if c1.name == "title" then annex_name(node, c1, s)
38
+ else parse(c1, s)
43
39
  end
44
40
  end
45
41
  end
46
42
  end
47
43
 
48
- def scope(isoxml, out, num)
49
- f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
50
- out.div **attr_code(id: f["id"]) do |div|
51
- num = num + 1
52
- clause_name(f, f&.at(ns("./title")), div, nil)
53
- f.elements.each do |e|
44
+ def indexsect(node, out)
45
+ clause_parse(node, out)
46
+ end
47
+
48
+ def scope(node, out)
49
+ out.div **attr_code(id: node["id"]) do |div|
50
+ clause_name(node, node.at(ns("./title")), div, nil)
51
+ node.elements.each do |e|
54
52
  parse(e, div) unless e.name == "title"
55
53
  end
56
54
  end
57
- num
58
55
  end
59
56
 
60
57
  TERM_CLAUSE = "//sections/terms | " \
61
58
  "//sections/clause[descendant::terms]".freeze
62
59
 
63
- def terms_defs(isoxml, out, num)
64
- f = isoxml.at(ns(TERM_CLAUSE)) or return num
65
- out.div **attr_code(id: f["id"]) do |div|
66
- num = num + 1
67
- clause_name(f, f.at(ns("./title")), div, nil)
68
- f.elements.each do |e|
60
+ def terms_defs(node, out)
61
+ out.div **attr_code(id: node["id"]) do |div|
62
+ clause_name(node, node.at(ns("./title")), div, nil)
63
+ node.elements.each do |e|
69
64
  parse(e, div) unless %w{title source}.include? e.name
70
65
  end
71
66
  end
72
- num
73
67
  end
74
68
 
75
69
  # subclause
@@ -77,16 +71,13 @@ module IsoDoc
77
71
  clause_parse(isoxml, out)
78
72
  end
79
73
 
80
- def symbols_abbrevs(isoxml, out, num)
81
- f = isoxml.at(ns("//sections/definitions")) or return num
82
- out.div **attr_code(id: f["id"], class: "Symbols") do |div|
83
- num = num + 1
84
- clause_name(f, f.at(ns("./title")), div, nil)
85
- f.elements.each do |e|
74
+ def symbols_abbrevs(node, out)
75
+ out.div **attr_code(id: node["id"], class: "Symbols") do |div|
76
+ clause_name(node, node.at(ns("./title")), div, nil)
77
+ node.elements.each do |e|
86
78
  parse(e, div) unless e.name == "title"
87
79
  end
88
80
  end
89
- num
90
81
  end
91
82
 
92
83
  # subclause
@@ -171,15 +162,14 @@ module IsoDoc
171
162
  end
172
163
  end
173
164
 
174
- def colophon(isoxml, out)
175
- isoxml.at(ns("//colophon")) or return
176
- page_break(out)
177
- isoxml.xpath(ns("//colophon/clause")).each do |f|
178
- out.div class: "Section3", id: f["id"] do |div|
179
- clause_name(f, f&.at(ns("./title")), div, { class: "IntroTitle" })
180
- f.elements.each do |e|
181
- parse(e, div) unless e.name == "title"
182
- end
165
+ def colophon(node, out)
166
+ @seen_colophon or page_break(out)
167
+ @seen_colophon = true
168
+ out.div class: "Section3", id: node["id"] do |div|
169
+ clause_name(node, node.at(ns("./title")), div,
170
+ { class: "IntroTitle" })
171
+ node.elements.each do |e|
172
+ parse(e, div) unless e.name == "title"
183
173
  end
184
174
  end
185
175
  end
@@ -194,24 +184,6 @@ module IsoDoc
194
184
  t.size == 1 && %w(terms definitions references).include?(t[0].name)
195
185
  end
196
186
 
197
- def front(isoxml, out)
198
- p = isoxml.at(ns("//preface")) or return
199
- p.elements.each do |e|
200
- if is_clause?(e.name)
201
- case e.name
202
- when "abstract" then abstract e, out
203
- when "foreword" then foreword e, out
204
- when "introduction" then introduction e, out
205
- when "executivesummary" then executivesummary e, out
206
- when "clause" then preface e, out
207
- when "acknowledgements" then acknowledgements e, out
208
- end
209
- else
210
- preface_block(e, out)
211
- end
212
- end
213
- end
214
-
215
187
  def executivesummary(clause, out)
216
188
  introduction clause, out
217
189
  end
@@ -56,7 +56,6 @@ module IsoDoc
56
56
 
57
57
  # top level clause names
58
58
  def clause_name(node, title, div, header_class)
59
- preceding_floating_titles(node, div)
60
59
  header_class = {} if header_class.nil?
61
60
  div.h1 **attr_code(header_class) do |h1|
62
61
  if title.is_a?(String) then h1 << title
@@ -69,7 +68,6 @@ module IsoDoc
69
68
  end
70
69
 
71
70
  def annex_name(_annex, name, div)
72
- preceding_floating_titles(name, div)
73
71
  return if name.nil?
74
72
 
75
73
  div.h1 class: "Annex" do |t|
@@ -84,18 +82,6 @@ module IsoDoc
84
82
  node.children.each { |c| parse(c, p) }
85
83
  end
86
84
  end
87
-
88
- def preceding_floating_titles(node, div)
89
- return if node.nil?
90
-
91
- out = node.xpath("./preceding-sibling::*")
92
- .reverse.each_with_object([]) do |p, m|
93
- break m unless p.name == "p"
94
-
95
- m << p
96
- end or return
97
- out.each { |c| parse(c, div) }
98
- end
99
85
  end
100
86
  end
101
87
  end
@@ -82,20 +82,57 @@ module IsoDoc
82
82
  section_break(body)
83
83
  end
84
84
 
85
+ TOP_ELEMENTS =
86
+ "//preface/*[@displayorder] | //sections/*[@displayorder] | " \
87
+ "//annex[@displayorder] | //bibliography/*[@displayorder] | " \
88
+ "//colophon/*[@displayorder] | //indexsect[@displayorder]"
89
+ .freeze
90
+
85
91
  def make_body3(body, docxml)
86
92
  body.div class: "main-section" do |div3|
87
93
  boilerplate docxml, div3
88
- preface_block docxml, div3
89
- abstract docxml, div3
90
- foreword docxml, div3
91
- introduction docxml, div3
92
- acknowledgements docxml, div3
93
- middle docxml, div3
94
+ content(div3, docxml, ns(self.class::TOP_ELEMENTS))
94
95
  footnotes div3
95
96
  comments div3
96
97
  end
97
98
  end
98
99
 
100
+ # xpath presumed to list elements with displayorder attribute
101
+ def content(body, docxml, xpath)
102
+ docxml.xpath(xpath).sort_by { |c| c["displayorder"].to_i }
103
+ .each do |c|
104
+ top_element_render(c, body)
105
+ end
106
+ end
107
+
108
+ def top_element_render(e, out)
109
+ case e.name
110
+ when "abstract" then abstract e, out
111
+ when "foreword" then foreword e, out
112
+ when "introduction" then introduction e, out
113
+ when "executivesummary" then executivesummary e, out
114
+ when "acknowledgements" then acknowledgements e, out
115
+ when "annex" then annex e, out
116
+ when "definitions" then symbols_abbrevs e, out
117
+ when "indexsect" then indexsect e, out
118
+ when "references"
119
+ if e["normative"] == "true" then norm_ref e, out
120
+ else bibliography e, out
121
+ end
122
+ when "clause"
123
+ if e.parent.name == "preface" then preface e, out
124
+ elsif e.parent.name == "colophon" then colophon e, out
125
+ elsif e["type"] == "scope" then scope e, out
126
+ elsif e.at(ns(".//terms")) then terms_defs e, out
127
+ elsif e.at(ns(".//references[@normative = 'true']"))
128
+ norm_ref e, out
129
+ elsif e.at(ns(".//references")) then bibliography e, out
130
+ else clause e, out
131
+ end
132
+ else parse(e, out)
133
+ end
134
+ end
135
+
99
136
  def info(isoxml, out)
100
137
  @meta.code_css isoxml, out
101
138
  @meta.title isoxml, out
@@ -116,22 +153,8 @@ module IsoDoc
116
153
  @meta.get
117
154
  end
118
155
 
119
- def middle(isoxml, out)
120
- middle_title(isoxml, out)
121
- middle_admonitions(isoxml, out)
122
- scope isoxml, out, 0
123
- norm_ref isoxml, out, 0
124
- terms_defs isoxml, out, 0
125
- symbols_abbrevs isoxml, out, 0
126
- clause isoxml, out
127
- annex isoxml, out
128
- bibliography isoxml, out
129
- colophon isoxml, out
130
- end
131
-
132
156
  def boilerplate(node, out)
133
- return if @bare
134
-
157
+ @bare and return
135
158
  boilerplate = node.at(ns("//boilerplate")) or return
136
159
  out.div class: "authority" do |s|
137
160
  boilerplate.children.each do |n|
@@ -176,6 +176,7 @@ module IsoDoc
176
176
  imgtype = "emf" if emf?("#{imgclass}/#{imgtype}")
177
177
  imgtype = imgtype.sub(/\+[a-z0-9]+$/, "") # svg+xml
178
178
  imgtype = "png" unless /^[a-z0-9]+$/.match? imgtype
179
+ imgtype == "postscript" and imgtype = "eps"
179
180
  Tempfile.open(["image", ".#{imgtype}"]) do |f|
180
181
  f.binmode
181
182
  f.write(Base64.strict_decode64(imgdata))
@@ -36,7 +36,7 @@ module IsoDoc
36
36
 
37
37
  def make_generic_footnote_text(node, fnid)
38
38
  noko do |xml|
39
- xml.aside **{ id: "fn:#{fnid}", class: "footnote" } do |div|
39
+ xml.aside id: "fn:#{fnid}", class: "footnote" do |div|
40
40
  node.children.each { |n| parse(n, div) }
41
41
  end
42
42
  end.join("\n")
@@ -59,7 +59,7 @@ module IsoDoc
59
59
  return if @seen_footnote.include?(tid + fn)
60
60
 
61
61
  @in_footnote = true
62
- out.aside **{ class: "footnote" } do |a|
62
+ out.aside class: "footnote" do |a|
63
63
  a << make_table_footnote_text(node, tid + fn, fn)
64
64
  end
65
65
  @in_footnote = false
@@ -33,16 +33,6 @@ module IsoDoc
33
33
  section_break(body)
34
34
  end
35
35
 
36
- def make_body3(body, docxml)
37
- body.div class: "main-section" do |div3|
38
- boilerplate docxml, div3
39
- front docxml, div3
40
- middle docxml, div3
41
- footnotes div3
42
- comments div3
43
- end
44
- end
45
-
46
36
  def googlefonts
47
37
  <<~HEAD.freeze
48
38
  <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet"/>
data/lib/isodoc/init.rb CHANGED
@@ -21,9 +21,9 @@ module IsoDoc
21
21
  def toc_init(docxml)
22
22
  x = "//metanorma-extension/presentation-metadata" \
23
23
  "[name[text() = 'TOC Heading Levels']]/value"
24
- n = docxml.at(ns(x.sub(/TOC/, "DOC TOC"))) and
24
+ n = docxml.at(ns(x.sub("TOC", "DOC TOC"))) and
25
25
  @wordToClevels = n.text.to_i
26
- n = docxml.at(ns(x.sub(/TOC/, "HTML TOC"))) and
26
+ n = docxml.at(ns(x.sub("TOC", "HTML TOC"))) and
27
27
  @htmlToClevels = n.text.to_i
28
28
  end
29
29
 
@@ -93,7 +93,7 @@ module IsoDoc
93
93
  @fn_bookmarks = {}
94
94
  end
95
95
 
96
- def init_fonts(options)
96
+ def init_fonts(options)
97
97
  @normalfontsize = options[:normalfontsize]
98
98
  @smallerfontsize = options[:smallerfontsize]
99
99
  @monospacefontsize = options[:monospacefontsize]
@@ -129,5 +129,13 @@ module IsoDoc
129
129
  @toctables = options[:toctables]
130
130
  @tocrecommendations = options[:tocrecommendations]
131
131
  end
132
+
133
+ AGENCIES = %w(ISO IEC ITU IETF NIST OGC IEEE BIPM BSI BS JIS IANA UN W3C
134
+ IHO CSA IEV)
135
+ .freeze
136
+
137
+ def agency?(text)
138
+ self.class::AGENCIES.include?(text)
139
+ end
132
140
  end
133
141
  end
@@ -1,5 +1,5 @@
1
- require_relative "./metadata_date"
2
- require_relative "./metadata_contributor"
1
+ require_relative "metadata_date"
2
+ require_relative "metadata_contributor"
3
3
 
4
4
  module IsoDoc
5
5
  class Metadata
@@ -15,7 +15,7 @@ module IsoDoc
15
15
 
16
16
  def initialize(lang, script, locale, i18n, fonts_options = {})
17
17
  @metadata = { lang: lang, script: script }
18
- DATETYPES.each { |w| @metadata["#{w.gsub(/-/, '_')}date".to_sym] = "XXX" }
18
+ DATETYPES.each { |w| @metadata["#{w.gsub('-', '_')}date".to_sym] = "XXX" }
19
19
  @lang = lang
20
20
  @script = script
21
21
  @locale = locale
@@ -67,7 +67,7 @@ module IsoDoc
67
67
  publisher = []
68
68
  xml.xpath(ns("//bibdata/contributor[xmlns:role/@type = 'publisher']/" \
69
69
  "organization")).each do |org|
70
- name = org.at(ns("./name"))&.text
70
+ name = extract_variant(org.at(ns("./name")))
71
71
  agency1 = org.at(ns("./abbreviation"))&.text || name
72
72
  publisher << name if name
73
73
  agency = iso?(org) ? "ISO/#{agency}" : "#{agency}#{agency1}/"
@@ -75,6 +75,12 @@ module IsoDoc
75
75
  [agency, publisher]
76
76
  end
77
77
 
78
+ def extract_variant(node)
79
+ node.nil? and return node
80
+ x = node.at(ns("./variant[@language = '#{@lang}']")) and node = x
81
+ node.text
82
+ end
83
+
78
84
  def agency(xml)
79
85
  agency, publisher = agency1(xml)
80
86
  set(:agency, agency.sub(%r{/$}, ""))
@@ -4,7 +4,7 @@ module IsoDoc
4
4
  class PresentationXMLConvert < ::IsoDoc::Convert
5
5
  def expand_citeas(text)
6
6
  text.nil? and return text
7
- HTMLEntities.new.decode(text.gsub(/&amp;#x/, "&#"))
7
+ HTMLEntities.new.decode(text.gsub("&amp;#x", "&#"))
8
8
  end
9
9
 
10
10
  def erefstack1(elem)
@@ -84,7 +84,7 @@ module IsoDoc
84
84
  locs1 = []
85
85
  until locs.empty?
86
86
  if locs[1] == "to"
87
- locs1 << @i18n.chain_to.sub(/%1/, locs[0]).sub(/%2/, locs[2])
87
+ locs1 << @i18n.chain_to.sub("%1", locs[0]).sub("%2", locs[2])
88
88
  locs.shift(3)
89
89
  else locs1 << locs.shift
90
90
  end