metanorma-iec 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,18 +13,8 @@ module IsoDoc
13
13
  super
14
14
  end
15
15
 
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
- /\.xml$/.match(filename) or
20
- filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
21
- f.write file
22
- f.path
23
- end
24
- FileUtils.rm_rf dir
25
- ::Metanorma::Output::XslfoPdf.new.convert(
26
- filename, outname_html + ".pdf",
27
- File.join(@libdir, "iec.international-standard.xsl"))
16
+ def pdf_stylesheet(docxml)
17
+ "iec.international-standard.xsl"
28
18
  end
29
19
  end
30
20
  end
@@ -0,0 +1,10 @@
1
+ require_relative "base_convert"
2
+ require "isodoc"
3
+
4
+ module IsoDoc
5
+ module Iec
6
+ class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
7
+ end
8
+ end
9
+ end
10
+
@@ -171,7 +171,7 @@ module IsoDoc
171
171
  div.p **attr_code(class: "formula") do |p|
172
172
  insert_tab(div, 1)
173
173
  parse(node.at(ns("./stem")), div)
174
- lbl = anchor(node['id'], :label, false)
174
+ lbl = @xrefs.anchor(node['id'], :label, false)
175
175
  unless lbl.nil?
176
176
  insert_tab(div, 1)
177
177
  div << "(#{lbl})"
@@ -0,0 +1,45 @@
1
+ module IsoDoc
2
+ module Iec
3
+ class Xref < IsoDoc::Iso::Xref
4
+ def parse(docxml)
5
+ id = docxml&.at(ns("//bibdata/docnumber"))&.text
6
+ @is_iev = id == "60050"
7
+ id = docxml&.at(ns("//bibdata/docidentifier[@type = 'ISO']"))&.text
8
+ m = /60050-(\d+)/.match(id) and @iev_part = m[1]
9
+ super
10
+ end
11
+
12
+ def introduction_names(clause)
13
+ return super unless @is_iev
14
+ end
15
+
16
+ def initial_anchor_names(d)
17
+ super
18
+ return unless @is_iev
19
+ terms_iev_names(d)
20
+ middle_section_asset_names(d)
21
+ termnote_anchor_names(d)
22
+ termexample_anchor_names(d)
23
+ end
24
+
25
+ def terms_iev_names(d)
26
+ d.xpath(ns("//sections/clause/terms")).each_with_index do |t, i|
27
+ num = "#{@iev_part}-%02d" % [i+1]
28
+ @anchors[t["id"]] =
29
+ { label: num, xref: l10n("#{@labels["section_iev"]}-#{num}"), level: 2,
30
+ type: "clause" }
31
+ t.xpath(ns("./term")).each_with_index do |c, i|
32
+ num2 = "%02d" % [i+1]
33
+ section_names1(c, "#{num}-#{num2}", 3)
34
+ end
35
+ end
36
+ end
37
+
38
+ def annex_name_lbl(clause, num)
39
+ obl = l10n("(#{@labels["inform_annex"]})")
40
+ obl = l10n("(#{@labels["norm_annex"]})") if clause["obligation"] == "normative"
41
+ l10n("<b>#{@labels["annex"]} #{num}</b><br/><br/>#{obl}")
42
+ end
43
+ end
44
+ end
45
+ end
@@ -4,7 +4,9 @@ require_relative "metanorma/iec/version"
4
4
  require "isodoc/iec/html_convert"
5
5
  require "isodoc/iec/word_convert"
6
6
  require "isodoc/iec/pdf_convert"
7
+ require "isodoc/iec/presentation_xml_convert"
7
8
  require "isodoc/iec/metadata"
9
+ require "isodoc/iec/xref"
8
10
 
9
11
  if defined? Metanorma
10
12
  require_relative "metanorma/iec"
@@ -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::Iec::HtmlConvert.new(options).convert(outname, isodoc_node)
40
+ IsoDoc::Iec::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
41
41
  when :doc
