metanorma-itu 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,61 +6,27 @@ module IsoDoc
6
6
  module ITU
7
7
  # A {Converter} implementation that generates PDF HTML output, and a
8
8
  # document schema encapsulation of the document for validation
9
- class PdfConvert < IsoDoc::PdfConvert
9
+ class PdfConvert < IsoDoc::XslfoPdfConvert
10
10
  def initialize(options)
11
11
  @libdir = File.dirname(__FILE__)
12
12
  @hierarchical_assets = options[:hierarchical_assets]
13
13
  super
14
14
  end
15
15
 
16
- def html_toc(docxml)
17
- docxml
18
- end
19
-
20
- def default_fonts(options)
21
- {
22
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Open Sans",sans-serif'),
23
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Open Sans",sans-serif'),
24
- monospacefont: '"Space Mono",monospace'
25
- }
26
- end
27
-
28
- def default_file_locations(_options)
29
- {
30
- htmlstylesheet: html_doc_path("htmlstyle.scss"),
31
- htmlcoverpage: html_doc_path("html_itu_titlepage.html"),
32
- htmlintropage: html_doc_path("html_itu_intro.html"),
33
- scripts_pdf: html_doc_path("scripts.pdf.html"),
34
- }
35
- end
36
-
37
- def googlefonts()
38
- <<~HEAD.freeze
39
- <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,800|Space+Mono:400,700" rel="stylesheet">
40
- HEAD
41
- end
42
-
43
- def make_body(xml, docxml)
44
- body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72", "xml:lang": "EN-US", class: "container" }
45
- xml.body **body_attr do |body|
46
- make_body1(body, docxml)
47
- make_body2(body, docxml)
48
- make_body3(body, docxml)
49
- end
50
- end
51
-
52
- def make_body3(body, docxml)
53
- body.div **{ class: "main-section" } do |div3|
54
- boilerplate docxml, div3
55
- abstract docxml, div3
56
- preface docxml, div3
57
- middle docxml, div3
58
- footnotes div3
59
- comments div3
16
+ def convert(filename, file = nil, debug = false)
17
+ file = File.read(filename, encoding: "utf-8") if file.nil?
18
+ docxml, outname_html, dir = convert_init(file, filename, debug)
19
+ resolution = docxml.at(ns("//bibdata/ext[doctype = 'resolution']"))
20
+ /\.xml$/.match(filename) or
21
+ filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
22
+ f.write file
23
+ f.path
60
24
  end
25
+ FileUtils.rm_rf dir
26
+ ::Metanorma::Output::XslfoPdf.new.convert(
27
+ filename, outname_html + ".pdf",
28
+ File.join(@libdir, resolution ? "itu.resolution.xsl" : "itu.recommendation.xsl"))
61
29
  end
62
-
63
- include BaseConvert
64
30
  end
65
31
  end
66
32
  end
@@ -1,16 +1,15 @@
1
1
  module IsoDoc
2
2
  module ITU
3
3
  module BaseConvert
4
- def terms_defs_title(node)
5
- t = node.at(ns("./title")) and return t.text
6
- super
4
+ def term_def_title(node)
5
+ node
7
6
  end
8
7
 
9
8
  def terms_defs(node, out, num)
10
9
  f = node.at(ns(IsoDoc::Convert::TERM_CLAUSE)) or return num
11
10
  out.div **attr_code(id: f["id"]) do |div|
12
11
  num = num + 1
13
- clause_name(num, terms_defs_title(f), div, nil)
12
+ clause_name(num, term_def_title(f.at(ns("./title"))), div, nil)
14
13
  if f.at(ns("./clause | ./terms | ./term")).nil? then out.p "None."
15
14
  else
16
15
  f.children.reject { |c1| c1.name == "title" }.each do |c1|
@@ -117,7 +117,7 @@ module IsoDoc
117
117
  def formula_parse1(node, out)
118
118
  out.div **attr_code(id: node["id"], class: "formula") do |div|
119
119
  div.p **attr_code(class: "formula") do |p|
120
- insert_tab(div, 2)
120
+ insert_tab(div, 1)
121
121
  parse(node.at(ns("./stem")), div)
122
122
  lbl = anchor(node['id'], :label, false)
123
123
  unless lbl.nil?
@@ -89,7 +89,7 @@ module IsoDoc
89
89
  j = 0
90
90
  c.increment(t)
91
91
  end
92
- label = c.print + (j.zero? ? "" : "-#{(97 + j).chr.to_s}")
92
+ label = c.print + (j.zero? ? "" : "-#{(96 + j).chr.to_s}")
93
93
  next if t["id"].nil? || t["id"].empty?
94
94
  @anchors[t["id"]] =
95
95
  anchor_struct(label, nil, @figure_lbl, "figure", t["unnumbered"])
@@ -106,7 +106,7 @@ module IsoDoc
106
106
  c.increment(t)
107
107
  end
108
108
  label = "#{num}#{hiersep}#{c.print}" +
109
- (j.zero? ? "" : "#{hierfigsep}#{(97 + j).chr.to_s}")
109
+ (j.zero? ? "" : "#{hierfigsep}#{(96 + j).chr.to_s}")
110
110
  next if t["id"].nil? || t["id"].empty?
111
111
  @anchors[t["id"]] = anchor_struct(label, nil, @figure_lbl, "figure",
112
112
  t["unnumbered"])
@@ -2,6 +2,10 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module ITU
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 ITU
3
- VERSION = "1.0.13"
3
+ VERSION = "1.0.14"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-itu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.13
4
+ version: 1.0.14
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-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -275,6 +275,8 @@ files:
275
275
  - lib/isodoc/itu/html/wordstyle.scss
276
276
  - lib/isodoc/itu/html_convert.rb
277
277
  - lib/isodoc/itu/i18n-en.yaml
278
+ - lib/isodoc/itu/itu.recommendation.xsl
279
+ - lib/isodoc/itu/itu.resolution.xsl
278
280
  - lib/isodoc/itu/metadata.rb
279
281
  - lib/isodoc/itu/pdf_convert.rb
280
282
  - lib/isodoc/itu/ref.rb