metanorma-un 0.3.11 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require_relative "init"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
@@ -15,8 +16,10 @@ module IsoDoc
15
16
 
16
17
  def default_fonts(options)
17
18
  {
18
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Times New Roman",serif'),
19
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Times New Roman",serif'),
19
+ bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
20
+ '"Times New Roman",serif'),
21
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
22
+ '"Times New Roman",serif'),
20
23
  monospacefont: '"Courier New",monospace'
21
24
  }
22
25
  end
@@ -47,7 +50,8 @@ module IsoDoc
47
50
 
48
51
  def make_body(xml, docxml)
49
52
  plenary = is_plenary?(docxml)
50
- if plenary && @wordcoverpage == html_doc_path("word_unece_titlepage.html")
53
+ if plenary &&
54
+ @wordcoverpage == html_doc_path("word_unece_titlepage.html")
51
55
  @wordcoverpage = html_doc_path("word_unece_plenary_titlepage.html")
52
56
  end
53
57
  @wordintropage = nil if plenary && !@toc
@@ -94,27 +98,12 @@ module IsoDoc
94
98
  end_line(isoxml, out)
95
99
  end
96
100
 
97
- def clause_parse_title(node, div, c1, out)
98
- if node["inline-header"] == "true"
99
- inline_header_title(out, node, c1)
100
- else
101
- div.send "h#{anchor(node['id'], :level, false) || '1'}" do |h|
102
- lbl = anchor(node['id'], :label, false)
103
- if lbl && !@suppressheadingnumbers
104
- h << "#{lbl}. "
105
- insert_tab(h, 1)
106
- end
107
- c1&.children&.each { |c2| parse(c2, h) }
108
- end
109
- end
110
- end
111
-
112
101
  def introduction(isoxml, out)
113
102
  f = isoxml.at(ns("//introduction")) || return
114
103
  out.div **{ class: "Section3", id: f["id"] } do |div|
115
104
  page_break(out)
116
105
  div.p(**{ class: "IntroTitle" }) do |h1|
117
- h1 << @introduction_lbl
106
+ f&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
118
107
  end
119
108
  f.elements.each do |e|
120
109
  parse(e, div) unless e.name == "title"
@@ -127,7 +116,7 @@ module IsoDoc
127
116
  out.div **attr_code(id: f["id"]) do |s|
128
117
  page_break(out)
129
118
  s.p(**{ class: "ForewordTitle" }) do |h1|
130
- h1 << @foreword_lbl
119
+ f&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
131
120
  end
132
121
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
133
122
  end
@@ -135,7 +124,8 @@ module IsoDoc
135
124
 
136
125
  def word_preface(docxml)
137
126
  super
138
- preface_container = docxml.at("//div[@id = 'preface_container']") # recommendation
127
+ preface_container =
128
+ docxml.at("//div[@id = 'preface_container']") # recommendation
139
129
  abstractbox = docxml.at("//div[@id = 'abstractbox']") # plenary
140
130
  foreword = docxml.at("//p[@class = 'ForewordTitle']/..")
141
131
  intro = docxml.at("//p[@class = 'IntroTitle']/..")
@@ -163,18 +153,22 @@ module IsoDoc
163
153
  f = isoxml.at(ns("//abstract")) || return
164
154
  out.div **attr_code(id: f["id"]) do |s|
165
155
  page_break(out)
166
- s.p(**{ class: "AbstractTitle" }) { |h1| h1 << @abstract_lbl }
156
+ s.p(**{ class: "AbstractTitle" }) do |h1|
157
+ f&.at(ns("./title"))&.children&.each { |n| parse(n, h1) }
158
+ end
167
159
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
168
160
  end
169
161
  end
170
162
 
171
163
  def authority_cleanup(docxml)
172
164
  super
173
- a = docxml.at("//div[@id = 'boilerplate-ECEhdr']") and a["class"] = "boilerplate-ECEhdr"
165
+ a = docxml.at("//div[@id = 'boilerplate-ECEhdr']") and
166
+ a["class"] = "boilerplate-ECEhdr"
174
167
  docxml&.at("//div[@class = 'authority']")&.remove
175
168
  end
176
169
 
177
170
  include BaseConvert
171
+ include Init
178
172
  end
179
173
  end
180
174
  end
@@ -2,9 +2,7 @@ require "roman-numerals"
2
2
 
3
3
  module IsoDoc
4
4
  module UN
5
- module BaseConvert
6
- MIDDLE_CLAUSE = "//clause[parent::sections]".freeze
7
-
5
+ class Xref < IsoDoc::Xref
8
6
  def initial_anchor_names(d)
9
7
  preface_names(d.at(ns("//preface/abstract")))
10
8
  preface_names(d.at(ns("//foreword")))
@@ -75,12 +73,11 @@ module IsoDoc
75
73
  num = num + 1
76
74
  lbl = levelnumber(num, 1)
77
75
  @anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
78
- xref: l10n("#{@clause_lbl} #{lbl}") }
76
+ xref: l10n("#{@labels['clause']} #{lbl}") }
79
77
  i = 1
