metanorma-unece 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4106169b0beff0251701a368f8d8435c00f6abbce94f305529ad381ec3785757
4
- data.tar.gz: 57873f037a5cc25f9649bf48550e79a4a1df9c1adbfe1212cbb00dc15c852725
3
+ metadata.gz: bdb5f95d47c9db88bf4a33313dc66f5064eca19a5005165e539a393fed984534
4
+ data.tar.gz: efc6015774feab34665ca9e6e35b2331675b88710c8805e840dacae1f4cf6fb7
5
5
  SHA512:
6
- metadata.gz: 8f9216030eecdf32a03b316725d9d1264d86d58aed32d45be1de9d20f17d3331aa85be1a4dd990991f8589e386cd0f85c554c912eac9c9166c60265c5f87fae8
7
- data.tar.gz: b290ff5c12a82a1033b697c23ddc6ffb70342186deee081ecf6fb9fbf233f8b1bca0029646b4df530c1c6189d76b69de848f4d4df56602f3f364e7d4ef94bb61
6
+ metadata.gz: e5d100882e8c8a963b0b568a3ca3ab287f2d2bd45f2c9152492d6d06357ffb493eb8db7caa8a705890fd0430bc78c1bc2b4fc5dd3a527291fe092ace741ef6bc
7
+ data.tar.gz: 8e7b0e98c4940fa509687463420f53f8d08bbabee615d65d928478b5b226df7f887a1fda82762afb2ea024eaeecdb7615622b9336b721877dd5d758aeb73fc23
@@ -1,9 +1,10 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
3
- <include href="biblio.rng"/>
4
- <start>
5
- <ref name="document"/>
6
- </start>
3
+ <include href="biblio.rng">
4
+ <start>
5
+ <ref name="document"/>
6
+ </start>
7
+ </include>
7
8
  <define name="document">
8
9
  <element name="document">
9
10
  <optional>
