metanorma-csd 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7627c2e066294a10125980df6ac9f96f7c2ebf368c77317e43036de59abb617d
4
- data.tar.gz: 1da0618c9fca2472453f0210ad5645e825c3fb7d6d0fe28d6fb6f544892540bf
3
+ metadata.gz: 98bb923f1fa0d6386171746c6c1f6256026408aad33555851703591774886c6e
4
+ data.tar.gz: ffe452187fcda8f1b0a6902aa6c62c3aa370808803fc7f1184761189d8d9c40b
5
5
  SHA512:
6
- metadata.gz: 4e5c0e16d39f15587886c38f0b15504782135f66d2d3009e338df68496bd7fd159ab24e5cd0f3e798790aafcae4572a74f10159375998d45f52f910029726a3a
7
- data.tar.gz: 8a3bedd76c6ec9c44ab4539ccb28e2e05e38442b453815f6621a80465b9b2964ab2b02424ec496f69698d1aedf6a719ed8a12063ebc38ee0ae11d3d5c53def9b
6
+ metadata.gz: c9f378917cd2b3a1623944501c908f7b76d4675c4e690cba3132c4516211040a1f4a23ac009d4bc69fa5499ebd0ce5d424486a7e3a96b532515de348be10d128
7
+ data.tar.gz: 5589a1b8c394532d1030cfaf4134ece3857148e391c23ab4feaadf16ed634ad712d5aa9d7cbf3d6c005c4bf95f44c1651a50254d4dc0dbb6cecc4527926a277a
@@ -97,13 +97,6 @@ module Asciidoctor
97
97
  d
98
98
  end
99
99
 
100
- def pdf_convert(filename)
101
- url = "#{Dir.pwd}/#{filename}.html"
102
- pdfjs = File.join(File.dirname(__FILE__), 'pdf.js')
103
- system "export NODE_PATH=$(npm root --quiet -g);
104
- node #{pdfjs} file://#{url} #{filename}.pdf"
105
- end
106
-
107
100
  def document(node)
108
101
  init(node)
109
102
  ret1 = makexml(node)
@@ -114,7 +107,7 @@ module Asciidoctor
114
107
  File.open(filename, "w") { |f| f.write(ret) }
115
108
  html_converter(node).convert filename
116
109
  word_converter(node).convert filename
117
- pdf_convert(filename.sub(/\.xml$/, ""))
110
+ pdf_converter(node).convert filename
118
111
  end
119
112
  @files_to_delete.each { |f| system "rm #{f}" }
120
113
  ret
@@ -150,6 +143,10 @@ module Asciidoctor
150
143
  IsoDoc::Csd::HtmlConvert.new(html_extract_attributes(node))
151
144
  end
152
145
 
146
+ def pdf_converter(node)
147
+ IsoDoc::Csd::PdfConvert.new(html_extract_attributes(node))
148
+ end
149
+
153
150
  def word_converter(node)
154
151
  IsoDoc::Csd::WordConvert.new(doc_extract_attributes(node))