80
78
  clause.xpath(ns(NONTERMINAL)).each do |c|
81
- next if c["unnumbered"] == "true"
82
79
  section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
83
- i += 1 if !leaf_section?(c)
80
+ i += 1 if !leaf_section?(c) && c["unnumbered"] != "true"
84
81
  end
85
82
  num
86
83
  end
@@ -88,22 +85,22 @@ module IsoDoc
88
85
  def section_names1(clause, num, level)
89
86
  leaf_section?(clause) and label_leaf_section(clause, level) and return
90
87
  /\.(?<leafnum>[^.]+$)/ =~ num
91
- @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
92
- xref: l10n("#{@clause_lbl} #{num}") }
88
+ clause["unnumbered"] == "true" or
89
+ @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
90
+ xref: l10n("#{@labels['clause']} #{num}") }
93
91
  i = 1
94
92
  clause.xpath(ns(NONTERMINAL)).each do |c|
95
- next if c["unnumbered"] == "true"
96
93
  section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
97
- i += 1 if !leaf_section?(c)
94
+ i += 1 if !leaf_section?(c) && c["unnumbered"] != "true"
98
95
  end
99
96
  end
100
97
 
101
98
  def annex_name_lbl(clause, num)
102
- l10n("<b>#{@annex_lbl} #{num}</b>")
99
+ l10n("<strong>#{@labels['annex']} #{num}</strong>")
103
100
  end
104
101
 
105
102
  SUBCLAUSES =
106
- "./clause | ./references | ./term | ./terms | ./definitions".freeze
103
+ "./clause | ./references | ./term | ./terms | ./definitions".freeze
107
104
 
108
105
 
109
106
  def annex_names(clause, num)
@@ -112,13 +109,13 @@ module IsoDoc
112
109
  label_annex_leaf_section(clause, num, 1) and return
113
110
  @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
114
111
  type: "clause",
115
- xref: "#{@annex_lbl} #{num}", level: 1 }
112
+ xref: "#{@labels['annex']} #{num}", level: 1 }
116
113
  if a = single_annex_special_section(clause)
117
114
  annex_names1(a, "#{num}", 1)
118
115
  else
119
116
  i = 1
120
117
  clause.xpath(ns(SUBCLAUSES)).each do |c|
121
- next if c["unnumbered"] == "true"
118
+ next if c["unnumbered"] == "true"
122
119
  annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
123
120
  i += 1 if !leaf_section?(c)
124
121
  end
@@ -129,7 +126,7 @@ module IsoDoc
129
126
  leaf_section?(clause) and
130
127
  label_annex_leaf_section(clause, num, level) and return
131
128
  /\.(?<leafnum>[^.]+$)/ =~ num
