metanorma-standoc 1.10.4 → 1.10.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ require "isodoc"
2
+
3
+ module IsoDoc
4
+ module Standoc
5
+
6
+ # A {Converter} implementation that generates HTML output, and a document
7
+ # schema encapsulation of the document for validation
8
+ #
9
+ class PdfConvert < IsoDoc::XslfoPdfConvert
10
+ def initialize(options)
11
+ @libdir = File.dirname(__FILE__)
12
+ super
13
+ end
14
+
15
+ def pdf_stylesheet(docxml)
16
+ "base.standard.xsl"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,4 +1,5 @@
1
1
  require "asciidoctor" unless defined? Asciidoctor::Converter
2
+ require_relative "isodoc/pdf_convert"
2
3
  require_relative "asciidoctor/standoc/converter"
3
4
  require_relative "metanorma/standoc/version"
4
5
  require "asciidoctor/extensions"
@@ -13,6 +13,7 @@ module Metanorma
13
13
  super.merge(
14
14
  html: "html",
15
15
  doc: "doc",
16
+ pdf: "pdf",
16
17
  )
17
18
  end
18
19
 
@@ -29,12 +30,15 @@ module Metanorma
29
30
  when :html
30
31
  options = options
31
32
  .merge(htmlstylesheet: html_path("htmlstyle.scss"),
32
- htmlcoverpage: html_path("html_titlepage.html"))
33
+ htmlcoverpage: html_path("html_titlepage.html"))
33
34
  IsoDoc::HtmlConvert.new(options)
34
35
  .convert(inname, isodoc_node, nil, outname)
35
36
  when :doc
36
37
  IsoDoc::WordConvert.new(options)
37
38
  .convert(inname, isodoc_node, nil, outname)
39
+ when :pdf
40
+ IsoDoc::Standoc::PdfConvert.new(options)
41
+ .convert(inname, isodoc_node, nil, outname)
38
42
  when :presentation
39
43
  IsoDoc::PresentationXMLConvert.new(options)
40
44
  .convert(inname, isodoc_node, nil, outname)
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "1.10.4".freeze
22
+ VERSION = "1.10.4.1".freeze
23
23
  end
24
24
  end
@@ -35,6 +35,7 @@ RSpec.describe Asciidoctor::Standoc do
35
35
  expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
36
36
  .to be_equivalent_to xmlpp(output)
37
37
  expect(File.exist?("test.doc")).to be true
38
+ expect(File.exist?("test.pdf")).to be true
38
39
  expect(File.exist?("htmlstyle.css")).to be false
39
40
  end
40
41
 
@@ -45,6 +46,7 @@ RSpec.describe Asciidoctor::Standoc do
45
46
  Author
46
47
  :docfile: test.adoc
47
48
  :novalid:
49
+ :no-pdf:
48
50
  :language: ar
49
51
  INPUT
50
52
  output = <<~OUTPUT
@@ -887,6 +889,7 @@ RSpec.describe Asciidoctor::Standoc do
887
889
  Author
888
890
  :docfile: test.adoc
889
891
  :novalid:
892
+ :no-pdf:
890
893
  :scripts: spec/assets/scripts.html
891
894
  INPUT
892
895
  html = File.read("test.html", encoding: "utf-8")
@@ -899,6 +902,7 @@ RSpec.describe Asciidoctor::Standoc do
899
902
  = Document title
900
903
  Author
901
904
  :docfile: test.adoc
905
+ :no-pdf:
902
906
  :novalid:
903
907
  :script: Hans
904
908
  :body-font: Zapf Chancery
@@ -934,6 +938,7 @@ RSpec.describe Asciidoctor::Standoc do
934
938
  Author
935
939
  :docfile: test.adoc
936
940
  :novalid:
941
+ :no-pdf:
937
942
  :script: Hans
938
943
  :body-font: Zapf Chancery
939
944
  :header-font: Comic Sans
@@ -974,6 +979,7 @@ QU1FOiB0ZXN0Cgo=
974
979
  Asciidoctor.convert(<<~"INPUT", *OPTIONS)
975
980
  = Document title
976
981
  Author
982
+ :no-pdf:
977
983
  :docfile: test.adoc
978
984
  :doctype: standard
979
985
  :encoding: utf-8
@@ -1357,7 +1357,7 @@ RSpec.describe Asciidoctor::Standoc do
1357
1357
 
1358
1358
  it "processes section names, internationalisation file" do
1359
1359
  input = <<~INPUT
1360
- #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ':i18nyaml: spec/assets/i18n.yaml')}
1360
+ #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":no-pdf:\n:i18nyaml: spec/assets/i18n.yaml")}
1361
1361
  .Foreword
1362
1362
 
