metanorma-ogc 1.0.9 → 1.1.0

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.
@@ -19,19 +19,6 @@ module IsoDoc
19
19
  standard user-guide test-suite white-paper).include? doctype
20
20
  "ogc.#{doctype}.xsl"
21
21
  end
22
-
23
- def convert(filename, file = nil, debug = false)
24
- file = File.read(filename, encoding: "utf-8") if file.nil?
25
- docxml, outname_html, dir = convert_init(file, filename, debug)
26
- /\.xml$/.match(filename) or
27
- filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
28
- f.write file
29
- f.path
30
- end
31
- FileUtils.rm_rf dir
32
- ::Metanorma::Output::XslfoPdf.new.convert(
33
- filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
34
- end
35
22
  end
36
23
  end
37
24
  end
@@ -0,0 +1,10 @@
1
+ require_relative "base_convert"
2
+ require "isodoc"
3
+
4
+ module IsoDoc
5
+ module Ogc
6
+ class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
7
+ end
8
+ end
9
+ end
10
+
@@ -1,5 +1,4 @@
1
1
  require "isodoc"
2
- require_relative "reqt_xref"
3
2
 
4
3
  module IsoDoc
5
4
  module Ogc
@@ -30,7 +29,7 @@ module IsoDoc
30
29
  label, title, lbl = recommendation_labels(node)
31
30
  out.p **{ class: recommendation_class(node) } do |b|
32
31
  if inject_crossreference_reqt?(node, label)
33
- lbl = anchor(@reqtlabels[label.text], :xref, false)
32
+ lbl = @xrefs.anchor(@xrefs.reqtlabels[label.text], :xref, false)
34
33
  b << (lbl.nil? ? l10n("#{type}:") : l10n("#{lbl}:"))
35
34
  else
36
35
  b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
@@ -59,7 +58,7 @@ module IsoDoc
59
58
  # embedded reqts xref to top level reqts via label lookup
60
59
  def inject_crossreference_reqt?(node, label)
61
60
  !node.ancestors("requirement, recommendation, permission").empty? &&
62
- @reqtlabels[label&.text]
61
+ @xrefs.reqtlabels[label&.text]
63
62
  end
64
63
 
65
64
  def recommendation_attributes1(node)
@@ -3,7 +3,7 @@ module IsoDoc
3
3
  module BaseConvert
4
4
  def annex_name(annex, name, div)
5
5
  div.h1 **{ class: "Annex" } do |t|
6
- t << "#{anchor(annex['id'], :label)} "
6
+ t << "#{@xrefs.anchor(annex['id'], :label)} "
7
7
  t.br
8
8
  t.b do |b|
9
9
  name&.children&.each { |c2| parse(c2, b) }
@@ -24,12 +24,13 @@ module IsoDoc
24
24
  end
25
25
  end
26
26
 
27
- SUBMITTINGORGS =
28
- "//bibdata/contributor[role/@type = 'author']/organization/name".freeze
27
+ def submittingorgs_path
28
+ "//bibdata/contributor[role/@type = 'author']/organization/name"
29
+ end
29
30
 
30
31
  def submittingorgs(docxml, out)
31
32
  orgs = []
32
- docxml.xpath(ns(SUBMITTINGORGS)).each { |org| orgs << org.text }
33
+ docxml.xpath(ns(submittingorgs_path)).each { |org| orgs << org.text }
33
34
  return if orgs.empty?
34
35
  @prefacenum += 1
35
36
  out.div **{ class: "Section3" } do |div|
@@ -47,7 +48,7 @@ module IsoDoc
47
48
  f = docxml.at(ns("//submitters")) || return
48
49
  @prefacenum += 1
49
50
  out.div **{ class: "Section3" } do |div|
50
- clause_name(anchor(f['id'], :label), "Submitters", div,
51
+ clause_name(@xrefs.anchor(f['id'], :label), "Submitters", div,
51
52
  class: "IntroTitle")
52
53
  f.elements.each { |e| parse(e, div) unless e.name == "title" }
53
54
  end
@@ -70,7 +71,7 @@ module IsoDoc
70
71
  @prefacenum += 1
71
72
  page_break(out)
72
73
  out.div **attr_code(id: f["id"]) do |s|
73
- clause_name(anchor(f["id"], :label), @abstract_lbl, s,
74
+ clause_name(@xrefs.anchor(f["id"], :label), @abstract_lbl, s,
74
75
  class: "AbstractTitle")
75
76
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
76
77
  end
@@ -81,7 +82,7 @@ module IsoDoc
81
82
  @prefacenum += 1
82
83
  page_break(out)
83
84
  out.div **attr_code(id: f["id"]) do |s|
84
- clause_name(anchor(f["id"], :label), @foreword_lbl, s,
85
+ clause_name(@xrefs.anchor(f["id"], :label), @foreword_lbl, s,
85
86
  class: "ForewordTitle")
86
87
  f.elements.each { |e| parse(e, s) unless e.name == "title" }
87
88
  end
@@ -91,7 +92,7 @@ module IsoDoc
91
92
  f = isoxml.at(ns("//acknowledgements")) || return
92
93
  @prefacenum += 1
93
94
  out.div **{ class: "Section3", id: f["id"] } do |div|
94
- clause_name(anchor(f["id"], :label), f&.at(ns("./title")), div,
95
+ clause_name(@xrefs.anchor(f["id"], :label), f&.at(ns("./title")), div,
95
96
  class: "IntroTitle")
96
97
  f.elements.each { |e| parse(e, div) unless e.name == "title" }
97
98
  end
@@ -11,7 +11,6 @@ module IsoDoc
11
11
  class WordConvert < IsoDoc::WordConvert
12
12
  def initialize(options)
13
13
  @libdir = File.dirname(__FILE__)
14
- @reqtlabels = {}
15
14
  super
16
15
  end
17
16
 
@@ -37,10 +36,6 @@ module IsoDoc
37
36
  }
38
37
  end
39
38
 
40
- def metadata_init(lang, script, labels)
41
- @meta = Metadata.new(lang, script, labels)
42
- end
43
-
44
39
  def make_body(xml, docxml)
45
40
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
46
41
  xml.body **body_attr do |body|
@@ -1,10 +1,19 @@
1
1
  module IsoDoc
2
2
  module Ogc
3
- module BaseConvert
4
- FIRST_LVL_REQ = IsoDoc::Function::XrefGen::FIRST_LVL_REQ
3
+ class Xref < IsoDoc::Xref
4
+ def initialize(lang, script, klass, labels, options)
5
+ @reqtlabels = {}
6
+ super
7
+ end
8
+
9
+ def reqtlabels
10
+ @reqtlabels
11
+ end
12
+
13
+ FIRST_LVL_REQ = IsoDoc::XrefGen::Blocks::FIRST_LVL_REQ
5
14
 
6
15
  def sequential_permission_names(clause, klass, label)
7
- c = ::IsoDoc::Function::XrefGen::Counter.new
16
+ c = ::IsoDoc::XrefGen::Counter.new
8
17
  clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
9
18
  next if t["id"].nil? || t["id"].empty?
10
19
  id = c.increment(t).print
@@ -40,7 +49,7 @@ module IsoDoc
40
49
  end
41
50
 
42
51
  def sequential_permission_names1(block, lbl, klass, label)
43
- c = ::IsoDoc::Function::XrefGen::Counter.new
52
+ c = ::IsoDoc::XrefGen::Counter.new
44
53
  block.xpath(ns("./#{klass}")).each do |t|
45
54
  next if t["id"].nil? || t["id"].empty?
46
55
  id = "#{lbl}#{hierfigsep}#{c.increment(t).print}"
@@ -82,7 +91,7 @@ module IsoDoc
82
91
  end
83
92
 
84
93
  def hierarchical_permission_names(clause, num, klass, label)
85
- c = ::IsoDoc::Function::XrefGen::Counter.new
94
+ c = ::IsoDoc::XrefGen::Counter.new
86
95
  clause.xpath(ns(".//#{klass}#{FIRST_LVL_REQ}")).each do |t|
87
96
  next if t["id"].nil? || t["id"].empty?
88
97
  lbl = "#{num}#{hiersep}#{c.increment(t).print}"
@@ -91,6 +100,59 @@ module IsoDoc
91
100
  sequential_permission_children(t, lbl)
92
101
  end
93
102
  end
103
+
104
+ def initial_anchor_names(d)
105
+ @prefacenum = 0
106
+ preface_names_numbered(d.at(ns("//preface/abstract")))
107
+ @prefacenum += 1 if d.at(ns("//keyword"))
108
+ preface_names_numbered(d.at(ns("//foreword")))
109
+ preface_names_numbered(d.at(ns("//introduction")))
110
+ @prefacenum += 1 if d.at(ns(@klass.submittingorgs_path))
111
+ preface_names_numbered(d.at(ns("//submitters")))
112
+ d.xpath(ns("//preface/clause")).each do |c|
113
+ preface_names_numbered(c)
114
+ end
115
+ preface_names_numbered(d.at(ns("//acknowledgements")))
116
+ sequential_asset_names(d.xpath(ns(
117
+ "//preface/abstract | //foreword | //introduction | "\
118
+ "//submitters | //acknowledgements | //preface/clause")))
119
+ n = section_names(d.at(ns("//clause[title = 'Scope']")), 0, 1)
120
+ n = section_names(d.at(ns("//clause[title = 'Conformance']")), n, 1)
121
+ n = section_names(d.at(ns(
122
+ "//references[title = 'Normative References' or "\
123
+ "title = 'Normative references']")), n, 1)
124
+ n = section_names(
125
+ d.at(ns("//sections/terms | //sections/clause[descendant::terms]")),
126
+ n, 1)
127
+ n = section_names(d.at(ns("//sections/definitions")), n, 1)
128
+ middle_section_asset_names(d)
129
+ clause_names(d, n)
130
+ termnote_anchor_names(d)
131
+ termexample_anchor_names(d)
132
+ end
133
+
134
+ def middle_section_asset_names(d)
135
+ middle_sections = "//clause[title = 'Scope' or title = 'Conformance'] "\
136
+ "| //foreword | //introduction | //preface/abstract | "\
137
+ "//submitters | //acknowledgements | //preface/clause | "\
138
+ "//references[title = 'Normative References' or title = "\
139
+ "'Normative references'] | //sections/terms | "\
140
+ "//sections/definitions | //clause[parent::sections]"
141
+ sequential_asset_names(d.xpath(ns(middle_sections)))
142
+ end
143
+
144
+ def preface_names_numbered(clause)
145
+ return if clause.nil?
146
+ @prefacenum += 1
147
+ pref = RomanNumerals.to_roman(@prefacenum).downcase
148
+ @anchors[clause["id"]] =
149
+ { label: pref,
150
+ level: 1, xref: preface_clause_name(clause), type: "clause" }
151
+ clause.xpath(ns("./clause | ./terms | ./term | ./definitions | "\
152
+ "./references")).each_with_index do |c, i|
153
+ section_names1(c, "#{pref}.#{i + 1}", 2)
154
+ end
155
+ end
94
156
  end
95
157
  end
96
158
  end
@@ -34,14 +34,16 @@ module Metanorma
34
34
  Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
35
35
  end
36
36
 
37
- def output(isodoc_node, outname, format, options={})
37
+ def output(isodoc_node, inname, outname, format, options={})
38
38
  case format
39
39
  when :html
40
- IsoDoc::Ogc::HtmlConvert.new(options).convert(outname, isodoc_node)
40
+ IsoDoc::Ogc::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
41
41
  when :doc
42
- IsoDoc::Ogc::WordConvert.new(options).convert(outname, isodoc_node)
42
+ IsoDoc::Ogc::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
43
43
  when :pdf
44
- IsoDoc::Ogc::PdfConvert.new(options).convert(outname, isodoc_node)
44
+ IsoDoc::Ogc::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
45
+ when :presentation
46
+ IsoDoc::Ogc::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
45
47
  else
46
48
  super
47
49
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "1.0.9"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency "htmlentities", "~> 4.3.4"
28
28
  spec.add_dependency "ruby-jing"
29
29
  spec.add_dependency "metanorma-standoc", "~> 1.4.0"
30
- spec.add_dependency "isodoc", "~> 1.0.20"
30
+ spec.add_dependency "isodoc", "~> 1.1.0"
31
31
  spec.add_dependency "iso-639"
32
32
 
33
33
  spec.add_development_dependency "byebug", "~> 9.1"
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.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-19 00:00:00.000000000 Z
11
+ date: 2020-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.20
61
+ version: 1.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.20
68
+ version: 1.1.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: iso-639
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -272,10 +272,11 @@ files:
272
272
  - lib/isodoc/ogc/ogc.user-guide.xsl
273
273
  - lib/isodoc/ogc/ogc.white-paper.xsl
274
274
  - lib/isodoc/ogc/pdf_convert.rb
275
+ - lib/isodoc/ogc/presentation_xml_convert.rb
275
276
  - lib/isodoc/ogc/reqt.rb
276
- - lib/isodoc/ogc/reqt_xref.rb
277
277
  - lib/isodoc/ogc/sections.rb
278
278
  - lib/isodoc/ogc/word_convert.rb
279
+ - lib/isodoc/ogc/xref.rb
279
280
  - lib/metanorma-ogc.rb
280
281
  - lib/metanorma/ogc.rb
281
282
  - lib/metanorma/ogc/processor.rb
@@ -285,7 +286,7 @@ homepage: https://github.com/metanorma/metanorma-ogc
285
286
  licenses:
286
287
  - BSD-2-Clause
287
288
  metadata: {}
288
- post_install_message:
289
+ post_install_message:
289
290
  rdoc_options: []
290
291
  require_paths:
291
292
  - lib
@@ -300,9 +301,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
301
  - !ruby/object:Gem::Version
301
302
  version: '0'
302
303
  requirements: []
303
- rubyforge_project:
304
- rubygems_version: 2.7.6
305
- signing_key:
304
+ rubygems_version: 3.0.3
305
+ signing_key:
306
306
  specification_version: 4
307
307
  summary: Metanorma for the Open Geospatial Consortium.
308
308
  test_files: []