metanorma-un 0.4.0 → 0.5.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.
@@ -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#{@xrefs.anchor(node['id'], :level, false) || '1'}" do |h|
102
- lbl = @xrefs.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
@@ -76,9 +76,8 @@ module IsoDoc
76
76
  xref: l10n("#{@labels['clause']} #{lbl}") }
77
77
  i = 1
78
78
  clause.xpath(ns(NONTERMINAL)).each do |c|
79
- next if c["unnumbered"] == "true"
80
79
  section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
81
- i += 1 if !leaf_section?(c)
80
+ i += 1 if !leaf_section?(c) && c["unnumbered"] != "true"
82
81
  end
83
82
  num
84
83
  end
@@ -86,18 +85,18 @@ module IsoDoc
86
85
  def section_names1(clause, num, level)
87
86
  leaf_section?(clause) and label_leaf_section(clause, level) and return
88
87
  /\.(?<leafnum>[^.]+$)/ =~ num
89
- @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
90
- xref: l10n("#{@labels['clause']} #{num}") }
88
+ clause["unnumbered"] == "true" or
89
+ @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
90
+ xref: l10n("#{@labels['clause']} #{num}") }
91
91
  i = 1
92
92
  clause.xpath(ns(NONTERMINAL)).each do |c|
93
- next if c["unnumbered"] == "true"
94
93
  section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
95
- i += 1 if !leaf_section?(c)
94
+ i += 1 if !leaf_section?(c) && c["unnumbered"] != "true"
96
95
  end
97
96
  end
98
97
 
99
98
  def annex_name_lbl(clause, num)
100
- l10n("<b>#{@labels['annex']} #{num}</b>")
99
+ l10n("<strong>#{@labels['annex']} #{num}</strong>")
101
100
  end
102
101
 
103
102
  SUBCLAUSES =
@@ -128,7 +127,7 @@ module IsoDoc
128
127
  label_annex_leaf_section(clause, num, level) and return
129
128
  /\.(?<leafnum>[^.]+$)/ =~ num
130
129
  @anchors[clause["id"]] = { label: leafnum, xref: "#{@labels['annex']} #{num}",
131
- level: level, type: "clause" }
130
+ level: level, type: "clause" }
132
131
  i = 1
133
132
  clause.xpath(ns("./clause | ./references")).each do |c|
134
133
  next if c["unnumbered"] == "true"
@@ -30,10 +30,6 @@ 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
33
  def output(isodoc_node, inname, outname, format, options={})
38
34
  case format
39
35
  when :html
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.1"
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.1.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.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-26 00:00:00.000000000 Z
11
+ date: 2020-08-14 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.1.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.1.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,15 +259,21 @@ 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
287
279
  - lib/isodoc/un/presentation_xml_convert.rb