1363
1363
  Text
@@ -331,36 +331,36 @@ RSpec.describe Asciidoctor::Standoc do
331
331
  ....
332
332
  INPUT
333
333
  output = <<~OUTPUT
334
- #{BLANK_HDR}
335
- <sections>
336
- <p id='_'>
337
- &#8220;ppt&#8221;,
338
- <index>
339
- <primary>ppt</primary>
340
- </index>
341
- </p>
342
- <p id='_'>
343
- &#8220;ppm&#8221;,
344
- <index>
345
- <primary>ppm</primary>
346
- </index>
347
- &#8220;ppt&#8221;
348
- <index>
349
- <primary>ppt</primary>
350
- </index>
351
- </p>
352
- <p id='_'>
353
- &#8220;ppm
354
- <index>
355
- <primary>ppm</primary>
356
- </index>
357
- &#8220;&#160;
358
- </p>
359
- <figure id='_'>
360
- <pre id='_'>((ppm))",</pre>
361
- </figure>
362
- </sections>
363
- </standard-document>
334
+ #{BLANK_HDR}
335
+ <sections>
336
+ <p id='_'>
337
+ &#8220;ppt&#8221;,
338
+ <index>
339
+ <primary>ppt</primary>
340
+ </index>
341
+ </p>
342
+ <p id='_'>
343
+ &#8220;ppm&#8221;,
344
+ <index>
345
+ <primary>ppm</primary>
346
+ </index>
347
+ &#8220;ppt&#8221;
348
+ <index>
349
+ <primary>ppt</primary>
350
+ </index>
351
+ </p>
352
+ <p id='_'>
353
+ &#8220;ppm
354
+ <index>
355
+ <primary>ppm</primary>
356
+ </index>
357
+ &#8220;&#160;
358
+ </p>
359
+ <figure id='_'>
360
+ <pre id='_'>((ppm))",</pre>
361
+ </figure>
362
+ </sections>
363
+ </standard-document>
364
364
  OUTPUT
365
365
  expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
366
366
  .to be_equivalent_to xmlpp(output)
@@ -2100,6 +2100,90 @@ RSpec.describe Asciidoctor::Standoc do
2100
2100
  .to be_equivalent_to xmlpp(output)
2101
2101
  end
2102
2102
 
2103
+ it "moves metadata deflist to correct location" do
2104
+ input = <<~INPUT
2105
+ #{ASCIIDOC_BLANK_HDR}
2106
+
2107
+ == Clause
2108
+
2109
+ [.requirement,subsequence="A",inherit="/ss/584/2015/level/1 &amp; /ss/584/2015/level/2"]
2110
+ ====
2111
+ [%metadata]
2112
+ model:: ogc
2113
+ type:: class
2114
+ label:: http://www.opengis.net/spec/waterml/2.0/req/xsd-xml-rules[*req/core*]
2115
+ subject:: Encoding of logical models
2116
+ inherit:: urn:iso:dis:iso:19156:clause:7.2.2
2117
+ inherit:: urn:iso:dis:iso:19156:clause:8
2118
+ inherit:: http://www.opengis.net/doc/IS/GML/3.2/clause/2.4
2119
+ inherit:: O&M Abstract model, OGC 10-004r3, clause D.3.4
2120
+ inherit:: http://www.opengis.net/spec/SWE/2.0/req/core/core-concepts-used
2121
+ inherit:: <<ref2>>
2122
+ inherit:: <<ref3>>
2123
+ classification:: priority:P0
2124
+ classification:: domain:Hydrology,Groundwater
2125
+ classification:: control-class:Technical
2126
+ obligation:: recommendation,requirement
2127
+
2128
+ I recommend this
2129
+ ====
2130
+ INPUT
2131
+ output = <<~OUTPUT
2132
+ #{BLANK_HDR}
2133
+ <sections>
2134
+ <clause id='_' inline-header='false' obligation='normative'>
2135
+ <title>Clause</title>
2136
+ <requirement id='_' subsequence='A'>
2137
+ <label>
2138
+ <link target='http://www.opengis.net/spec/waterml/2.0/req/xsd-xml-rules'>
2139
+ <strong>req/core</strong>
2140
+ </link>
2141
+ </label>
2142
+ <subject>Encoding of logical models</subject>
2143
+ <inherit>/ss/584/2015/level/1 &amp; /ss/584/2015/level/2</inherit>
2144
+ <inherit>urn:iso:dis:iso:19156:clause:7.2.2</inherit>
2145
+ <inherit>urn:iso:dis:iso:19156:clause:8</inherit>
2146
+ <inherit>
2147
+ <link target='http://www.opengis.net/doc/IS/GML/3.2/clause/2.4'/>
2148
+ </inherit>
2149
+ <inherit>O&amp;M Abstract model, OGC 10-004r3, clause D.3.4</inherit>
2150
+ <inherit>
2151
+ <link target='http://www.opengis.net/spec/SWE/2.0/req/core/core-concepts-used'/>
2152
+ </inherit>
2153
+ <inherit>
2154
+ <xref target='ref2'/>
2155
+ </inherit>
2156
+ <inherit>
2157
+ <xref target='ref3'/>
2158
+ </inherit>
2159
+ <classification>
2160
+ <tag>control-class</tag>
2161
+ <value>Technical</value>
2162
+ </classification>
2163
+ <classification>
2164
+ <tag>domain</tag>
2165
+ <value>Groundwater</value>
2166
+ </classification>
2167
+ <classification>
2168
+ <tag>domain</tag>
2169
+ <value>Hydrology</value>
2170
+ </classification>
2171
+ <classification>
2172
+ <tag>priority</tag>
2173
+ <value>P0</value>
2174
+ </classification>
2175
+ <description>
2176
+ <p id='_'>I recommend this</p>
2177
+ </description>
2178
+ </requirement>
2179
+ </clause>
2180
+ </sections>
2181
+ </standard-document>
2182
+ OUTPUT
2183
+ expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
2184
+ .to be_equivalent_to xmlpp(output)
2185
+ end
2186
+
2103
2187
  it "moves inherit macros to correct location" do
