metanorma-itu 0.2.8 → 1.0.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.
@@ -15,12 +15,6 @@ module IsoDoc
15
15
  super
16
16
  end
17
17
 
18
- def convert1(docxml, filename, dir)
19
- FileUtils.cp html_doc_path('Logo_ITU.jpg'), "#{@localdir}/Logo_ITU.jpg"
20
- @files_to_delete << "#{@localdir}/Logo_ITU.jpg"
21
- super
22
- end
23
-
24
18
  def default_fonts(options)
25
19
  {
26
20
  bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Open Sans",sans-serif'),
@@ -55,6 +49,7 @@ module IsoDoc
55
49
 
56
50
  def make_body3(body, docxml)
57
51
  body.div **{ class: "main-section" } do |div3|
52
+ boilerplate docxml, div3
58
53
  abstract docxml, div3
59
54
  preface docxml, div3
60
55
  middle docxml, div3
@@ -63,7 +58,26 @@ module IsoDoc
63
58
  end
64
59
  end
65
60
 
66
- include BaseConvert
61
+ def html_preface(docxml)
62
+ super
63
+ authority_cleanup(docxml)
64
+ docxml
65
+ end
66
+
67
+ def authority_cleanup(docxml)
68
+ dest = docxml.at("//div[@class = 'draft-warning']")
69
+ auth = docxml.at("//div[@id = 'draft-warning']")
70
+ auth&.xpath(".//h1 | .//h2")&.each { |h| h["class"] = "IntroTitle" }
71
+ dest and auth and dest.replace(auth.remove)
72
+ %w(copyright license legal).each do |t|
73
+ dest = docxml.at("//div[@id = '#{t}']")
74
+ auth = docxml.at("//div[@class = '#{t}']")
75
+ auth&.xpath(".//h1 | .//h2")&.each { |h| h["class"] = "IntroTitle" }
76
+ dest and auth and dest.replace(auth.remove)
77
+ end
78
+ end
79
+
80
+ include BaseConvert
67
81
  end
68
82
  end
69
83
  end
@@ -10,3 +10,4 @@ inform_annex: (This appendix does not form an integral part of this %.)
10
10
  formula: Equation
11
11
  inequality: Inequality
12
12
  annex_subclause: Clause
13
+ in: in
@@ -6,6 +6,12 @@ module IsoDoc
6
6
  class Metadata < IsoDoc::Metadata
7
7
  def initialize(lang, script, labels)
8
8
  super
9
+ here = File.dirname(__FILE__)
10
+ set(:logo_html,
11
+ File.expand_path(File.join(here, "html", "Logo_ITU.jpg")))
12
+ set(:logo_comb,
13
+ File.expand_path(File.join(here, "html", "itu-document-comb.png")))
14
+ set(:logo_word, File.expand_path(File.join(here, "html", "logo.png")))
9
15
  end
10
16
 
11
17
  def title(isoxml, _out)
@@ -13,9 +19,11 @@ module IsoDoc
13
19
  set(:doctitle, main)
14
20
  series = isoxml&.at(ns("//bibdata/series[@type='main']/title"))&.text
15
21
  set(:series, series)
16
- series1 = isoxml&.at(ns("//bibdata/series[@type='secondary']/title"))&.text
22
+ series1 =
23
+ isoxml&.at(ns("//bibdata/series[@type='secondary']/title"))&.text
17
24
  set(:series1, series1)
18
- series2 = isoxml&.at(ns("//bibdata/series[@type='tertiary']/title"))&.text
25
+ series2 =
26
+ isoxml&.at(ns("//bibdata/series[@type='tertiary']/title"))&.text
19
27
  set(:series2, series2)
20
28
  annext = isoxml&.at(ns("//bibdata/title[@type='annex']"))&.text
21
29
  set(:annextitle, annext)
@@ -88,7 +96,8 @@ module IsoDoc
88
96
  end
89
97
 
90
98
  def ip_notice_received(isoxml, _out)
91
- received = isoxml.at(ns("//bibdata/ext/ip-notice-received"))&.text || "false"
99
+ received = isoxml.at(ns("//bibdata/ext/ip-notice-received"))&.text ||
100
+ "false"
92
101
  set(:ip_notice_received, received)
93
102
  end
94
103
  end
@@ -13,11 +13,11 @@ module IsoDoc
13
13
  super
14
14
  end
15
15
 
16
- def convert1(docxml, filename, dir)
17
- FileUtils.cp html_doc_path('Logo_ITU.jpg'), File.join(@localdir, "Logo_ITU.jpg")
18
- @files_to_delete << File.join(@localdir, "Logo_ITU.jpg")
19
- super
20
- end
16
+ #def convert1(docxml, filename, dir)
17
+ # FileUtils.cp html_doc_path('Logo_ITU.jpg'), File.join(@localdir, "Logo_ITU.jpg")
18
+ # @files_to_delete << File.join(@localdir, "Logo_ITU.jpg")
19
+ # super
20
+ #end
21
21
 
22
22
  def html_toc(docxml)
23
23
  docxml
@@ -57,6 +57,7 @@ module IsoDoc
57
57
 
58
58
  def make_body3(body, docxml)
59
59
  body.div **{ class: "main-section" } do |div3|
60
+ boilerplate docxml, div3
60
61
  abstract docxml, div3
61
62
  preface docxml, div3
62
63
  middle docxml, div3
@@ -65,6 +66,25 @@ module IsoDoc
65
66
  end
66
67
  end
67
68
 
69
+ def html_preface(docxml)
70
+ super
71
+ authority_cleanup(docxml)
72
+ docxml
73
+ end
74
+
75
+ def authority_cleanup(docxml)
76
+ dest = docxml.at("//div[@class = 'draft-warning']")
77
+ auth = docxml.at("//div[@id = 'draft-warning']")
78
+ auth&.xpath(".//h1 | .//h2")&.each { |h| h["class"] = "IntroTitle" }
79
+ dest and auth and dest.replace(auth.remove)
80
+ %w(copyright license legal).each do |t|
81
+ dest = docxml.at("//div[@id = '#{t}']")
82
+ auth = docxml.at("//div[@class = '#{t}']")
83
+ auth&.xpath(".//h1 | .//h2")&.each { |h| h["class"] = "IntroTitle" }
84
+ dest and auth and dest.replace(auth.remove)
85
+ end
86
+ end
87
+
68
88
  include BaseConvert
69
89
  end
70
90
  end
@@ -0,0 +1,87 @@
1
+ module IsoDoc
2
+ module ITU
3
+ module BaseConvert
4
+ def terms_defs_title(node)
5
+ t = node.at(ns("./title")) and return t.text
6
+ super
7
+ end
8
+
9
+ def terms_defs(node, out, num)
10
+ f = node.at(ns(IsoDoc::Convert::TERM_CLAUSE)) or return num
11
+ out.div **attr_code(id: f["id"]) do |div|
12
+ num = num + 1
13
+ clause_name(num, terms_defs_title(f), div, nil)
14
+ if f.at(ns("./clause | ./terms | ./term")).nil? then out.p "None."
15
+ else
16
+ f.children.reject { |c1| c1.name == "title" }.each do |c1|
17
+ parse(c1, div)
18
+ end
19
+ end
20
+ end
21
+ num
22
+ end
23
+
24
+ def terms_parse(node, out)
25
+ out.div **attr_code(id: node["id"]) do |div|
26
+ clause_parse_title(node, div, node.at(ns("./title")), out)
27
+ if node.at(ns("./clause | ./term")).nil? then out.p "None."
28
+ else
29
+ node.children.reject { |c1| c1.name == "title" }.each do |c1|
30
+ parse(c1, div)
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def termdef_parse1(node, div, term, defn, source)
37
+ div.p **{ class: "TermNum", id: node["id"] } do |p|
38
+ p.b do |b|
39
+ b << anchor(node["id"], :label)
40
+ insert_tab(b, 1)
41
+ term.children.each { |n| parse(n, b) }
42
+ end
43
+ source and p << " [#{source.value}]"
44
+ p << ": "
45
+ end
46
+ defn and defn.children.each { |n| parse(n, div) }
47
+ end
48
+
49
+ def termdef_parse(node, out)
50
+ term = node.at(ns("./preferred"))
51
+ defn = node.at(ns("./definition"))
52
+ source = node.at(ns("./termsource/origin/@citeas"))
53
+ out.div **attr_code(id: node["id"]) do |div|
54
+ termdef_parse1(node, div, term, defn, source)
55
+ set_termdomain("")
56
+ node.children.each do |n|
57
+ next if %w(preferred definition termsource title).include? n.name
58
+ parse(n, out)
59
+ end
60
+ end
61
+ end
62
+
63
+ def termnote_parse(node, out)
64
+ out.div **{ class: "Note" } do |div|
65
+ first = node.first_element_child
66
+ div.p do |p|
67
+ p << note_label(node) # "#{anchor(node['id'], :label) || '???'}: "
68
+ para_then_remainder(first, node, p, div)
69
+ end
70
+ end
71
+ end
72
+
73
+ def termnote_anchor_names(docxml)
74
+ docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
75
+ c = IsoDoc::Function::XrefGen::Counter.new
76
+ notes = t.xpath(ns(".//termnote"))
77
+ notes.each do |n|
78
+ return if n["id"].nil? || n["id"].empty?
79
+ idx = notes.size == 1 ? "" : " #{c.increment(n).print}"
80
+ @anchors[n["id"]] = anchor_struct(idx, n, @note_xref_lbl,
81
+ "termnote", false)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -26,6 +26,7 @@ module IsoDoc
26
26
  def make_body2(body, docxml)
27
27
  body.div **{ class: "WordSection2" } do |div2|
28
28
  info docxml, div2
29
+ boilerplate docxml, div2
29
30
  abstract docxml, div2
30
31
  keywords docxml, div2
31
32
  preface docxml, div2
@@ -70,7 +71,9 @@ module IsoDoc
70
71
  word_preface_cleanup(docxml)
71
72
  word_term_cleanup(docxml)
72
73
  word_history_cleanup(docxml)
74
+ authority_hdr_cleanup(docxml)
73
75
  super
76
+ authority_cleanup(docxml)
74
77
  docxml
75
78
  end
76
79
 
@@ -124,15 +127,6 @@ module IsoDoc
124
127
  end
125
128
  end
126
129
 
127
- def convert1(docxml, filename, dir)
128
- FileUtils.cp html_doc_path('itu-document-comb.png'),
129
- File.join(@localdir, "itu-document-comb.png")
130
- FileUtils.cp html_doc_path('logo.png'), File.join(@localdir, "logo.png")
131
- @files_to_delete << File.join(@localdir, "itu-document-comb.png")
132
- @files_to_delete << File.join(@localdir, "logo.png")
133
- super
134
- end
135
-
136
130
  def default_fonts(options)
137
131
  { bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
138
132
  '"Times New Roman",serif'),
@@ -151,15 +145,89 @@ module IsoDoc
151
145
  olstyle: "l2", }
