metanorma-un 0.3.6 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,11 +13,6 @@ module IsoDoc
13
13
  @toc = options[:toc]
14
14
  end
15
15
 
16
- #def convert1(docxml, filename, dir)
17
- #FileUtils.cp html_doc_path('logo.jpg'), File.join(@localdir, "logo.jpg")
18
- #super
19
- #end
20
-
21
16
  def default_fonts(options)
22
17
  {
23
18
  bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Times New Roman",serif'),
@@ -92,6 +87,7 @@ module IsoDoc
92
87
  end
93
88
 
94
89
  def middle(isoxml, out)
90
+ middle_admonitions(isoxml, out)
95
91
  clause isoxml, out
96
92
  annex isoxml, out
97
93
  bibliography isoxml, out
@@ -160,6 +156,7 @@ module IsoDoc
160
156
  sect2.next_element.remove # pagebreak
161
157
  sect2.remove # pagebreak
162
158
  end
159
+ abstractbox.parent.remove if abstractbox && !abstract
163
160
  end
164
161
 
165
162
  def abstract(isoxml, out)
@@ -0,0 +1,188 @@
1
+ require "roman-numerals"
2
+
3
+ module IsoDoc
4
+ module UN
5
+ module BaseConvert
6
+ MIDDLE_CLAUSE = "//clause[parent::sections]".freeze
7
+
8
+ def initial_anchor_names(d)
9
+ preface_names(d.at(ns("//preface/abstract")))
10
+ preface_names(d.at(ns("//foreword")))
11
+ preface_names(d.at(ns("//introduction")))
12
+ d.xpath(ns("//preface/clause")).each do |c|
13
+ preface_names(c)
14
+ end
15
+ preface_names(d.at(ns("//acknowledgements")))
16
+ sequential_asset_names(
17
+ d.xpath(ns("//preface/abstract | //foreword | //introduction | "\
18
+ "//preface/clause | //acknowledgements")))
19
+ middle_section_asset_names(d)
20
+ clause_names(d, 0)
21
+ termnote_anchor_names(d)
22
+ termexample_anchor_names(d)
23
+ end
24
+
25
+ def clause_names(docxml, sect_num)
26
+ q = "//clause[parent::sections]"
27
+ @paranumber = 0
28
+ docxml.xpath(ns(q)).each_with_index do |c, i|
29
+ section_names(c, (i + sect_num), 1)
30
+ end
31
+ end
32
+
33
+ def levelnumber(num, lvl)
34
+ case lvl % 3
35
+ when 1 then RomanNumerals.to_roman(num)
36
+ when 2 then ("A".ord + num - 1).chr
37
+ when 0 then num.to_s
38
+ end
39
+ end
40
+
41
+ def annex_levelnum(num, lvl)
42
+ case lvl % 3
43
+ when 0 then RomanNumerals.to_roman(num)
44
+ when 1 then ("A".ord + num - 1).chr
45
+ when 2 then num.to_s
46
+ end
47
+ end
48
+
49
+ NONTERMINAL =
50
+ "./clause | ./term | ./terms | ./definitions | ./references".freeze
51
+
52
+ def leaf_section?(clause)
53
+ !clause.at(ns(NONTERMINAL)) &&
54
+ !%w(definitions annex terms).include?(clause.name) &&
55
+ clause.at(ns("./p | ./bibitem"))
56
+ end
57
+
58
+ def label_leaf_section(clause, lvl)
59
+ @paranumber += 1
60
+ @anchors[clause["id"]] = {label: @paranumber.to_s,
61
+ xref: "paragraph #{@paranumber}",
62
+ level: lvl, type: "paragraph" }
63
+ end
64
+
65
+ def label_annex_leaf_section(clause, num, lvl)
66
+ @paranumber += 1
67
+ @anchors[clause["id"]] = {label: @paranumber.to_s,
68
+ xref: "paragraph #{num}.#{@paranumber}",
69
+ level: lvl, type: "paragraph" }
70
+ end
71
+
72
+ def section_names(clause, num, lvl)
73
+ return num if clause.nil?
74
+ leaf_section?(clause) and label_leaf_section(clause, lvl) and return
75
+ num = num + 1
76
+ lbl = levelnumber(num, 1)
77
+ @anchors[clause["id"]] = { label: lbl, level: lvl, type: "clause",
78
+ xref: l10n("#{@clause_lbl} #{lbl}") }
79
+ i = 1
80
+ clause.xpath(ns(NONTERMINAL)).each do |c|
81
+ next if c["unnumbered"] == "true"
82
+ section_names1(c, "#{lbl}.#{levelnumber(i, lvl + 1)}", lvl + 1)
83
+ i += 1 if !leaf_section?(c)
84
+ end
85
+ num
86
+ end
87
+
88
+ def section_names1(clause, num, level)
89
+ leaf_section?(clause) and label_leaf_section(clause, level) and return
90
+ /\.(?<leafnum>[^.]+$)/ =~ num
91
+ @anchors[clause["id"]] = { label: leafnum, level: level, type: "clause",
92
+ xref: l10n("#{@clause_lbl} #{num}") }
93
+ i = 1
94
+ clause.xpath(ns(NONTERMINAL)).each do |c|
95
+ next if c["unnumbered"] == "true"
96
+ section_names1(c, "#{num}.#{levelnumber(i, level + 1)}", level + 1)
97
+ i += 1 if !leaf_section?(c)
98
+ end
99
+ end
100
+
101
+ def annex_name_lbl(clause, num)
102
+ l10n("<b>#{@annex_lbl} #{num}</b>")
103
+ end
104
+
105
+ SUBCLAUSES =
106
+ "./clause | ./references | ./term | ./terms | ./definitions".freeze
107
+
108
+
109
+ def annex_names(clause, num)
110
+ hierarchical_asset_names(clause, num)
111
+ leaf_section?(clause) and
112
+ label_annex_leaf_section(clause, num, 1) and return
113
+ @anchors[clause["id"]] = { label: annex_name_lbl(clause, num),
114
+ type: "clause",
115
+ xref: "#{@annex_lbl} #{num}", level: 1 }
116
+ if a = single_annex_special_section(clause)
117
+ annex_names1(a, "#{num}", 1)
118
+ else
119
+ i = 1
120
+ clause.xpath(ns(SUBCLAUSES)).each do |c|
121
+ next if c["unnumbered"] == "true"
122
+ annex_names1(c, "#{num}.#{annex_levelnum(i, 2)}", 2)
123
+ i += 1 if !leaf_section?(c)
124
+ end
125
+ end
126
+ end
127
+
128
+ def annex_names1(clause, num, level)
129
+ leaf_section?(clause) and
130
+ label_annex_leaf_section(clause, num, level) and return
131
+ /\.(?<leafnum>[^.]+$)/ =~ num
132
+ @anchors[clause["id"]] = { label: leafnum, xref: "#{@annex_lbl} #{num}",
133
+ level: level, type: "clause" }
134
+ i = 1
135
+ clause.xpath(ns("./clause | ./references")).each do |c|
136
+ next if c["unnumbered"] == "true"
137
+ annex_names1(c, "#{num}.#{annex_levelnum(i, level + 1)}", level + 1)
138
+ i += 1 if !leaf_section?(c)
139
+ end
140
+ end
141
+
142
+ def back_anchor_names(docxml)
143
+ docxml.xpath(ns("//annex")).each_with_index do |c, i|
144
+ @paranumber = 0
145
+ annex_names(c, RomanNumerals.to_roman(i + 1))
146
+ end
147
+ docxml.xpath(ns("//bibliography/clause |"\
148
+ "//bibliography/references")).each do |b|
149
+ preface_names(b)
150
+ end
151
+ docxml.xpath(ns("//bibitem[not(ancestor::bibitem)]")).each do |ref|
152
+ reference_names(ref)
153
+ end
154
+ end
155
+
156
+ def sequential_admonition_names(clause)
157
+ i = 0
158
+ clause.xpath(ns(".//admonition")).each do |t|
159
+ next if t["id"].nil? || t["id"].empty?
160
+ i += 1 unless t["unnumbered"] == "true"
161
+ @anchors[t["id"]] = anchor_struct(i.to_s, nil, @admonition_lbl,
162
+ "box", t["unnumbered"])
163
+ end
164
+ end
165
+
166
+ def hierarchical_admonition_names(clause, num)
167
+ i = 0
168
+ clause.xpath(ns(".//admonition")).each do |t|
169
+ next if t["id"].nil? || t["id"].empty?
170
+ i += 1 unless t["unnumbered"] == "true"
171
+ @anchors[t["id"]] =
172
+ anchor_struct("#{num}.#{i}", nil, @admonition_lbl, "box",
173
+ t["unnumbered"])
174
+ end
175
+ end
176
+
177
+ def sequential_asset_names(clause)
178
+ super
179
+ sequential_admonition_names(clause)
180
+ end
181
+
182
+ def hierarchical_asset_names(clause, num)
183
+ super
184
+ hierarchical_admonition_names(clause, num)
185
+ end
186
+ end
187
+ end
188
+ end
@@ -2,6 +2,14 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module UN
5
+ def self.fonts_used
6
+ {
7
+ html: ["Arial", "Arial Black", "Courier", "Times New Roman", "HanSans"],
8
+ doc: ["Arial", "Arial Black", "Courier", "Times New Roman", "HanSans"],
9
+ pdf: ["Arial", "Arial Black", "Courier", "Times New Roman", "HanSans"],
10
+ }
11
+ end
12
+
5
13
  class Processor < Metanorma::Processor
6
14
 
7
15
  def initialize
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module UN
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.11"
4
4
  end
5
5
  end
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "twitter_cldr"
33
33
  spec.add_dependency "iso-639"
34
34
 
35
- spec.add_dependency "metanorma-standoc", "~> 1.3.0"
35
+ spec.add_dependency "metanorma-standoc", "~> 1.4.0"
36
36
  spec.add_dependency "isodoc", "~> 1.0.0"
37
37
 
38
38
  spec.add_development_dependency "byebug", "~> 9.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-un
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.11
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-04-17 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 1.3.0
89
+ version: 1.4.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 1.3.0
96
+ version: 1.4.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: isodoc
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -276,7 +276,6 @@ files:
276
276
  - lib/isodoc/un/html/htmlstyle.scss
277
277
  - lib/isodoc/un/html/logo.jpg
278
278
  - lib/isodoc/un/html/scripts.html
279
- - lib/isodoc/un/html/scripts.pdf.html
280
279
  - lib/isodoc/un/html/unece.scss
281
280
  - lib/isodoc/un/html/word_unece_intro.html
282
281
  - lib/isodoc/un/html/word_unece_plenary_titlepage.html
@@ -285,7 +284,11 @@ files:
285
284
  - lib/isodoc/un/html_convert.rb
286
285
  - lib/isodoc/un/metadata.rb
287
286
  - lib/isodoc/un/pdf_convert.rb
287
+ - lib/isodoc/un/un.plenary-attachment.xsl
288
+ - lib/isodoc/un/un.plenary.xsl
289
+ - lib/isodoc/un/un.recommendation.xsl
288
290
  - lib/isodoc/un/word_convert.rb
291
+ - lib/isodoc/un/xref.rb
289
292
  - lib/metanorma-un.rb
290
293
  - lib/metanorma/un.rb
291
294
  - lib/metanorma/un/UN_emblem_blue.svg
@@ -1,72 +0,0 @@
1
- <script>
2
- //TOC generation
3
- $('#toc').toc({
4
- 'selectors': toclevel(), //elements to use as headings
5
- 'container': 'main', //element to find all selectors in
6
- 'smoothScrolling': true, //enable or disable smooth scrolling on click
7
- 'prefix': 'toc', //prefix for anchor tags and class names
8
- 'onHighlight': function(el) {}, //called when a new section is highlighted
9
- 'highlightOnScroll': false, //add class to heading that is currently in focus
10
- 'highlightOffset': 100, //offset to trigger the next headline
11
- 'anchorName': function(i, heading, prefix) { //custom function for anchor name
12
- return prefix+i;
13
- },
14
- 'headerText': function(i, heading, $heading) { //custom function building the header-item text
15
- return $heading.text();
16
- },
17
- 'itemClass': function(i, heading, $heading, prefix) { // custom function for item class
18
- return $heading[0].tagName.toLowerCase();
19
- }
20
- });
21
-
22
- </script>
23
-
24
- <script>
25
- //TOC toggle animation
26
- $('#toggle').on('click', function(){
27
- if( $('nav').is(':visible') ) {
28
- $('nav').animate({ 'left': '-353px' }, 'slow', function(){
29
- $('nav').hide();
30
- });
31
- $('.container').animate({ 'padding-left': '31px' }, 'slow');
32
- }
33
- else {
34
- $('nav').show();
35
- $('nav').animate({ 'left': '0px' }, 'slow');
36
- $('.container').animate({ 'padding-left': '360px' }, 'slow');
37
- }
38
- });
39
- </script>
40
-
41
- <script>
42
- // Scroll to top button
43
- window.onscroll = function() {scrollFunction()};
44
-
45
- function scrollFunction() {
46
- if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
47
- document.getElementById("myBtn").style.display = "block";
48
- } else {
49
- document.getElementById("myBtn").style.display = "none";
50
- }
51
- }
52
-
53
- // When the user clicks on the button, scroll to the top of the document
54
- function topFunction() {
55
- document.body.scrollTop = 0;
56
- document.documentElement.scrollTop = 0;
57
- }
58
- </script>
59
-
60
- <script>
61
- /*
62
- $(document).ready(function() {
63
- $('[id^=toc]').each(function ()
64
- {
65
- var currentToc = $(this);
66
- var url = window.location.href;
67
- currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
68
- });
69
- });
70
- */
71
- </script>
72
-