2104
2188
  input = <<~INPUT
2105
2189
  #{ASCIIDOC_BLANK_HDR}
@@ -22,6 +22,7 @@ RSpec.describe Asciidoctor::Standoc do
22
22
  Author
23
23
  :docfile: test.adoc
24
24
  :nodoc:
25
+ :no-pdf:
25
26
 
26
27
  [[abc]]
27
28
  == Clause 1
@@ -258,6 +259,7 @@ RSpec.describe Asciidoctor::Standoc do
258
259
  = Document title
259
260
  Author
260
261
  :docfile: test.adoc
262
+ :no-pdf:
261
263
 
262
264
  [bibliography]
263
265
  == Normative References
@@ -285,6 +287,7 @@ RSpec.describe Asciidoctor::Standoc do
285
287
  = Document title
286
288
  Author
287
289
  :docfile: test.adoc
290
+ :no-pdf:
288
291
 
289
292
  [bibliography]
290
293
  == Normative References
@@ -443,6 +446,7 @@ RSpec.describe Asciidoctor::Standoc do
443
446
  = Document title
444
447
  Author
445
448
  :docfile: test.adoc
449
+ :no-pdf:
446
450
 
447
451
  footnoteblock:[id1]
448
452
 
@@ -1,4 +1,5 @@
1
1
  = Document title
2
2
  Author
3
+ :no-pdf:
3
4
 
4
5
  [datamodel_attributes_table,models/models/AddressClassProfile.yml]
@@ -1,4 +1,5 @@
1
1
  = Document title
2
2
  Author
3
+ :no-pdf:
3
4
 
4
5
  [datamodel_attributes_table,models/models/AddressComponentProfile.yml]
@@ -1,4 +1,5 @@
1
1
  = Document title
2
2
  Author
3
+ :no-pdf:
3
4
 
4
5
  [datamodel_attributes_table,models/models/SignatureBlankDefinition.yml]
@@ -1,4 +1,5 @@
1
1
  = Document title
2
2
  Author
3
+ :no-pdf:
3
4
 
4
- [datamodel_diagram,models/views/CommonModels.yml]
5
+ [datamodel_diagram,models/views/CommonModels.yml]
@@ -1,4 +1,5 @@
1
1
  = Document title
2
2
  Author
3
+ :no-pdf:
3
4
 
4
- [datamodel_diagram,models/views/TopDown.yml]
5
+ [datamodel_diagram,models/views/TopDown.yml]
@@ -3,7 +3,6 @@ require "metanorma"
3
3
  require "fileutils"
4
4
 
5
5
  RSpec.describe Metanorma::Standoc::Processor do
6
-
7
6
  registry = Metanorma::Registry.instance
8
7
  registry.register(Metanorma::Standoc::Processor)
9
8
  processor = registry.find_processor(:standoc)
@@ -14,7 +13,7 @@ RSpec.describe Metanorma::Standoc::Processor do
14
13
 
15
14
  it "registers output formats against metanorma" do
16
15
  expect(processor.output_formats.sort.to_s).to be_equivalent_to <<~"OUTPUT"
17
- [[:doc, "doc"], [:html, "html"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:xml, "xml"]]
16
+ [[:doc, "doc"], [:html, "html"], [:pdf, "pdf"], [:presentation, "presentation.xml"], [:rxl, "rxl"], [:xml, "xml"]]
18
17
  OUTPUT