132
- @anchors[clause["id"]] = { label: leafnum, xref: "#{@annex_lbl} #{num}",
129
+ @anchors[clause["id"]] = { label: leafnum, xref: "#{@labels['annex']} #{num}",
133
130
  level: level, type: "clause" }
134
131
  i = 1
135
132
  clause.xpath(ns("./clause | ./references")).each do |c|
@@ -158,7 +155,7 @@ module IsoDoc
158
155
  clause.xpath(ns(".//admonition")).each do |t|
159
156
  next if t["id"].nil? || t["id"].empty?
160
157
  i += 1 unless t["unnumbered"] == "true"
161
- @anchors[t["id"]] = anchor_struct(i.to_s, nil, @admonition_lbl,
158
+ @anchors[t["id"]] = anchor_struct(i.to_s, nil, @labels["admonition"],
162
159
  "box", t["unnumbered"])
163
160
  end
164
161
  end
@@ -169,7 +166,7 @@ module IsoDoc
169
166
  next if t["id"].nil? || t["id"].empty?
170
167
  i += 1 unless t["unnumbered"] == "true"
171
168
  @anchors[t["id"]] =
172
- anchor_struct("#{num}.#{i}", nil, @admonition_lbl, "box",
169
+ anchor_struct("#{num}.#{i}", nil, @labels["admonition"], "box",
173
170
  t["unnumbered"])
174
171
  end
175
172
  end
@@ -30,18 +30,16 @@ module Metanorma
30
30
  "Metanorma::UN #{Metanorma::UN::VERSION}"
31
31
  end
32
32
 
33
- def input_to_isodoc(file, filename)
34
- Metanorma::UN::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
35
- end
36
-
37
- def output(isodoc_node, outname, format, options={})
33
+ def output(isodoc_node, inname, outname, format, options={})
38
34
  case format
39
35
  when :html
40
- IsoDoc::UN::HtmlConvert.new(options).convert(outname, isodoc_node)
36
+ IsoDoc::UN::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
41
37
  when :doc
42
- IsoDoc::UN::WordConvert.new(options).convert(outname, isodoc_node)
38
+ IsoDoc::UN::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
43
39
  when :pdf
44
- IsoDoc::UN::PdfConvert.new(options).convert(outname, isodoc_node)
40
+ IsoDoc::UN::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
41
+ when :presentation
42
+ IsoDoc::UN::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
45
43
  else
46
44
  super
47
45
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.3.11"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -26,16 +26,15 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
28
28
 
29
- spec.add_dependency "htmlentities", "~> 4.3.4"
30
- spec.add_dependency "ruby-jing"
31
29
  spec.add_dependency "roman-numerals"
32
30
  spec.add_dependency "twitter_cldr"
33
31
  spec.add_dependency "iso-639"
34
32
 
35
- spec.add_dependency "metanorma-standoc", "~> 1.4.0"
36
- spec.add_dependency "isodoc", "~> 1.0.0"
33
+ spec.add_dependency "metanorma-standoc", "~> 1.5.0"
34
+ spec.add_dependency "isodoc", "~> 1.2.0"
37
35
 
38
36
  spec.add_development_dependency "byebug", "~> 9.1"
37
+ spec.add_development_dependency "sassc", "2.4.0"
39
38
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
40
39
  spec.add_development_dependency "guard", "~> 2.14"
41
40
  spec.add_development_dependency "guard-rspec", "~> 4.7"
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: htmlentities
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 4.3.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 4.3.4
27
- - !ruby/object:Gem::Dependency
28
- name: ruby-jing
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
13
  - !ruby/object:Gem::Dependency
42
14
  name: roman-numerals
43
15
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +58,28 @@ dependencies:
86
58
  requirements:
87
59
  - - "~>"
88
60
  - !ruby/object:Gem::Version
89
- version: 1.4.0
61
+ version: 1.5.0
90
62
  type: :runtime
91
63
  prerelease: false
92
64
  version_requirements: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - "~>"
95
67
  - !ruby/object:Gem::Version
96
- version: 1.4.0
68
+ version: 1.5.0
97
69
  - !ruby/object:Gem::Dependency
98
70
  name: isodoc
99
71
  requirement: !ruby/object:Gem::Requirement
100
72
  requirements:
101
73
  - - "~>"
102
74
  - !ruby/object:Gem::Version
103
- version: 1.0.0
75
+ version: 1.2.0
104
76
  type: :runtime
105
77
  prerelease: false
106
78
  version_requirements: !ruby/object:Gem::Requirement
107
79
  requirements:
108
80
  - - "~>"
109
81
  - !ruby/object:Gem::Version
110
- version: 1.0.0
82
+ version: 1.2.0
111
83
  - !ruby/object:Gem::Dependency
112
84
  name: byebug
113
85
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +94,20 @@ dependencies:
122
94
  - - "~>"
123
95
  - !ruby/object:Gem::Version
124
96
  version: '9.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sassc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.4.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 2.4.0
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: equivalent-xml
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -273,17 +259,24 @@ files:
273
259
  - lib/isodoc/un/html/html_unece_intro.html
274
260
  - lib/isodoc/un/html/html_unece_plenary_titlepage.html
275
261
  - lib/isodoc/un/html/html_unece_titlepage.html
262
+ - lib/isodoc/un/html/htmlstyle.css
276
263
  - lib/isodoc/un/html/htmlstyle.scss
277
264
  - lib/isodoc/un/html/logo.jpg
278
265
  - lib/isodoc/un/html/scripts.html
266
+ - lib/isodoc/un/html/unece.css
279
267
  - lib/isodoc/un/html/unece.scss
280
268
  - lib/isodoc/un/html/word_unece_intro.html
281
269
  - lib/isodoc/un/html/word_unece_plenary_titlepage.html
282
270
  - lib/isodoc/un/html/word_unece_titlepage.html
271
+ - lib/isodoc/un/html/wordstyle.css
283
272
  - lib/isodoc/un/html/wordstyle.scss
284
273
  - lib/isodoc/un/html_convert.rb
274
+ - lib/isodoc/un/i18n-en.yaml
275
+ - lib/isodoc/un/i18n.rb
276
+ - lib/isodoc/un/init.rb
285
277
  - lib/isodoc/un/metadata.rb
286
278
  - lib/isodoc/un/pdf_convert.rb
279
+ - lib/isodoc/un/presentation_xml_convert.rb
287
280
  - lib/isodoc/un/un.plenary-attachment.xsl
288
281
  - lib/isodoc/un/un.plenary.xsl
289
282
  - lib/isodoc/un/un.recommendation.xsl
@@ -300,7 +293,7 @@ homepage: https://github.com/metanorma/metanorma-un
300
293
  licenses:
301
294
  - BSD-2-Clause
302
295
  metadata: {}
303
- post_install_message:
296
+ post_install_message:
304
297
  rdoc_options: []
305
298
  require_paths:
306
299
  - lib
@@ -315,9 +308,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
308
  - !ruby/object:Gem::Version
316
309
  version: '0'
317
310
  requirements: []
318
- rubyforge_project:
319
- rubygems_version: 2.7.6
320
- signing_key:
311
+ rubygems_version: 3.0.3
312
+ signing_key:
321
313
  specification_version: 4
322
314
  summary: Metanorma for UN.
323
315
  test_files: []