152
146
  end
153
147
 
154
- def word_example_cleanup(docxml)
155
- super
156
- docxml.xpath("//div[@class = 'pseudocode']//p[not(@class)]").each do |p|
157
- p["class"] = "pseudocode"
148
+ def make_tr_attr(td, row, totalrows, header)
149
+ super.merge(valign: "top")
150
+ end
151
+
152
+ def ol_parse(node, out)
153
+ out.ol **attr_code(class: node["class"], id: node["id"] ) do |ol|
154
+ node.children.each { |n| parse(n, ol) }
158
155
  end
159
156
  end
160
157
 
161
- def make_tr_attr(td, row, totalrows, header)
162
- super.merge(valign: "top")
158
+ def toWord(result, filename, dir, header)
159
+ result = populate_template(result, :word)
160
+ result = from_xhtml(word_cleanup(to_xhtml(result)))
161
+ Html2Doc.process(result, filename: filename, stylesheet: @wordstylesheet&.path,
162
+ header_file: header&.path, dir: dir,
163
+ asciimathdelims: [@openmathdelim, @closemathdelim],
164
+ liststyles: { ul: @ulstyle, ol: @olstyle, steps: "l4" })
165
+ header&.unlink
166
+ @wordstylesheet&.unlink
167
+ end
168
+
169
+ =begin
170
+ def eref_parse(node, out)
171
+ linkend = get_linkend(node)
172
+ if node["type"] == "footnote"
173
+ out.sup { |s| s << linkend }
174
+ else
175
+ out << linkend
176
+ end
177
+ end
178
+
179
+ def xref_parse(node, out)
180
+ #target = /#/.match(node["target"]) ? node["target"].sub(/#/, ".html#") :
181
+ # "##{node["target"]}"
182
+ out << get_linkend(node)
183
+ end
184
+ =end
185
+
186
+ def link_parse(node, out)
187
+ out.a **attr_code(href: node["target"], title: node["alt"], class: "url") do |l|
188
+ if node.text.empty?
189
+ l << node["target"].sub(/^mailto:/, "")
190
+ else
191
+ node.children.each { |n| parse(n, l) }
192
+ end
193
+ end
194
+ end
195
+
196
+ def authority_hdr_cleanup(docxml)
197
+ docxml&.xpath("//div[@id = 'draft-warning']").each do |d|
198
+ d.xpath(".//h1 | .//h2").each do |p|
199
+ p.name = "p"
200
+ p["class"] = "draftwarningHdr"
201
+ end
202
+ end
203
+ %w(copyright license legal).each do |t|
204
+ docxml&.xpath("//div[@class = '#{t}']").each do |d|
205
+ p = d&.at("./descendant::h1[2]") and
206
+ p.previous = "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>"
207
+ d.xpath(".//h1 | .//h2").each do |p|
208
+ p.name = "p"
209
+ p["class"] = "boilerplateHdr"
210
+ end
211
+ end
212
+ end
213
+ end
214
+
215
+ def authority_cleanup(docxml)
216
+ dest = docxml.at("//div[@class = 'draft-warning']")
217
+ auth = docxml.at("//div[@id = 'draft-warning']")
218
+ dest and auth and dest.replace(auth.remove)
219
+ %w(copyright license legal).each do |t|
220
+ dest = docxml.at("//div[@id = '#{t}']")
221
+ auth = docxml.at("//div[@class = '#{t}']")
222
+ next unless auth && dest
223
+ t == "copyright" and p = auth&.at(".//p[@class = 'Normalaftertitle']") and
224
+ p["class"] = "boilerplateHdr"
225
+ auth&.xpath(".//p[not(@class) or @class = 'Normalaftertitle']")&.each do |p|
226
+ p["class"] = "boilerplate"
227
+ end
228
+ auth << "<p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>" unless t == "copyright"
229
+ dest.replace(auth.remove)
230
+ end
163
231
  end