@@ -33,6 +33,9 @@
33
33
  <param name="pattern">([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?</param>
34
34
  </data>
35
35
  </define>
36
+ <start>
37
+ <ref name="relaton_collection"/>
38
+ </start>
36
39
  <define name="status">
37
40
  <element name="status">
38
41
  <ref name="stage"/>
@@ -150,6 +150,7 @@ module Asciidoctor
150
150
  File.open(filename, "w") { |f| f.write(ret) }
151
151
  html_converter(node).convert filename unless node.attr("nodoc")
152
152
  word_converter(node).convert filename unless node.attr("nodoc")
153
+ pdf_converter(node).convert filename unless node.attr("nodoc")
153
154
  end
154
155
  @files_to_delete.each { |f| FileUtils.rm f }
155
156
  ret
@@ -181,6 +182,10 @@ module Asciidoctor
181
182
  IsoDoc::Unece::WordConvert.new(doc_extract_attributes(node))
182
183
  end
183
184
 
185
+ def pdf_converter(node)
186
+ IsoDoc::Unece::PdfConvert.new(doc_extract_attributes(node))
187
+ end
188
+
184
189
  def sections_cleanup(xmldoc)
185
190
  super
186
191
  xmldoc.xpath("//clause/p | //annex/p").each do |p|
data/lib/isodoc/unece.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "isodoc/unece/metadata"
2
2
  require "isodoc/unece/html_convert"
3
3
  require "isodoc/unece/word_convert"
4
+ require "isodoc/unece/pdf_convert"
4
5
 
5
6
  module IsoDoc
6
7
  module Unece
@@ -0,0 +1,72 @@
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
+
@@ -591,10 +591,6 @@ div.WordSection2
591
591
  }
592
592
  div.WordSection3
593
593
  {page:WordSection3;}
594
- ol
595
- {margin-bottom:0cm;}
596
- ul
597
- {margin-bottom:0cm;}
598
594
  table.MsoISOTable
599
595
  {mso-style-name:"Table ISO";
600
596
  mso-tstyle-rowband-size:0;
@@ -616,8 +612,6 @@ table.MsoISOTable
616
612
  margin-bottom:12pt;
617
613
  font-size:10.0pt;
618
614
  font-family:$bodyfont;}
619
- table.MsoISOTable tr
620
- {page-break-inside:avoid;}
621
615
  table.MsoISOTable th
622
616
  {border:solid windowtext 1pt;
623
617
  mso-border-alt:solid windowtext 1pt;
@@ -645,20 +639,10 @@ table.MsoTableGrid
645
639
  margin-bottom:12pt;
646
640
  font-size:10.0pt;
647
641
  font-family:$bodyfont;}
648
- td { page-break-inside:avoid; }
649
- tr { page-break-after:avoid; }
650
- span.stem
651
- {font-family:"Cambria Math",serif;
652
- mso-ascii-font-family:"Cambria Math";
653
- font-style:
654
- italic;}
655
642
  div.formula
656
643
  {tab-stops:right 487.45pt;}
657
644
  body
658
645
  {tab-interval:36.0pt;}
659
- dt
660
- {page-break-inside:avoid;
661
- page-break-after:avoid}
662
646
  .coverpage_docnumber
663
647
  {text-align:center;
664
648
  font-size:14.0pt;
@@ -1058,106 +1058,44 @@ p.Tablebody, li.Tablebody, div.Tablebody
1058
1058
  mso-level-number-position:left;
1059
1059
  margin-left:162.0pt;
1060
1060
  text-indent:-18.0pt;}
1061
- p.ListContLevel1, li.ListContLevel1, div.ListContLevel1
1062
- {mso-style-priority:34;
1063
- margin-top:0cm;
1064
- margin-left:18.0pt;
1065
- margin-right:0cm;
1066
- margin-bottom:12.0pt;
1067
- mso-pagination:widow-orphan;
1068
- font-size:11.0pt;
1069
- font-family:$bodyfont;
1070
- mso-ansi-language:EN-AU;
1071
- mso-fareast-language:EN-US;}
1072
- p.ListContLevel2, li.ListContLevel2, div.ListContLevel2
1073
- {mso-style-priority:34;
1074
- margin-top:0cm;
1075
- margin-left:36.0pt;
1076
- margin-right:0cm;
1077
- margin-bottom:12.0pt;
1078
- mso-pagination:widow-orphan;
1079
- font-size:11.0pt;
1080
- font-family:$bodyfont;
1081
- mso-ansi-language:EN-AU;
1082
- mso-fareast-language:EN-US;}
1083
- p.ListContLevel3, li.ListContLevel3, div.ListContLevel3
1084
- {mso-style-priority:34;
1085
- margin-top:0cm;
1086
- margin-left:54.0pt;
1087
- margin-right:0cm;
1088
- margin-bottom:12.0pt;
1089
- mso-pagination:widow-orphan;
1090
- font-size:11.0pt;
1091
- font-family:$bodyfont;
1092
- mso-ansi-language:EN-AU;
1093
- mso-fareast-language:EN-US;}
1094
- p.ListContLevel4, li.ListContLevel4, div.ListContLevel4
1095
- {mso-style-priority:34;
1096
- margin-top:0cm;
1097
- margin-left:72.0pt;
1098
- margin-right:0cm;
1099
- margin-bottom:12.0pt;
1100
- mso-pagination:widow-orphan;
1101
- font-size:11.0pt;
1102
- font-family:$bodyfont;
1103
- mso-ansi-language:EN-AU;
1104
- mso-fareast-language:EN-US;}
1105
- p.ListContLevel5, li.ListContLevel5, div.ListContLevel5
1106
- {mso-style-priority:34;
1107
- margin-top:0cm;
1108
- margin-left:90.0pt;
1109
- margin-right:0cm;
1110
- margin-bottom:12.0pt;
1111
- mso-pagination:widow-orphan;
1112
- font-size:11.0pt;
1113
- font-family:$bodyfont;
1114
- mso-ansi-language:EN-AU;
1115
- mso-fareast-language:EN-US;}
1116
- p.ListContLevel6, li.ListContLevel6, div.ListContLevel6
1117
- {mso-style-priority:34;
1118
- margin-top:0cm;
1119
- margin-left:108.0pt;
1120
- margin-right:0cm;
1121
- margin-bottom:12.0pt;
1122
- mso-pagination:widow-orphan;
1123
- font-size:11.0pt;
1124
- font-family:$bodyfont;
1125
- mso-ansi-language:EN-AU;
1126
- mso-fareast-language:EN-US;}
1127
- p.ListContLevel7, li.ListContLevel7, div.ListContLevel7
1128
- {mso-style-priority:34;
1129
- margin-top:0cm;
1130
- margin-left:126.0pt;
1131
- margin-right:0cm;
1132
- margin-bottom:12.0pt;
1133
- mso-pagination:widow-orphan;
1134
- font-size:11.0pt;
1135
- font-family:$bodyfont;
1136
- mso-ansi-language:EN-AU;
1137
- mso-fareast-language:EN-US;}
1138
- p.ListContLevel8, li.ListContLevel8, div.ListContLevel8
1139
- {mso-style-priority:34;
1140
- margin-top:0cm;
1141
- margin-left:144.0pt;
1142
- margin-right:0cm;
1143
- margin-bottom:12.0pt;
1144
- mso-pagination:widow-orphan;
1145
- font-size:11.0pt;
1146
- font-family:$bodyfont;
1147
- mso-ansi-language:EN-AU;
1148
- mso-fareast-language:EN-US;}
1149
- p.ListContLevel9, li.ListContLevel9, div.ListContLevel9
1150
- {mso-style-priority:34;
1151
- margin-top:0cm;
1152
- margin-left:162.0pt;
1153
- margin-right:0cm;
1154
- margin-bottom:12.0pt;
1155
- mso-pagination:widow-orphan;
1156
- font-size:11.0pt;
1157
- font-family:$bodyfont;
1158
- mso-ansi-language:EN-AU;
1159
- mso-fareast-language:EN-US;}
1160
1061
 
1062
+ div.ListContLevel1
1063
+ {mso-style-priority:34;
1064
+ margin-left:18.0pt;
1065
+ margin-right:0cm;}
1066
+ div.ListContLevel2
1067
+ {mso-style-priority:34;
1068
+ margin-top:0cm;
1069
+ margin-left:36.0pt;
1070
+ margin-right:0cm;}
1071
+ div.ListContLevel3
1072
+ {mso-style-priority:34;
1073
+ margin-left:54.0pt;
1074
+ margin-right:0cm;}
1075
+ div.ListContLevel4
1076
+ {mso-style-priority:34;
1077
+ margin-left:72.0pt;
1078
+ margin-right:0cm;}
1079
+ div.ListContLevel5
1080
+ {mso-style-priority:34;
1081
+ margin-left:90.0pt;
1082
+ margin-right:0cm;}
1083
+ div.ListContLevel6
1084
+ {mso-style-priority:34;
1085
+ margin-left:108.0pt;
1086
+ margin-right:0cm;}
1087
+ div.ListContLevel7
1088
+ {mso-style-priority:34;
1089
+ margin-left:126.0pt;
1090
+ margin-right:0cm;}
1091
+ div.ListContLevel8
1092
+ {mso-style-priority:34;
1093
+ margin-left:144.0pt;
1094
+ margin-right:0cm;}
1095
+ div.ListContLevel9
1096
+ {mso-style-priority:34;
1097
+ margin-left:162.0pt;
1098
+ margin-right:0cm;}
1161
1099
 
1162
1100
  table.MsoNormalTable
1163
1101
  {mso-style-name:"Table Normal";
@@ -1172,12 +1110,6 @@ table.MsoNormalTable
1172
1110
  mso-pagination:widow-orphan;
1173
1111
  font-size:10.0pt;
1174
1112
  font-family:$bodyfont;}
1175
- br.section
1176
- {page-break-before:always;
1177
- mso-break-type:section-break;}
1178
- br.pagebreak
1179
- {page-break-before:always;
1180
- mso-special-character:line-break;}
1181
1113
  ol
1182
1114
  {margin-bottom:0cm;
1183
1115
  margin-left:18pt;}
@@ -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.jpg'), File.join(@localdir, "logo.jpg")
18
- @files_to_delete << File.join(@localdir, "logo.jpg")
19
- super
20
- end
16
+ #def convert1(docxml, filename, dir)
17
+ #FileUtils.cp html_doc_path('logo.jpg'), File.join(@localdir, "logo.jpg")
18
+ #@files_to_delete << File.join(@localdir, "logo.jpg")
19
+ #super
20
+ #end
21
21
 
22
22
  def default_fonts(options)
23
23
  {
@@ -8,6 +8,8 @@ module IsoDoc
8
8
  class Metadata < IsoDoc::Metadata
9
9
  def initialize(lang, script, labels)
10
10
  super
11
+ here = File.dirname(__FILE__)
12
+ set(:logo, File.expand_path(File.join(here, "html", "logo.jpg")))
11
13
  end
12
14
 
13
15
  def title(isoxml, _out)
@@ -0,0 +1,132 @@
1
+ require_relative "base_convert"
2
+ require "isodoc"
3
+
4
+ module IsoDoc
5
+ module Unece
6
+
7
+ # A {Converter} implementation that generates HTML output, and a document
8
+ # schema encapsulation of the document for validation
9
+ #
10
+ class PdfConvert < IsoDoc::PdfConvert
11
+ def initialize(options)
12
+ @libdir = File.dirname(__FILE__)
13
+ super
14
+ end
15
+
16
+ #def convert1(docxml, filename, dir)
17
+ #FileUtils.cp html_doc_path('logo.jpg'), File.join(@localdir, "logo.jpg")
18
+ #@files_to_delete << File.join(@localdir, "logo.jpg")
19
+ #super
20
+ #end
21
+
22
+ def default_fonts(options)
23
+ {
24
+ bodyfont: (
25
+ options[:script] == "Hans" ?
26
+ '"SimSun",serif' :
27
+ '"Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif'
28
+ ),
29
+ headerfont: (
30
+ options[:script] == "Hans" ?
31
+ '"SimHei",sans-serif' :
32
+ '"Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif'
33
+ ),
34
+ monospacefont: '"Space Mono",monospace'
35
+ }
36
+ end
37
+
38
+ def default_file_locations(_options)
39
+ {
40
+ htmlstylesheet: html_doc_path("htmlstyle.scss"),
41
+ htmlcoverpage: html_doc_path("html_unece_titlepage.html"),
42
+ htmlintropage: html_doc_path("html_unece_intro.html"),
43
+ scripts: html_doc_path("scripts.pdf.html"),
44
+ }
45
+ end
46
+
47
+
48
+ def googlefonts
49
+ <<~HEAD.freeze
50
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
51
+ <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,500,700,900" rel="stylesheet">
52
+ HEAD
53
+ end
54
+
55
+ def make_body(xml, docxml)
56
+ plenary = docxml.at(ns("//bibdata/ext[doctype = 'plenary']"))
57
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
58
+ if plenary && @htmlcoverpage == html_doc_path("html_unece_titlepage.html")
59
+ @htmlcoverpage = html_doc_path("html_unece_plenary_titlepage.html")
60
+ end
61
+ #@htmlintropage = nil if plenary
62
+ xml.body **body_attr do |body|
63
+ make_body1(body, docxml)
64
+ make_body2(body, docxml)
65
+ make_body3(body, docxml)
66
+ end
67
+ end
68
+
69
+ def make_body3(body, docxml)
70
+ body.div **{ class: "main-section" } do |div3|
71
+ abstract docxml, div3
72
+ foreword docxml, div3
73
+ introduction docxml, div3
74
+ middle docxml, div3
75
+ footnotes div3
76
+ comments div3
77
+ end
78
+ end
79
+
80
+ def html_preface(docxml)
81
+ super
82
+ docxml
83
+ end
84
+
85
+ def middle(isoxml, out)
86
+ clause isoxml, out
87
+ annex isoxml, out
88
+ bibliography isoxml, out
89
+ end
90
+
91
+ def clause_parse_title(node, div, c1, out)
92
+ if node["inline-header"] == "true"
93
+ inline_header_title(out, node, c1)
94
+ else
95
+ div.send "h#{anchor(node['id'], :level) || '1'}" do |h|
96
+ lbl = anchor(node['id'], :label, false)
97
+ h << "#{lbl}. " if lbl && !@suppressheadingnumbers
98
+ insert_tab(h, 1) if lbl && !@suppressheadingnumbers
99
+ c1&.children&.each { |c2| parse(c2, h) }
100
+ end
101
+ end
102
+ end
103
+
104
+ def introduction(isoxml, out)
105
+ f = isoxml.at(ns("//introduction")) || return
106
+ page_break(out)
107
+ out.div **{ class: "Section3", id: f["id"] } do |div|
108
+ div.h1(**{ class: "IntroTitle" }) do |h1|
109
+ h1 << @introduction_lbl
110
+ end
111
+ f.elements.each do |e|
112
+ parse(e, div) unless e.name == "title"
113
+ end
114
+ end
115
+ end
116
+
117
+ def foreword(isoxml, out)
118
+ f = isoxml.at(ns("//foreword")) || return
119
+ page_break(out)
120
+ out.div **attr_code(id: f["id"]) do |s|
121
+ s.h1(**{ class: "ForewordTitle" }) do |h1|
122
+ h1 << @foreword_lbl
123
+ end
124
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
125
+ end
126
+ end
127
+
128
+ include BaseConvert
129
+ end
130
+ end
131
+ end
132
+
@@ -13,10 +13,10 @@ 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
16
+ #def convert1(docxml, filename, dir)
17
+ #FileUtils.cp html_doc_path('logo.jpg'), File.join(@localdir, "logo.jpg")
18
+ #super
19
+ #end
20
20
 
21
21
  def default_fonts(options)
22
22
  {
@@ -14,6 +14,7 @@ module Metanorma
14
14
  super.merge(
15
15
  html: "html",
16
16
  doc: "doc",
17
+ pdf: "pdf",
17
18
  )
18
19
  end
19
20
 
@@ -31,6 +32,8 @@ module Metanorma
31
32
  IsoDoc::Unece::HtmlConvert.new(options).convert(outname, isodoc_node)
32
33
  when :doc
33
34
  IsoDoc::Unece::WordConvert.new(options).convert(outname, isodoc_node)
35
+ when :pdf
36
+ IsoDoc::Unece::PdfConvert.new(options).convert(outname, isodoc_node)
34
37
  else
35
38
  super
36
39
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Unece
3
- VERSION = "0.2.8"
3
+ VERSION = "0.2.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-unece
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.9
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-11-08 00:00:00.000000000 Z
11
+ date: 2019-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -303,6 +303,7 @@ files:
303
303
  - lib/isodoc/unece/html/htmlstyle.scss
304
304
  - lib/isodoc/unece/html/logo.jpg
305
305
  - lib/isodoc/unece/html/scripts.html
306
+ - lib/isodoc/unece/html/scripts.pdf.html
306
307
  - lib/isodoc/unece/html/unece.scss
307
308
  - lib/isodoc/unece/html/word_unece_intro.html
308
309
  - lib/isodoc/unece/html/word_unece_plenary_titlepage.html
@@ -310,6 +311,7 @@ files:
310
311
  - lib/isodoc/unece/html/wordstyle.scss
311
312
  - lib/isodoc/unece/html_convert.rb
312
313
  - lib/isodoc/unece/metadata.rb
314
+ - lib/isodoc/unece/pdf_convert.rb
313
315
  - lib/isodoc/unece/word_convert.rb
314
316
  - lib/metanorma-unece.rb
315
317
  - lib/metanorma/unece.rb