19
18
  end
20
19
 
@@ -25,68 +24,69 @@ RSpec.describe Metanorma::Standoc::Processor do
25
24
 
26
25
  it "generates IsoDoc XML from a blank document" do
27
26
  expect(processor.input_to_isodoc(<<~"INPUT", "test")).to be_equivalent_to <<~"OUTPUT"
28
- #{ASCIIDOC_BLANK_HDR}
27
+ #{ASCIIDOC_BLANK_HDR}
29
28
  INPUT
30
- #{BLANK_HDR}
31
- <sections/>
32
- </iso-standard>
29
+ #{BLANK_HDR}
30
+ <sections/>
31
+ </iso-standard>
33
32
  OUTPUT
34
33
  end
35
34
 
36
35
  it "generates HTML from IsoDoc XML" do
37
36
  FileUtils.rm_f "test.html"
38
37
  processor.output(<<~"INPUT", "test.xml", "test.html", :html)
39
- <iso-standard xmlns="http://riboseinc.com/isoxml">
40
- <sections>
41
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
42
- <term id="J">
43
- <preferred>Term2</preferred>
44
- </term>
45
- </terms>
46
- </sections>
47
- </iso-standard>
38
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
39
+ <sections>
40
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
41
+ <term id="J">
42
+ <preferred>Term2</preferred>
43
+ </term>
44
+ </terms>
45
+ </sections>
46
+ </iso-standard>
48
47
  INPUT
49
- expect(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(%r{</main>.*}m, "</main>")).to be_equivalent_to <<~"OUTPUT"
50
- <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
51
- <p class="zzSTDTitle1"></p>
52
- <div id="H"><h1>Terms, Definitions, Symbols and Abbreviated Terms</h1><h2 class="TermNum" id="J"></h2>
53
- <p class="Terms" style="text-align:left;">Term2</p>
54
- </div>
55
- </main>
56
- OUTPUT
48
+ expect(File.read("test.html", encoding: "utf-8").gsub(%r{^.*<main}m, "<main").gsub(
49
+ %r{</main>.*}m, "</main>"
50
+ )).to be_equivalent_to <<~"OUTPUT"
51
+ <main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
52
+ <p class="zzSTDTitle1"></p>
53
+ <div id="H"><h1>Terms, Definitions, Symbols and Abbreviated Terms</h1><h2 class="TermNum" id="J"></h2>
54
+ <p class="Terms" style="text-align:left;">Term2</p>
55
+ </div>
56
+ </main>
57
+ OUTPUT
57
58
  end
58
59
 
59
- it "generates HTML from IsoDoc XML" do
60
+ it "generates HTML from IsoDoc XML" do
60
61
  FileUtils.rm_f "test.doc"
61
62
  processor.output(<<~"INPUT", "test.xml", "test.doc", :doc)
62
- <iso-standard xmlns="http://riboseinc.com/isoxml">
63
- <sections>
64
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
65
- <term id="J">
66
- <preferred>Term2</preferred>
67
- </term>
68
- </terms>
69
- </sections>
70
- </iso-standard>
63
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
64
+ <sections>
65
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
66
+ <term id="J">
67
+ <preferred>Term2</preferred>
68
+ </term>
69
+ </terms>
70
+ </sections>
71
+ </iso-standard>
71
72
  INPUT
72
- expect(File.read("test.doc", encoding: "utf-8")).to match(/Terms, Definitions, Symbols and Abbreviated Terms/)
73
- end
73
+ expect(File.read("test.doc",
74
+ encoding: "utf-8")).to match(/Terms, Definitions, Symbols and Abbreviated Terms/)
75
+ end
74
76
 
75
- it "generates XML from IsoDoc XML" do
77
+ it "generates XML from IsoDoc XML" do
76
78
  FileUtils.rm_f "test.xml"
77
79
  processor.output(<<~"INPUT", "test.xml", "test.xml", :xml)
78
- <iso-standard xmlns="http://riboseinc.com/isoxml">
79
- <sections>
80
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
81
- <term id="J">
82
- <preferred>Term2</preferred>
83
- </term>
84
- </terms>
85
- </sections>
86
- </iso-standard>
87
- INPUT
88
- expect(File.exist?("test.xml")).to be true
89
-
90
- end
91
-
80
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
81
+ <sections>
82
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
83
+ <term id="J">
84
+ <preferred>Term2</preferred>
85
+ </term>
86
+ </terms>
87
+ </sections>
88
+ </iso-standard>
89
+ INPUT
90
+ expect(File.exist?("test.xml")).to be true
91
+ end
92
92
  end