164
232
 
165
233
  include BaseConvert
@@ -46,9 +46,8 @@ module IsoDoc
46
46
  end
47
47
 
48
48
  def initial_anchor_names(d)
49
- d.xpath("//xmlns:preface/child::*").each do |c|
50
- preface_names(c)
51
- end
49
+ d.xpath(ns("//boilerplate//clause")).each { |c| preface_names(c) }
50
+ d.xpath("//xmlns:preface/child::*").each { |c| preface_names(c) }
52
51
  @hierarchical_assets ?
53
52
  hierarchical_asset_names(d.xpath("//xmlns:preface/child::*"), "Preface") :
54
53
  sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
@@ -83,7 +82,7 @@ module IsoDoc
83
82
  def sequential_figure_names(clause)
84
83
  c = IsoDoc::Function::XrefGen::Counter.new
85
84
  j = 0
86
- clause.xpath(ns(".//figure[not(@type = 'pseudocode')]")).each do |t|
85
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
87
86
  if t.parent.name == "figure" then j += 1
88
87
  else
89
88
  j = 0
@@ -99,7 +98,7 @@ module IsoDoc
99
98
  def hierarchical_figure_names(clause, num)
100
99
  c = IsoDoc::Function::XrefGen::Counter.new
101
100
  j = 0
