metanorma-iho 0.0.3 → 0.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.
@@ -18,19 +18,6 @@ module IsoDoc
18
18
  "iho.specification.xsl"
19
19
  end
20
20
  end
21
-
22
- def convert(filename, file = nil, debug = false)
23
- file = File.read(filename, encoding: "utf-8") if file.nil?
24
- docxml, outname_html, dir = convert_init(file, filename, debug)
25
- /\.xml$/.match(filename) or
26
- filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
27
- f.write file
28
- f.path
29
- end
30
- FileUtils.rm_rf dir
31
- ::Metanorma::Output::XslfoPdf.new.convert(
32
- filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
33
- end
34
21
  end
35
22
  end
36
23
  end
@@ -0,0 +1,11 @@
1
+ require_relative "base_convert"
2
+ require "isodoc"
3
+ require "metanorma-generic"
4
+
5
+ module IsoDoc
6
+ module IHO
7
+ class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,64 @@
1
+ require "isodoc/generic/xref"
2
+
3
+ module IsoDoc
4
+ module IHO
5
+ class Xref < IsoDoc::Generic::Xref
6
+ def annex_name_lbl(clause, num)
7
+ lbl = clause["obligation"] == "informative" ?
8
+ @labels["appendix"] : @labels["annex"]
9
+ l10n("<b>#{lbl} #{num}</b>")
10
+ end
11
+
12
+ def annex_names(clause, num)
13
+ appendix_names(clause, num)
14
+ lbl = clause["obligation"] == "informative" ?
15
+ @labels["appendix"] : @labels["annex"]
16
+ @anchors[clause["id"]] =
17
+ { label: annex_name_lbl(clause, num), type: "clause",
18
+ xref: "#{lbl} #{num}", level: 1 }
19
+ if a = single_annex_special_section(clause)
20
+ annex_names1(a, "#{num}", 1)
21
+ else
22
+ clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).
23
+ each_with_index do |c, i|
24
+ annex_names1(c, "#{num}.#{i + 1}", 2)
25
+ end
26
+ end
27
+ hierarchical_asset_names(clause, num)
28
+ end
29
+
30
+ def back_anchor_names(docxml)
31
+ super
32
+ docxml.xpath(ns("//annex[@obligation = 'informative']")).
33
+ each_with_index do |c, i|
34
+ annex_names(c, i + 1)
35
+ end
36
+ docxml.xpath(ns("//annex[not(@obligation = 'informative')]")).
37
+ each_with_index do |c, i|
38
+ annex_names(c, (65 + i + (i > 7 ? 1 : 0)).chr.to_s)
39
+ end
40
+ end
41
+
42
+ def annex_names1(clause, num, level)
43
+ lbl = clause.at("./ancestor::xmlns:annex/@obligation").
44
+ text == "informative" ? @labels["appendix"] : @labels["annex"]
45
+ @anchors[clause["id"]] =
46
+ { label: num, xref: "#{lbl} #{num}",
47
+ level: level, type: "clause" }
48
+ clause.xpath(ns("./clause | ./references | ./terms | ./definitions")).
49
+ each_with_index do |c, i|
50
+ annex_names1(c, "#{num}.#{i + 1}", level + 1)
51
+ end
52
+ end
53
+
54
+ def appendix_names(clause, num)
55
+ clause.xpath(ns("./appendix")).each_with_index do |c, i|
56
+ @anchors[c["id"]] =
57
+ anchor_struct(i + 1, nil, @labels["appendix"], "clause")
58
+ @anchors[c["id"]][:level] = 2
59
+ @anchors[c["id"]][:container] = clause["id"]
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -4,6 +4,7 @@ require_relative "isodoc/iho/base_convert"
4
4
  require_relative "isodoc/iho/html_convert"
5
5
  require_relative "isodoc/iho/word_convert"
6
6
  require_relative "isodoc/iho/pdf_convert"
7
+ require_relative "isodoc/iho/presentation_xml_convert"
7
8
  require_relative "metanorma/iho/version"
8
9
 
9
10
  if defined? Metanorma
@@ -27,14 +27,16 @@ module Metanorma
27
27
  "Metanorma::IHO #{Metanorma::IHO::VERSION}"
28
28
  end
29
29
 
30
- def output(isodoc_node, outname, format, options={})
30
+ def output(isodoc_node, inname, outname, format, options={})
31
31
  case format
32
32
  when :html
33
- IsoDoc::IHO::HtmlConvert.new(options).convert(outname, isodoc_node)
33
+ IsoDoc::IHO::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
34
34
  when :doc
35
- IsoDoc::IHO::WordConvert.new(options).convert(outname, isodoc_node)
35
+ IsoDoc::IHO::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
36
36
  when :pdf
37
- IsoDoc::IHO::PdfConvert.new(options).convert(outname, isodoc_node)
37
+ IsoDoc::IHO::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
38
+ when :presentation
39
+ IsoDoc::IHO::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
38
40
  else
39
41
  super
40
42
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IHO
3
- VERSION = "0.0.3"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
30
  spec.add_dependency "metanorma-standoc", "~> 1.4.0"
31
- spec.add_dependency "isodoc", "~> 1.0.0"
32
- spec.add_dependency 'metanorma-generic', '~> 1.4.0'
31
+ spec.add_dependency "isodoc", "~> 1.1.0"
32
+ spec.add_dependency 'metanorma-generic', '~> 1.5.0'
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
35
35
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.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-08 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
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: 1.1.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: 1.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: metanorma-generic
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.4.0
61
+ version: 1.5.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.4.0
68
+ version: 1.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -241,7 +241,9 @@ files:
241
241
  - lib/isodoc/iho/iho.standard.xsl
242
242
  - lib/isodoc/iho/metadata.rb
243
243
  - lib/isodoc/iho/pdf_convert.rb
244
+ - lib/isodoc/iho/presentation_xml_convert.rb
244
245
  - lib/isodoc/iho/word_convert.rb
246
+ - lib/isodoc/iho/xref.rb
245
247
  - lib/metanorma-iho.rb
246
248
  - lib/metanorma/iho.rb
247
249
  - lib/metanorma/iho/processor.rb
@@ -252,7 +254,7 @@ homepage: https://github.com/metanorma/metanorma-iho
252
254
  licenses:
253
255
  - BSD-2-Clause
254
256
  metadata: {}
255
- post_install_message:
257
+ post_install_message:
256
258
  rdoc_options: []
257
259
  require_paths:
258
260
  - lib
@@ -267,9 +269,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
269
  - !ruby/object:Gem::Version
268
270
  version: '0'
269
271
  requirements: []
270
- rubyforge_project:
271
- rubygems_version: 2.7.6
272
- signing_key:
272
+ rubygems_version: 3.0.3
273
+ signing_key:
273
274
  specification_version: 4
274
275
  summary: metanorma-iho lets you write IHO in AsciiDoc.
275
276
  test_files: []