42
- IsoDoc::Iec::WordConvert.new(options).convert(outname, isodoc_node)
42
+ IsoDoc::Iec::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
43
43
  when :pdf
44
- IsoDoc::Iec::PdfConvert.new(options).convert(outname, isodoc_node)
44
+ IsoDoc::Iec::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
45
+ when :presentation
46
+ IsoDoc::Iec::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
45
47
  else
46
48
  super
47
49
  end
@@ -1,6 +1,6 @@
1
1
  module Metanorma
2
2
  module Iec
3
- VERSION = "1.0.9"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
6
6
 
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
29
29
 
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "isodoc", "~> 1.0.0"
32
- spec.add_dependency "metanorma-iso", "~> 1.3.0"
31
+ spec.add_dependency "isodoc", "~> 1.1.0"
32
+ spec.add_dependency "metanorma-iso", "~> 1.4.0"
33
33
 
34
34
  spec.add_development_dependency "byebug"
35
35
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -288,7 +288,7 @@ RSpec.describe Asciidoctor::Iec do
288
288
  INPUT
289
289
  #{BLANK_HDR}
290
290
  <sections><formula id="_">
291
- <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi><mtext>or</mtext><mi>μ</mi><mi>l</mi><mi>a</mi></math></stem>
291
+ <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi><mi>or</mi><mi>μ</mi><mi>l</mi><mi>a</mi></math></stem>
292
292
  <dl id="_">
293
293
  <dt>a</dt>
294
294
  <dd>
@@ -15,7 +15,7 @@ RSpec.describe Metanorma::Iec::Processor do
15
15
 
16
16
  it "registers output formats against metanorma" do
17
17
  expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT"
18
- [[:doc, "doc"], [:html, "html"], [:pdf, "pdf"], [:rxl, "rxl"], [:xml, "xml"]]
18
+ [[:doc, "doc"], [:html, "html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:xml, "xml"]]
19
19
  OUTPUT
20
20
  end
21
21
 
@@ -35,7 +35,7 @@ RSpec.describe Metanorma::Iec::Processor do
35
35
 
36
36
  it "generates HTML from IsoDoc XML" do
37
37
  FileUtils.rm_f "test.xml"
38
- processor.output(<<~"INPUT", "test.html", :html)
38
+ processor.output(<<~"INPUT", "test.xml", "test.html", :html)
39
39
  <iec-standard xmlns="http://riboseinc.com/isoxml">
40
40
  <sections>
41
41
  <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iec
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: bin
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: ruby-jing
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.0.0
33
+ version: 1.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.0.0
40
+ version: 1.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: metanorma-iso
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.0
47
+ version: 1.4.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.3.0
54
+ version: 1.4.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: byebug
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -244,7 +244,9 @@ files:
244
244
  - lib/isodoc/iec/iec.international-standard.xsl
245
245
  - lib/isodoc/iec/metadata.rb
246
246
  - lib/isodoc/iec/pdf_convert.rb
247
+ - lib/isodoc/iec/presentation_xml_convert.rb
247
248
  - lib/isodoc/iec/word_convert.rb
249
+ - lib/isodoc/iec/xref.rb
248
250
  - lib/metanorma-iec.rb
249
251
  - lib/metanorma/iec.rb
250
252
  - lib/metanorma/iec/processor.rb
@@ -289,7 +291,7 @@ homepage: https://github.com/metanorma/metanorma-iec
289
291
  licenses:
290
292
  - BSD-2-Clause
291
293
  metadata: {}
292
- post_install_message:
294
+ post_install_message:
293
295
  rdoc_options: []
294
296
  require_paths:
295
297
  - lib
@@ -304,9 +306,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
304
306
  - !ruby/object:Gem::Version
305
307
  version: '0'
306
308
  requirements: []
307
- rubyforge_project:
308
- rubygems_version: 2.7.6
309
- signing_key:
309
+ rubygems_version: 3.0.3
310
+ signing_key:
310
311
  specification_version: 4
311
312
  summary: metanorma-iec lets you write IEC standards in AsciiDoc.
312
313
  test_files: []