102
- clause.xpath(ns(".//figure[not(@type = 'pseudocode')]")).each do |t|
101
+ clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
103
102
  if t.parent.name == "figure" then j += 1
104
103
  else
105
104
  j = 0
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "0.2.8"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
@@ -24,13 +24,11 @@ Gem::Specification.new do |spec|
24
24
  spec.require_paths = ["lib"]
25
25
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
26
26
 
27
- spec.add_dependency "asciidoctor", "~> 1.5.7"
28
27
  spec.add_dependency "htmlentities", "~> 4.3.4"
29
28
  spec.add_dependency "ruby-jing"
30
29
  spec.add_dependency "metanorma-standoc", "~> 1.3.0"
31
30
  spec.add_dependency "isodoc", "~> 1.0.0"
32
31
 
33
- spec.add_development_dependency "bundler", "~> 2.0.1"
34
32
  spec.add_development_dependency "byebug", "~> 9.1"
35
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
36
34
  spec.add_development_dependency "guard", "~> 2.14"
@@ -41,4 +39,6 @@ Gem::Specification.new do |spec|
41
39
  spec.add_development_dependency "simplecov", "~> 0.15"
42
40
  spec.add_development_dependency "timecop", "~> 0.9"
43
41
  spec.add_development_dependency "metanorma", "~> 0.3.0"
