metanorma-csand 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,108 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+
4
+ module IsoDoc
5
+ module Csand
6
+ # A {Converter} implementation that generates CSAND 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' : '"Source Sans Pro",sans-serif'),
17
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Source Sans Pro",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_csand_titlepage.html"),
26
+ htmlintropage: html_doc_path("html_csand_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.br
39
+ t.b do |b|
40
+ name&.children&.each { |c2| parse(c2, b) }
41
+ end
42
+ end
43
+ end
44
+
45
+ def term_defs_boilerplate(div, source, term, preface)
46
+ if source.empty? && term.nil?
47
+ div << @no_terms_boilerplate
48
+ else
49
+ div << term_defs_boilerplate_cont(source, term)
50
+ end
51
+ end
52
+
53
+ def i18n_init(lang, script)
54
+ super
55
+ @annex_lbl = "Appendix"
56
+ end
57
+
58
+ def html_head()
59
+ <<~HEAD.freeze
60
+ <title>{{ doctitle }}</title>
61
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
62
+
63
+ <!--TOC script import-->
64
+ <script type="text/javascript" src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js"></script>
65
+
66
+ <!--Google fonts-->
67
+ <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet">
68
+ <link href="https://fonts.googleapis.com/css?family=Rubik:300,300i,500" rel="stylesheet">
69
+ <link href="https://fonts.googleapis.com/css?family=Overpass:100,300,300i,600,900" rel="stylesheet">
70
+
71
+ <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,700,900" rel="stylesheet">
72
+ <!--Font awesome import for the link icon-->
73
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous">
74
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous">
75
+ <style class="anchorjs"></style>
76
+ HEAD
77
+ end
78
+
79
+ def make_body(xml, docxml)
80
+ body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
81
+ xml.body **body_attr do |body|
82
+ make_body1(body, docxml)
83
+ make_body2(body, docxml)
84
+ make_body3(body, docxml)
85
+ end
86
+ end
87
+
88
+ def html_toc(docxml)
89
+ docxml
90
+ end
91
+
92
+ def cleanup(docxml)
93
+ super
94
+ term_cleanup(docxml)
95
+ end
96
+
97
+ def term_cleanup(docxml)
98
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
99
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
100
+ h2.add_child("&nbsp;")
101
+ h2.add_child(d.remove)
102
+ end
103
+ docxml
104
+ end
105
+ end
106
+ end
107
+ end
108
+
@@ -0,0 +1,77 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+
4
+ module IsoDoc
5
+ module Csand
6
+ # A {Converter} implementation that generates CSAND output, and a document
7
+ # schema encapsulation of the document for validation
8
+ class WordConvert < IsoDoc::WordConvert
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' : '"Arial",sans-serif'),
17
+ headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Arial",sans-serif'),
18
+ monospacefont: '"Courier New",monospace'
19
+ }
20
+ end
21
+
22
+ def default_file_locations(options)
23
+ {
24
+ wordstylesheet: html_doc_path("wordstyle.scss"),
25
+ standardstylesheet: html_doc_path("csand.scss"),
26
+ header: html_doc_path("header.html"),
27
+ wordcoverpage: html_doc_path("word_csand_titlepage.html"),
28
+ wordintropage: html_doc_path("word_csand_intro.html"),
29
+ ulstyle: "l3",
30
+ olstyle: "l2",
31
+ }
32
+ end
33
+
34
+ def metadata_init(lang, script, labels)
35
+ @meta = Metadata.new(lang, script, labels)
36
+ end
37
+
38
+ def annex_name(annex, name, div)
39
+ div.h1 **{ class: "Annex" } do |t|
40
+ t << "#{get_anchors[annex['id']][:label]} "
41
+ t.br
42
+ t.b do |b|
43
+ name&.children&.each { |c2| parse(c2, b) }
44
+ end
45
+ end
46
+ end
47
+
48
+ def term_defs_boilerplate(div, source, term, preface)
49
+ if source.empty? && term.nil?
50
+ div << @no_terms_boilerplate
51
+ else
52
+ div << term_defs_boilerplate_cont(source, term)
53
+ end
54
+ end
55
+
56
+ def i18n_init(lang, script)
57
+ super
58
+ @annex_lbl = "Appendix"
59
+ end
60
+
61
+ def cleanup(docxml)
62
+ super
63
+ term_cleanup(docxml)
64
+ end
65
+
66
+ def term_cleanup(docxml)
67
+ docxml.xpath("//p[@class = 'Terms']").each do |d|
68
+ h2 = d.at("./preceding-sibling::*[@class = 'TermNum'][1]")
69
+ h2.add_child("&nbsp;")
70
+ h2.add_child(d.remove)
71
+ end
72
+ docxml
73
+ end
74
+ end
75
+ end
76
+ end
77
+
@@ -13,8 +13,8 @@ module Metanorma
13
13
  def output_formats