155
152
  end
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Csd
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
@@ -59,10 +59,10 @@ time, mark, audio, video {
59
59
 
60
60
 
61
61
  html, body, div, span, applet, object, iframe,
62
- p, blockquote, pre,
63
- a, abbr, acronym, address, big, cite, code,
64
- del, dfn, em, img, ins, kbd, q, s, samp,
65
- small, strike, strong, sub, sup, tt, var,
62
+ p, blockquote,
63
+ a, abbr, acronym, address, big, cite,
64
+ del, dfn, em, img, ins, q, s,
65
+ small, strike, strong, sub, sup, var,
66
66
  b, u, i, center,
67
67
  dl, dt, dd, ol, ul, li,
68
68
  fieldset, form, label, legend,
@@ -74,6 +74,10 @@ time, mark, audio, video {
74
74
  font-family: $bodyfont;
75
75
  }
76
76
 
77
+ code, pre, tt, kbd, samp {
78
+ font-family: $monospacefont;
79
+ }
80
+
77
81
  h1, h2, h3, h4, h5, h6, .h2Annex {
78
82
  font-family: $headerfont;
79
83
  }
@@ -146,7 +150,7 @@ table {
146
150
  */
147
151
 
148
152
 
149
- @media (min-width: 768px) {
153
+ @media screen and (min-width: 768px) {
150
154
  nav {
151
155
  position: fixed;
152
156
  top: 0;
@@ -198,7 +202,7 @@ table {
198
202
  }
199
203
  }
200
204
 
201
- @media (max-width: 768px) {
205
+ @media screen and (max-width: 768px) {
202
206
  #toc {
203
207
  padding: 0 1.5em 0 1.5em;
204
208
  overflow: visible;
@@ -0,0 +1,70 @@
1
+ <script>
2
+ //TOC generation
3
+ $('#toc').toc({
4
+ 'selectors': 'h1,h2:not(.TermNum)', //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
+ $(document).ready(function() {
62
+ $('[id^=toc]').each(function ()
63
+ {
64
+ var currentToc = $(this);
65
+ var url = window.location.href;
66
+ currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' </a>");
67
+ });
68
+ });
69
+ </script>
70
+
@@ -11,7 +11,7 @@ module IsoDoc
11
11
  end
12
12
 
13
13
  def title(isoxml, _out)
14
- main = isoxml&.at(ns("//title[@language='en']"))&.text
14
+ main = isoxml&.at(ns("//bibdata/title[@language='en']"))&.text
15
15
  set(:doctitle, main)
16
16
  end
17
17
 
@@ -21,7 +21,7 @@ module IsoDoc
21
21
 
22
22
  def author(isoxml, _out)
23
23
  set(:tc, "XXXX")
24
- tc = isoxml.at(ns("//editorialgroup/technical-committee"))
24
+ tc = isoxml.at(ns("//bibdata/editorialgroup/technical-committee"))
25
25
  set(:tc, tc.text) if tc
26
26
  end
27
27
 
@@ -0,0 +1,124 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+
4
+ module IsoDoc
5
+ module Csd
6
+ # A {Converter} implementation that generates CSD output, and a document
7
+ # schema encapsulation of the document for validation
8
+ class PdfConvert < IsoDoc::PdfConvert
9
+ def initialize(options)
10
+ @libdir = File.dirname(__FILE__)
11
+ super
12
+ end
13
+
14
+ def default_fonts(options)
15
+ {
16
+ bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
17
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
18
+ monospacefont: '"Space Mono",monospace'
19
+ }
20
+ end
21
+
22
+ def default_file_locations(options)
23
+ {
24
+ htmlstylesheet: html_doc_path("htmlstyle.scss"),
25
+ htmlcoverpage: html_doc_path("html_csd_titlepage.html"),
26
+ htmlintropage: html_doc_path("html_csd_intro.html"),
27
+ scripts_pdf: html_doc_path("scripts.pdf.html"),
28
+ }
29
+ end
30
+
31
+ def metadata_init(lang, script, labels)
32
+ @meta = Metadata.new(lang, script, labels)
33
+ end
34
+
35
+ def annex_name(annex, name, div)
36
+ div.h1 **{ class: "Annex" } do |t|
37
+ t << "#{get_anchors[annex['id']][:label]} "
38
+ t << "<b>#{name.text}</b>"
39
+ end
40
+ end
41
+
42
+ def annex_name_lbl(clause, num)
43
+ obl = l10n("(#{@inform_annex_lbl})")
44
+ obl = l10n("(#{@norm_annex_lbl})") if clause["obligation"] == "normative"
45
+ l10n("<b>#{@annex_lbl} #{num}</b> #{obl}")
46
+ end
47
+
48
+ def pre_parse(node, out)
49
+ out.pre node.text # content.gsub(/</, "&lt;").gsub(/>/, "&gt;")
50
+ end
51
+
52
+ def term_defs_boilerplate(div, source, term, preface)
53
+ if source.empty? && term.nil?
54
+ div << @no_terms_boilerplate
55
+ else
56
+ div << term_defs_boilerplate_cont(source, term)
57
+ end
58
+ end
59
+
60
+ def i18n_init(lang, script)
61
+ super
62
+ @annex_lbl = "Appendix"
63
+ end
64
+
65
+ def error_parse(node, out)
66
+ # catch elements not defined in ISO
67
+ case node.name
68
+ when "pre"
69
+ pre_parse(node, out)
70
+ when "keyword"
71
+ out.span node.text, **{ class: "keyword" }
72
+ else
73
+ super
74
+ end
75
+ end
76
+
77
+ def html_head()
78
+ <<~HEAD.freeze
79
+ <title>{{ doctitle }}</title>
80
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
81
+
82
+ <!--TOC script import-->
83
+ <script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
84
+
85
+ <!--Google fonts-->
86
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
87
+ <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet">
88
+ <!--Font awesome import for the link icon-->
89
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
90
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
91
+ <style class="anchorjs"></style>
92
+ HEAD
93
+ end
94
+
95
+ def make_body(xml, docxml)
96
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
97
+ xml.body **body_attr do |body|
98
+ make_body1(body, docxml)
99
+ make_body2(body, docxml)
100
+ make_body3(body, docxml)
101
+ end
102
+ end
103
+
104
+ def html_toc(docxml)
105
+ docxml
106
+ end
107
+
108
+ def cleanup(docxml)
109
+ super
110
+ term_cleanup(docxml)
111
+ end
112
+
113
+ def term_cleanup(docxml)
114
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
115
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
116
+ h2.add_child("&nbsp;")
117
+ h2.add_child(d.remove)
118
+ end
119
+ docxml
120
+ end
121
+ end
122
+ end
123
+ end
124
+
data/lib/metanorma-csd.rb CHANGED
@@ -2,6 +2,7 @@ require "asciidoctor" unless defined? Asciidoctor::Converter
2
2
  require_relative "asciidoctor/csd/converter"
3
3
  require_relative "isodoc/csd/html_convert"
4
4
  require_relative "isodoc/csd/word_convert"
5
+ require_relative "isodoc/csd/pdf_convert"
5
6
  require_relative "asciidoctor/csd/version"
6
7
 
7
8
  if defined? Metanorma
@@ -33,13 +33,7 @@ module Metanorma
33
33
  when :doc
34
34
  IsoDoc::Csd::WordConvert.new(options).convert(outname, isodoc_node)
35
35
  when :pdf
36
- #require 'tempfile'
37
- # Tempfile.open("#{outname}.html") do |tmp|
38
- outname_html = outname + ".html"
39
- IsoDoc::Csd::HtmlConvert.new(options).convert(outname_html, isodoc_node)
40
- puts outname_html
41
- #system "cat #{outname_html}"
42
- Metanorma::Output::Pdf.new.convert(outname_html, outname)
36
+ IsoDoc::Csd::PdfConvert.new(options).convert(outname, isodoc_node)
43
37
  else
44
38
  super
45
39
  end
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_dependency "metanorma-standoc", "~> 1.0.0"
31
- spec.add_dependency "isodoc", "~> 0.8.8"
31
+ spec.add_dependency "isodoc", "~> 0.9.0"
32
32
 
33
33
  spec.add_development_dependency "bundler", "~> 1.15"
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-csd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-01 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-standoc
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.8
33
+ version: 0.9.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.8.8
40
+ version: 0.9.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -232,11 +232,13 @@ files:
232
232
  - lib/isodoc/csd/html/html_csd_titlepage.html
233
233
  - lib/isodoc/csd/html/htmlstyle.scss
234
234
  - lib/isodoc/csd/html/scripts.html
235
+ - lib/isodoc/csd/html/scripts.pdf.html
235
236
  - lib/isodoc/csd/html/word_csd_intro.html
236
237
  - lib/isodoc/csd/html/word_csd_titlepage.html
237
238
  - lib/isodoc/csd/html/wordstyle.scss
238
239
  - lib/isodoc/csd/html_convert.rb
239
240
  - lib/isodoc/csd/metadata.rb
241
+ - lib/isodoc/csd/pdf_convert.rb
240
242
  - lib/isodoc/csd/word_convert.rb
241
243
  - lib/metanorma-csd.rb
242
244
  - lib/metanorma/csd.rb