metanorma-iso 1.3.27 → 1.4.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.
- checksums.yaml +4 -4
- data/lib/asciidoctor/iso/base.rb +11 -14
- data/lib/isodoc/iso/base_convert.rb +23 -22
- data/lib/isodoc/iso/iso.amendment.xsl +746 -261
- data/lib/isodoc/iso/iso.international-standard.xsl +746 -261
- data/lib/isodoc/iso/pdf_convert.rb +0 -13
- data/lib/isodoc/iso/presentation_xml_convert.rb +13 -0
- data/lib/isodoc/iso/sections.rb +2 -2
- data/lib/isodoc/iso/sts_convert.rb +8 -6
- data/lib/isodoc/iso/xref.rb +15 -9
- data/lib/metanorma-iso.rb +1 -0
- data/lib/metanorma/iso/processor.rb +13 -6
- data/lib/metanorma/iso/version.rb +1 -1
- data/metanorma-iso.gemspec +1 -1
- data/spec/asciidoctor-iso/cleanup_spec.rb +1 -1
- data/spec/asciidoctor-iso/table_spec.rb +1 -1
- data/spec/metanorma/processor_spec.rb +2 -2
- metadata +9 -9
@@ -20,19 +20,6 @@ module IsoDoc
|
|
20
20
|
"iso.international-standard.xsl"
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
24
|
-
def convert(filename, file = nil, debug = false)
|
25
|
-
file = File.read(filename, encoding: "utf-8") if file.nil?
|
26
|
-
docxml, outname_html, dir = convert_init(file, filename, debug)
|
27
|
-
/\.xml$/.match(filename) or
|
28
|
-
filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
|
29
|
-
f.write file
|
30
|
-
f.path
|
31
|
-
end
|
32
|
-
FileUtils.rm_rf dir
|
33
|
-
::Metanorma::Output::XslfoPdf.new.convert(
|
34
|
-
filename, outname_html + ".pdf", File.join(@libdir, pdf_stylesheet(docxml)))
|
35
|
-
end
|
36
23
|
end
|
37
24
|
end
|
38
25
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "base_convert"
|
2
|
+
require "isodoc"
|
3
|
+
|
4
|
+
module IsoDoc
|
5
|
+
module Iso
|
6
|
+
|
7
|
+
# A {Converter} implementation that generates HTML output, and a document
|
8
|
+
# schema encapsulation of the document for validation
|
9
|
+
#
|
10
|
+
class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/isodoc/iso/sections.rb
CHANGED
@@ -30,9 +30,9 @@ module IsoDoc
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def annex(isoxml, out)
|
33
|
-
|
33
|
+
amd(isoxml) and @suppressheadingnumbers = @oldsuppressheadingnumbers
|
34
34
|
super
|
35
|
-
|
35
|
+
amd(isoxml) and @suppressheadingnumbers = true
|
36
36
|
end
|
37
37
|
|
38
38
|
def introduction(isoxml, out)
|
@@ -10,18 +10,20 @@ module IsoDoc
|
|
10
10
|
class StsConvert < IsoDoc::XslfoPdfConvert
|
11
11
|
def initialize(options)
|
12
12
|
@libdir = File.dirname(__FILE__)
|
13
|
+
@format = :sts
|
14
|
+
@suffix = "sts.xml"
|
13
15
|
end
|
14
16
|
|
15
|
-
def convert(
|
16
|
-
file = File.read(
|
17
|
-
docxml,
|
18
|
-
/\.xml$/.match(
|
19
|
-
|
17
|
+
def convert(input_filename, file = nil, debug = false, output_filename = nil)
|
18
|
+
file = File.read(input_filename, encoding: "utf-8") if file.nil?
|
19
|
+
docxml, filename, dir = convert_init(file, input_filename, debug)
|
20
|
+
/\.xml$/.match(input_filename) or
|
21
|
+
input_filename = Tempfile.open([filename, ".xml"], encoding: "utf-8") do |f|
|
20
22
|
f.write file
|
21
23
|
f.path
|
22
24
|
end
|
23
25
|
FileUtils.rm_rf dir
|
24
|
-
Mn2sts.convert(
|
26
|
+
Mn2sts.convert(input_filename, output_filename || "#{filename}.#{@suffix}")
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/isodoc/iso/xref.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module IsoDoc
|
2
2
|
module Iso
|
3
|
-
|
4
|
-
def
|
5
|
-
if @amd
|
3
|
+
class Xref < IsoDoc::Xref
|
4
|
+
def parse(docxml)
|
5
|
+
if @klass.amd(docxml)
|
6
6
|
back_anchor_names(docxml)
|
7
7
|
note_anchor_names(docxml.xpath(ns("//annex//table | //annex//figure")))
|
8
8
|
note_anchor_names(docxml.xpath(ns("//annex")))
|
@@ -33,7 +33,7 @@ module IsoDoc
|
|
33
33
|
|
34
34
|
def appendix_names(clause, num)
|
35
35
|
clause.xpath(ns("./appendix")).each_with_index do |c, i|
|
36
|
-
@anchors[c["id"]] = anchor_struct(i + 1, nil, @
|
36
|
+
@anchors[c["id"]] = anchor_struct(i + 1, nil, @labels["appendix"], "clause")
|
37
37
|
@anchors[c["id"]][:level] = 2
|
38
38
|
@anchors[c["id"]][:container] = clause["id"]
|
39
39
|
end
|
@@ -58,12 +58,12 @@ module IsoDoc
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def hierarchical_formula_names(clause, num)
|
61
|
-
c = IsoDoc::
|
61
|
+
c = IsoDoc::XrefGen::Counter.new
|
62
62
|
clause.xpath(ns(".//formula")).each do |t|
|
63
63
|
next if t["id"].nil? || t["id"].empty?
|
64
64
|
@anchors[t["id"]] =
|
65
65
|
anchor_struct("#{num}#{hiersep}#{c.increment(t).print}", t,
|
66
|
-
t["inequality"] ? @
|
66
|
+
t["inequality"] ? @labels["inequality"] : @labels["formula"],
|
67
67
|
"formula", t["unnumbered"])
|
68
68
|
end
|
69
69
|
end
|
@@ -71,13 +71,13 @@ module IsoDoc
|
|
71
71
|
def figure_anchor(t, sublabel, label)
|
72
72
|
@anchors[t["id"]] = anchor_struct(
|
73
73
|
(sublabel ? "#{label} #{sublabel}" : label),
|
74
|
-
nil, @
|
74
|
+
nil, @labels["figure"], "figure", t["unnumbered"])
|
75
75
|
sublabel && t["unnumbered"] != "true" and
|
76
76
|
@anchors[t["id"]][:label] = sublabel
|
77
77
|
end
|
78
78
|
|
79
79
|
def sequential_figure_names(clause)
|
80
|
-
c = IsoDoc::
|
80
|
+
c = IsoDoc::XrefGen::Counter.new
|
81
81
|
j = 0
|
82
82
|
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
|
83
83
|
each do |t|
|
@@ -89,7 +89,7 @@ module IsoDoc
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def hierarchical_figure_names(clause, num)
|
92
|
-
c = IsoDoc::
|
92
|
+
c = IsoDoc::XrefGen::Counter.new
|
93
93
|
j = 0
|
94
94
|
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).
|
95
95
|
each do |t|
|
@@ -100,6 +100,12 @@ module IsoDoc
|
|
100
100
|
figure_anchor(t, sublabel, label)
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
def reference_names(ref)
|
105
|
+
super
|
106
|
+
@anchors[ref["id"]] = { xref: @anchors[ref["id"]][:xref].
|
107
|
+
sub(/ \(All Parts\)/i, "") }
|
108
|
+
end
|
103
109
|
end
|
104
110
|
end
|
105
111
|
end
|
data/lib/metanorma-iso.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative "isodoc/iso/html_convert"
|
|
5
5
|
require_relative "isodoc/iso/word_convert"
|
6
6
|
require_relative "isodoc/iso/pdf_convert"
|
7
7
|
require_relative "isodoc/iso/sts_convert"
|
8
|
+
require_relative "isodoc/iso/presentation_xml_convert"
|
8
9
|
require "asciidoctor/extensions"
|
9
10
|
|
10
11
|
if defined? Metanorma
|
@@ -37,18 +37,25 @@ module Metanorma
|
|
37
37
|
Metanorma::Input::Asciidoc.new.process(file, filename, @asciidoctor_backend)
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def use_presentation_xml(ext)
|
41
|
+
return true if ext == :html_alt
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def output(isodoc_node, inname, outname, format, options={})
|
41
46
|
case format
|
42
47
|
when :html
|
43
|
-
IsoDoc::Iso::HtmlConvert.new(options).convert(
|
48
|
+
IsoDoc::Iso::HtmlConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
44
49
|
when :html_alt
|
45
|
-
IsoDoc::Iso::HtmlConvert.new(options.merge(alt: true)).convert(
|
50
|
+
IsoDoc::Iso::HtmlConvert.new(options.merge(alt: true)).convert(inname, isodoc_node, nil, outname)
|
46
51
|
when :doc
|
47
|
-
IsoDoc::Iso::WordConvert.new(options).convert(
|
52
|
+
IsoDoc::Iso::WordConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
48
53
|
when :pdf
|
49
|
-
IsoDoc::Iso::PdfConvert.new(options).convert(
|
54
|
+
IsoDoc::Iso::PdfConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
50
55
|
when :sts
|
51
|
-
IsoDoc::Iso::StsConvert.new(options).convert(
|
56
|
+
IsoDoc::Iso::StsConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
57
|
+
when :presentation
|
58
|
+
IsoDoc::Iso::PresentationXMLConvert.new(options).convert(inname, isodoc_node, nil, outname)
|
52
59
|
else
|
53
60
|
super
|
54
61
|
end
|
data/metanorma-iso.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
31
31
|
|
32
32
|
spec.add_dependency "ruby-jing"
|
33
|
-
spec.add_dependency "isodoc", "~> 1.
|
33
|
+
spec.add_dependency "isodoc", "~> 1.1.0"
|
34
34
|
spec.add_dependency "metanorma-standoc", "~> 1.4.0"
|
35
35
|
spec.add_dependency "tokenizer", "~> 0.3.0"
|
36
36
|
spec.add_dependency "twitter_cldr"
|
@@ -547,7 +547,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
547
547
|
INPUT
|
548
548
|
#{BLANK_HDR}
|
549
549
|
<sections><formula id="_">
|
550
|
-
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mi>F</mi><
|
550
|
+
<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>
|
551
551
|
<dl id="_">
|
552
552
|
<dt>a</dt>
|
553
553
|
<dd>
|
@@ -150,7 +150,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
150
150
|
<tr>
|
151
151
|
<th rowspan="2" align="left">Defect</th>
|
152
152
|
<th colspan="4" align="center">Maximum permissible mass fraction of defects in husked rice<br/>
|
153
|
-
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>w</mi><
|
153
|
+
<stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><msub><mi>w</mi><mo>max</mo></msub></math></stem></th>
|
154
154
|
</tr>
|
155
155
|
<tr>
|
156
156
|
<th align="left">in husked rice</th>
|
@@ -15,7 +15,7 @@ RSpec.describe Metanorma::Iso::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"], [:html_alt, "alt.html"], [:pdf, "pdf"], [:rxl, "rxl"], [:sts, "sts.xml"], [:xml, "xml"]]
|
18
|
+
[[:doc, "doc"], [:html, "html"], [:html_alt, "alt.html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:sts, "sts.xml"], [:xml, "xml"]]
|
19
19
|
OUTPUT
|
20
20
|
end
|
21
21
|
|
@@ -35,7 +35,7 @@ RSpec.describe Metanorma::Iso::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
|
<iso-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-iso
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.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-
|
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,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
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.
|
40
|
+
version: 1.1.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: metanorma-standoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -308,6 +308,7 @@ files:
|
|
308
308
|
- lib/isodoc/iso/iso.international-standard.xsl
|
309
309
|
- lib/isodoc/iso/metadata.rb
|
310
310
|
- lib/isodoc/iso/pdf_convert.rb
|
311
|
+
- lib/isodoc/iso/presentation_xml_convert.rb
|
311
312
|
- lib/isodoc/iso/sections.rb
|
312
313
|
- lib/isodoc/iso/sts_convert.rb
|
313
314
|
- lib/isodoc/iso/word_convert.rb
|
@@ -375,7 +376,7 @@ homepage: https://github.com/metanorma/metanorma-iso
|
|
375
376
|
licenses:
|
376
377
|
- BSD-2-Clause
|
377
378
|
metadata: {}
|
378
|
-
post_install_message:
|
379
|
+
post_install_message:
|
379
380
|
rdoc_options: []
|
380
381
|
require_paths:
|
381
382
|
- lib
|
@@ -390,9 +391,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
390
391
|
- !ruby/object:Gem::Version
|
391
392
|
version: '0'
|
392
393
|
requirements: []
|
393
|
-
|
394
|
-
|
395
|
-
signing_key:
|
394
|
+
rubygems_version: 3.0.3
|
395
|
+
signing_key:
|
396
396
|
specification_version: 4
|
397
397
|
summary: metanorma-iso lets you write ISO standards in AsciiDoc.
|
398
398
|
test_files: []
|