metanorma-ogc 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,95 +1,32 @@
1
1
  require_relative "base_convert"
2
- require "fileutils"
3
2
  require "isodoc"
4
- require_relative "metadata"
5
3
 
6
4
  module IsoDoc
7
5
  module Ogc
8
6
  # A {Converter} implementation that generates PDF HTML output, and a
9
7
  # document schema encapsulation of the document for validation
10
- class PdfConvert < IsoDoc::PdfConvert
8
+ class PdfConvert < IsoDoc::XslfoPdfConvert
11
9
  def initialize(options)
12
10
  @libdir = File.dirname(__FILE__)
13
11
  super
14
- #FileUtils.cp html_doc_path('logo.jpg'), "logo.jpg"
15
- #@files_to_delete << "logo.jpg"
16
12
  end
17
13
 
18
- def default_fonts(options)
19
- {
20
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Overpass",sans-serif'),
21
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Overpass",sans-serif'),
22
- monospacefont: '"Space Mono",monospace'
23
- }
24
- end
25
-
26
- def default_file_locations(_options)
27
- {
28
- htmlstylesheet: html_doc_path("htmlstyle.scss"),
29
- htmlcoverpage: html_doc_path("html_ogc_titlepage.html"),
30
- htmlintropage: html_doc_path("html_ogc_intro.html"),
31
- scripts_pdf: html_doc_path("scripts.pdf.html"),
32
- }
33
- end
34
-
35
- def metadata_init(lang, script, labels)
36
- @meta = Metadata.new(lang, script, labels)
37
- end
38
-
39
- def googlefonts
40
- <<~HEAD.freeze
41
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700" rel="stylesheet" />
42
- <link href="https://fonts.googleapis.com/css?family=Overpass:300,300i,600,900" rel="stylesheet" />
43
- <link href="https://fonts.googleapis.com/css?family=Teko:300,400,500" rel="stylesheet">
44
- HEAD
45
- end
46
-
47
- def admonition_class(node)
48
- case node["type"]
49
- when "important" then "Admonition.Important"
50
- when "warning" then "Admonition.Warning"
51
- else
52
- "Admonition"
53
- end
54
- end
55
-
56
- def make_body(xml, docxml)
57
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
58
- xml.body **body_attr do |body|
59
- make_body1(body, docxml)
60
- make_body2(body, docxml)
61
- make_body3(body, docxml)
62
- end
63
- end
64
-
65
- def html_toc(docxml)
66
- docxml
67
- end
68
-
69
- def make_body3(body, docxml)
70
- body.div **{ class: "main-section" } do |div3|
71
- @prefacenum = 0
72
- boilerplate docxml, div3
73
- abstract docxml, div3
74
- keywords docxml, div3
75
- foreword docxml, div3
76
- introduction docxml, div3
77
- submittingorgs docxml, div3
78
- submitters docxml, div3
79
- preface docxml, div3
80
- acknowledgements docxml, div3
81
- middle docxml, div3
82
- footnotes div3
83
- comments div3
14
+ def convert(filename, file = nil, debug = false)
15
+ file = File.read(filename, encoding: "utf-8") if file.nil?
16
+ docxml, outname_html, dir = convert_init(file, filename, debug)
17
+ doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
18
+ doctype = "other" unless %w(community-standard engineering-report policy
19
+ reference-model release-notes standard user-guide test-suite).include? doctype
20
+ /\.xml$/.match(filename) or
21
+ filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
22
+ f.write file
23
+ f.path
84
24
  end
25
+ FileUtils.rm_rf dir
26
+ ::Metanorma::Output::XslfoPdf.new.convert(
27
+ filename, outname_html + ".pdf",
28
+ File.join(@libdir, "unece.#{doctype}.xsl"))
85
29
  end
86
-
87
- def authority_cleanup(docxml)
88
- authority_cleanup1(docxml, "contact")
89
- super
90
- end
91
-
92
- include BaseConvert
93
30
  end
94
31
  end
95
32
  end
@@ -2,6 +2,10 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module Ogc
5
+ def self.pdf_fonts
6
+ ["Arial", "Courier", "Times New Roman"]
7
+ end
8
+
5
9
  class Processor < Metanorma::Processor
6
10
 
7
11
  def initialize
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
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-03 00:00:00.000000000 Z
11
+ date: 2020-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -257,6 +257,15 @@ files:
257
257
  - lib/isodoc/ogc/html_convert.rb
258
258
  - lib/isodoc/ogc/i18n-en.yaml
259
259
  - lib/isodoc/ogc/metadata.rb
260
+ - lib/isodoc/ogc/ogc.community-standard.xsl
261
+ - lib/isodoc/ogc/ogc.engineering-report.xsl
262
+ - lib/isodoc/ogc/ogc.other.xsl
263
+ - lib/isodoc/ogc/ogc.policy.xsl
264
+ - lib/isodoc/ogc/ogc.reference-model.xsl
265
+ - lib/isodoc/ogc/ogc.release-notes.xsl
266
+ - lib/isodoc/ogc/ogc.standard.xsl
267
+ - lib/isodoc/ogc/ogc.test-suite.xsl
268
+ - lib/isodoc/ogc/ogc.user-guide.xsl
260
269
  - lib/isodoc/ogc/pdf_convert.rb
261
270
  - lib/isodoc/ogc/reqt.rb
262
271
  - lib/isodoc/ogc/sections.rb