42
+ spec.add_development_dependency "vcr", "~> 5.0.0"
43
+ spec.add_development_dependency "webmock"
44
44
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-27 00:00:00.000000000 Z
11
+ date: 2019-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: asciidoctor
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.5.7
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.5.7
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: htmlentities
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +66,6 @@ dependencies:
80
66
  - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: 1.0.0
83
- - !ruby/object:Gem::Dependency
84
- name: bundler
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 2.0.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 2.0.1
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: byebug
99
71
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +206,34 @@ dependencies:
234
206
  - - "~>"
235
207
  - !ruby/object:Gem::Version
236
208
  version: 0.3.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: vcr
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: 5.0.0
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: 5.0.0
223
+ - !ruby/object:Gem::Dependency
224
+ name: webmock
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
237
237
  description: 'Metanorma for the ITU.
238
238
 
239
239
  '
@@ -260,18 +260,21 @@ files:
260
260
  - lib/asciidoctor/itu.rb
261
261
  - lib/asciidoctor/itu/basicdoc.rng
262
262
  - lib/asciidoctor/itu/biblio.rng
263
+ - lib/asciidoctor/itu/cleanup.rb
263
264
  - lib/asciidoctor/itu/converter.rb
264
265
  - lib/asciidoctor/itu/front.rb
265
266
  - lib/asciidoctor/itu/i18n-en.yaml
266
267
  - lib/asciidoctor/itu/isodoc.rng
267
268
  - lib/asciidoctor/itu/isostandard.rng
268
269
  - lib/asciidoctor/itu/itu.rng
270
+ - lib/asciidoctor/itu/itu_intro.xml
269
271
  - lib/asciidoctor/itu/macros.rb
270
272
  - lib/asciidoctor/itu/reqt.rng
271
273
  - lib/asciidoctor/itu/validate.rb
272
274
  - lib/isodoc/itu.rb
273
275
  - lib/isodoc/itu/base_convert.rb
274
276
  - lib/isodoc/itu/html/Logo_ITU.jpg
277
+ - lib/isodoc/itu/html/_coverpage.scss
275
278
  - lib/isodoc/itu/html/header.html
276
279
  - lib/isodoc/itu/html/html_itu_intro.html
277
280
  - lib/isodoc/itu/html/html_itu_titlepage.html
@@ -289,6 +292,7 @@ files:
289
292
  - lib/isodoc/itu/metadata.rb
290
293
  - lib/isodoc/itu/pdf_convert.rb
291
294
  - lib/isodoc/itu/ref.rb
295
+ - lib/isodoc/itu/terms.rb
292
296
  - lib/isodoc/itu/word_convert.rb
293
297
  - lib/isodoc/itu/xref.rb
294
298
  - lib/metanorma-itu.rb