14
14
  super.merge(
15
15
  html: "html",
16
- # doc: "doc",
17
- # pdf: "pdf"
16
+ doc: "doc",
17
+ pdf: "pdf"
18
18
  )
19
19
  end
20
20
 
@@ -30,10 +30,10 @@ module Metanorma
30
30
  case format
31
31
  when :html
32
32
  IsoDoc::Csand::HtmlConvert.new(options).convert(outname, isodoc_node)
33
- # when :doc
34
- # IsoDoc::Csand::WordConvert.new(options).convert(outname, isodoc_node)
35
- # when :pdf
36
- # IsoDoc::Csand::PdfConvert.new(options).convert(outname, isodoc_node)
33
+ when :doc
34
+ IsoDoc::Csand::WordConvert.new(options).convert(outname, isodoc_node)
35
+ when :pdf
36
+ IsoDoc::Csand::PdfConvert.new(options).convert(outname, isodoc_node)
37
37
  else
38
38
  super
39
39
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Csand
3
- VERSION = "1.1.0"
3
+ VERSION = "1.1.1"
4
4
  end
5
5
  end
@@ -1,6 +1,8 @@
1
1
  require "asciidoctor" unless defined? Asciidoctor::Converter
2
2
  require_relative "asciidoctor/csand/converter"
3
3
  require_relative "isodoc/csand/html_convert"
4
+ require_relative "isodoc/csand/pdf_convert"
5
+ require_relative "isodoc/csand/word_convert"
4
6
  require_relative "metanorma/csand/version"
5
7
 
6
8
  if defined? Metanorma
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-csand
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.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: 2019-01-21 00:00:00.000000000 Z
11
+ date: 2019-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -365,14 +365,22 @@ files:
365
365
  - lib/asciidoctor/csand/isostandard.rng
366
366
  - lib/isodoc/csand/html/csa-logo-white.png
367
367
  - lib/isodoc/csand/html/csa.png
368
+ - lib/isodoc/csand/html/csand.scss
368
369
  - lib/isodoc/csand/html/dots-w@2x.png
369
370
  - lib/isodoc/csand/html/dots@2x.png
371
+ - lib/isodoc/csand/html/header.html
370
372
  - lib/isodoc/csand/html/html_csand_intro.html
371
373
  - lib/isodoc/csand/html/html_csand_titlepage.html
372
374
  - lib/isodoc/csand/html/htmlstyle.scss
373
375
  - lib/isodoc/csand/html/scripts.html
376
+ - lib/isodoc/csand/html/scripts.pdf.html
377
+ - lib/isodoc/csand/html/word_csand_intro.html
378
+ - lib/isodoc/csand/html/word_csand_titlepage.html
379
+ - lib/isodoc/csand/html/wordstyle.scss
374
380
  - lib/isodoc/csand/html_convert.rb
375
381
  - lib/isodoc/csand/metadata.rb
382
+ - lib/isodoc/csand/pdf_convert.rb
383
+ - lib/isodoc/csand/word_convert.rb
376
384
  - lib/metanorma-csand.rb
377
385
  - lib/metanorma/csand.rb
378
386
  - lib/metanorma/csand/processor.rb