metanorma-itu 1.0.14 → 1.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,10 +13,18 @@ module IsoDoc
13
13
  super
14
14
  end
15
15
 
16
+ def pdf_stylesheet(docxml)
17
+ case doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
18
+ when "resolution" then "itu.resolution.xsl"
19
+ when "recommendation-annex" then "itu.recommendation-annex.xsl"
20
+ else
21
+ "itu.recommendation.xsl"
22
+ end
23
+ end
24
+
16
25
  def convert(filename, file = nil, debug = false)
17
26
  file = File.read(filename, encoding: "utf-8") if file.nil?
18
27
  docxml, outname_html, dir = convert_init(file, filename, debug)
19
- resolution = docxml.at(ns("//bibdata/ext[doctype = 'resolution']"))
20
28
  /\.xml$/.match(filename) or
21
29
  filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
22
30
  f.write file
@@ -24,8 +32,7 @@ module IsoDoc
24
32
  end
25
33
  FileUtils.rm_rf dir
26
34
  ::Metanorma::Output::XslfoPdf.new.convert(
27
- filename, outname_html + ".pdf",
28
- File.join(@libdir, resolution ? "itu.resolution.xsl" : "itu.recommendation.xsl"))
35
+ filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
29
36
  end
30
37
  end
31
38
  end
@@ -6,7 +6,7 @@ module IsoDoc
6
6
  module ITU
7
7
  module BaseConvert
8
8
  def norm_ref(isoxml, out, num)
9
- q = "//bibliography/references[title = 'References']"
9
+ q = "//bibliography/references[@normative = 'true']"
10
10
  f = isoxml.at(ns(q)) or return num
11
11
  out.div do |div|
12
12
  num = num + 1
@@ -15,9 +15,13 @@ module IsoDoc
15
15
  @anchors[clause["id"]] =
16
16
  { label: annex_name_lbl(clause, num), type: "clause",
17
17
  xref: "#{lbl} #{num}", level: 1 }
18
- clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).
19
- each_with_index do |c, i|
20
- annex_names1(c, "#{num}.#{i + 1}", 2)
18
+ if a = single_annex_special_section(clause)
19
+ annex_names1(a, "#{num}", 1)
20
+ else
21
+ clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).
22
+ each_with_index do |c, i|
23
+ annex_names1(c, "#{num}.#{i + 1}", 2)
24
+ end
21
25
  end
22
26
  hierarchical_asset_names(clause, num)
23
27
  end
@@ -52,8 +56,8 @@ module IsoDoc
52
56
  hierarchical_asset_names(d.xpath("//xmlns:preface/child::*"), "Preface") :
53
57
  sequential_asset_names(d.xpath("//xmlns:preface/child::*"))
54
58
  n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
55
- n = section_names(d.at(ns("//bibliography/clause[title = 'References'] | "\
56
- "//bibliography/references[title = 'References']")), n, 1)
59
+ n = section_names(d.at(ns("//bibliography/clause[.//references[@normative = 'true']] | "\
60
+ "//bibliography/references[@normative = 'true']")), n, 1)
57
61
  n = section_names(d.at(ns("//sections/terms | "\
58
62
  "//sections/clause[descendant::terms]")), n, 1)
59
63
  n = section_names(d.at(ns("//sections/definitions")), n, 1)
@@ -68,10 +72,10 @@ module IsoDoc
68
72
  end
69
73
 
70
74
  MIDDLE_SECTIONS = "//clause[title = 'Scope'] | "\
71
- "//foreword | //introduction | //acknowledgements | "\
72
- "//references[title = 'References' or title = 'references'] | "\
73
- "//sections/terms | //preface/clause | "\
74
- "//sections/definitions | //clause[parent::sections]".freeze
75
+ "//foreword | //introduction | //acknowledgements | "\
76
+ "//references[@normative = 'true'] | "\
77
+ "//sections/terms | //preface/clause | "\
78
+ "//sections/definitions | //clause[parent::sections]".freeze
75
79
 
76
80
  def middle_section_asset_names(d)
77
81
  return super unless @hierarchical_assets
@@ -116,7 +120,7 @@ module IsoDoc
116
120
  def sequential_formula_names(clause)
117
121
  clause&.first&.xpath(ns(MIDDLE_SECTIONS))&.each do |c|
118
122
  if c["id"] && @anchors[c["id"]]
119
- hierarchical_formula_names(c, @anchors[c["id"]][:label] || @anchors[c["id"]][:xref] || "???")
123
+ hierarchical_formula_names(c, @anchors[c["id"]][:label] || @anchors[c["id"]][:xref] || "???")
120
124
  else
121
125
  hierarchical_formula_names(c, "???")
122
126
  end
@@ -2,8 +2,8 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module ITU
5
- def self.pdf_fonts
6
- ["Arial", "Courier", "Times New Roman"]
5
+ def self.fonts_used
6
+ ["Arial", "Courier New", "Times New Roman"]
7
7
  end
8
8
 
9
9
  class Processor < Metanorma::Processor
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ITU
3
- VERSION = "1.0.14"
3
+ VERSION = "1.0.15"
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.14
4
+ version: 1.0.15
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-05-01 00:00:00.000000000 Z
11
+ date: 2020-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -275,6 +275,7 @@ 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-annex.xsl
278
279
  - lib/isodoc/itu/itu.recommendation.xsl
279
280
  - lib/isodoc/itu/itu.resolution.xsl
280
281
  - lib/isodoc/itu/metadata.rb