metanorma-iso 1.3.22 → 1.3.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,6 +50,8 @@ module IsoDoc
50
50
  set(:docnumber, dn&.text)
51
51
  tcdn = isoxml.xpath(ns("//bibdata/docidentifier[@type = 'iso-tc']"))
52
52
  set(:tc_docnumber, tcdn.map { |n| n.text })
53
+ dn = isoxml.at(ns("//bibdata/docidentifier[@type = 'iso-with-lang']"))
54
+ set(:docnumber_lang, dn&.text)
53
55
  end
54
56
 
55
57
  # we don't leave this to i18n.rb, because we have both English and
@@ -0,0 +1,32 @@
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 PdfConvert < IsoDoc::XslfoPdfConvert
11
+ def initialize(options)
12
+ @libdir = File.dirname(__FILE__)
13
+ super
14
+ end
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, "iso.international-standard.xsl"))
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -3,6 +3,7 @@ require_relative "asciidoctor/iso/converter"
3
3
  require_relative "metanorma/iso/version"
4
4
  require_relative "isodoc/iso/html_convert"
5
5
  require_relative "isodoc/iso/word_convert"
6
+ require_relative "isodoc/iso/pdf_convert"
6
7
  require "asciidoctor/extensions"
7
8
 
8
9
  if defined? Metanorma
@@ -2,6 +2,10 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module Iso
5
+ def self.pdf_fonts
6
+ ["Cambria", "Times New Roman", "Cambria Math", "HanSans", "Courier"]
7
+ end
8
+
5
9
  class Processor < Metanorma::Processor
6
10
 
7
11
  def initialize
@@ -14,7 +18,8 @@ module Metanorma
14
18
  super.merge(
15
19
  html: "html",
16
20
  html_alt: "alt.html",
17
- doc: "doc"
21
+ doc: "doc",
22
+ pdf: "pdf"
18
23
  )
19
24
  end
20
25
 
@@ -34,6 +39,8 @@ module Metanorma
34
39
  IsoDoc::Iso::HtmlConvert.new(options.merge(alt: true)).convert(outname, isodoc_node)
35
40
  when :doc
36
41
  IsoDoc::Iso::WordConvert.new(options).convert(outname, isodoc_node)
42
+ when :pdf
43
+ IsoDoc::Iso::PdfConvert.new(options).convert(outname, isodoc_node)
37
44
  else
38
45
  super
39
46
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module ISO
3
- VERSION = "1.3.22".freeze
3
+ VERSION = "1.3.23".freeze
4
4
  end
5
5
  end
@@ -35,6 +35,7 @@ RSpec.describe Asciidoctor::ISO do
35
35
  :docfile: test.adoc
36
36
  :novalid:
37
37
  :no-isobib:
38
+ :no-pdf:
38
39
  INPUT
39
40
  #{BLANK_HDR}
40
41
  <sections/>
@@ -486,6 +487,7 @@ OUTPUT
486
487
  :docfile: test.adoc
487
488
  :novalid:
488
489
  :no-isobib:
490
+ :no-pdf:
489
491
  INPUT
490
492
  html = File.read("test.html", encoding: "utf-8")
491
493
  expect(html).to match(%r{<script>})
@@ -499,6 +501,7 @@ OUTPUT
499
501
  :docfile: test.adoc
500
502
  :novalid:
501
503
  :no-isobib:
504
+ :no-pdf:
502
505
  INPUT
503
506
  html = File.read("test.html", encoding: "utf-8")
504
507
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
@@ -514,6 +517,7 @@ OUTPUT
514
517
  :docfile: test.adoc
515
518
  :novalid:
516
519
  :no-isobib:
520
+ :no-pdf:
517
521
  INPUT
518
522
  html = File.read("test_alt.html", encoding: "utf-8")
519
523
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Space Mono", monospace;]m)
@@ -530,6 +534,7 @@ OUTPUT
530
534
  :novalid:
531
535
  :no-isobib:
532
536
  :script: Hans
537
+ :no-pdf:
533
538
  INPUT
534
539
  html = File.read("test.html", encoding: "utf-8")
535
540
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
@@ -549,6 +554,7 @@ OUTPUT
549
554
  :body-font: Zapf Chancery
550
555
  :header-font: Comic Sans
551
556
  :monospace-font: Andale Mono
557
+ :no-pdf:
552
558
  INPUT
553
559
  html = File.read("test.html", encoding: "utf-8")
554
560
  expect(html).to match(%r[\bpre[^{]+\{[^{]+font-family: Andale Mono;]m)
@@ -565,6 +571,7 @@ OUTPUT
565
571
  :docfile: test.adoc
566
572
  :novalid:
567
573
  :no-isobib:
574
+ :no-pdf:
568
575
  INPUT
569
576
  word = File.read("test.doc", encoding: "utf-8")
570
577
  html = File.read("test.html", encoding: "utf-8")
@@ -195,6 +195,7 @@ RSpec.describe Asciidoctor::ISO do
195
195
  <bibitem id="iso216" type="standard">
196
196
  <title format="text/plain">Reference</title>
197
197
  <docidentifier>ISO 216:2001</docidentifier>
198
+ <docnumber>216</docnumber>
198
199
  <date type="published">
199
200
  <on>2001</on>
200
201
  </date>
@@ -237,6 +238,7 @@ RSpec.describe Asciidoctor::ISO do
237
238
  <bibitem id="iso216" type="standard">
238
239
  <title format="text/plain">Reference</title>
239
240
  <docidentifier>ISO 216</docidentifier>
241
+ <docnumber>216</docnumber>
240
242
  <contributor>
241
243
  <role type="publisher"/>
242
244
  <organization>
@@ -274,6 +276,7 @@ RSpec.describe Asciidoctor::ISO do
274
276
  <bibitem id="iso216" type="standard">
275
277
  <title format="text/plain">Reference</title>
276
278
  <docidentifier>ISO 216</docidentifier>
279
+ <docnumber>216</docnumber>
277
280
  <contributor>
278
281
  <role type="publisher"/>
279
282
  <organization>
@@ -335,6 +338,7 @@ RSpec.describe Asciidoctor::ISO do
335
338
  <bibitem id="iso216" type="standard">
336
339
  <title format="text/plain">Reference</title>
337
340
  <docidentifier>ISO 216</docidentifier>
341
+ <docnumber>216</docnumber>
338
342
  <contributor>
339
343
  <role type="publisher"/>
340
344
  <organization>
@@ -639,6 +643,7 @@ RSpec.describe Asciidoctor::ISO do
639
643
  <bibitem id="iso123" type="standard">
640
644
  <title format="text/plain">Standard</title>
641
645
  <docidentifier>ISO 123:—</docidentifier>
646
+ <docnumber>123</docnumber>
642
647
  <date type="published">
643
648
  <on>–</on>
644
649
  </date>
@@ -789,36 +794,46 @@ RSpec.describe Asciidoctor::ISO do
789
794
  * [[[ref17,(A)]]], _Standard 30_
790
795
  INPUT
791
796
  #{BLANK_HDR}
792
- <sections><clause id="_" inline-header="false" obligation="normative">
793
- <title>Clause 1</title>
794
- <p id="_"><eref type="inline" bibitemid="ref1" citeas="ISO 123"/>
795
- <eref type='inline' bibitemid='ref1a' citeas='ISO 123-100'/>
796
- <eref type='inline' bibitemid='ref1b' citeas='ISO/TS 123-1'/>
797
- <eref type="inline" bibitemid="ref2" citeas="ISO/IEC 123"/>
798
- <eref type="inline" bibitemid="ref3" citeas="IEC 123"/>
799
- <eref type="inline" bibitemid="ref4" citeas="GB 123"/>
800
- <eref type="inline" bibitemid="ref5" citeas="[6]"/>
801
- <eref type="inline" bibitemid="ref6" citeas="[B]"/>
802
- <eref type="inline" bibitemid="ref7" citeas="[A]"/>
803
- <xref target="ref8"/>
804
- <xref target="ref9"/>
805
- <eref type="inline" bibitemid="ref10" citeas="ISO/IEC 123"/></p>
806
- </clause>
807
- </sections><bibliography><clause id="_" obligation="informative"><title>Bibliography</title><references id="_" obligation="informative">
808
- <title>Clause 1</title><bibitem id="ref1" type="standard">
809
- <title format="text/plain">Standard ISO 123</title>
810
- <docidentifier>ISO 123</docidentifier>
811
- <contributor>
812
- <role type="publisher"/>
813
- <organization>
814
- <name>International Organization for Standardization</name>
815
- <abbreviation>ISO</abbreviation>
816
- </organization>
817
- </contributor>
818
- </bibitem>
819
- <bibitem id='ref2' type='standard'>
797
+ <sections>
798
+ <clause id='_' inline-header='false' obligation='normative'>
799
+ <title>Clause 1</title>
800
+ <p id='_'>
801
+ <eref type='inline' bibitemid='ref1' citeas='ISO 123'/>
802
+ <eref type='inline' bibitemid='ref1a' citeas='ISO 123-100'/>
803
+ <eref type='inline' bibitemid='ref1b' citeas='ISO/TS 123-1'/>
804
+ <eref type='inline' bibitemid='ref2' citeas='ISO/IEC 123'/>
805
+ <eref type='inline' bibitemid='ref3' citeas='IEC 123'/>
806
+ <eref type='inline' bibitemid='ref4' citeas='GB 123'/>
807
+ <eref type='inline' bibitemid='ref5' citeas='[6]'/>
808
+ <eref type='inline' bibitemid='ref6' citeas='[B]'/>
809
+ <eref type='inline' bibitemid='ref7' citeas='[A]'/>
810
+ <xref target='ref8'/>
811
+ <xref target='ref9'/>
812
+ <eref type='inline' bibitemid='ref10' citeas='ISO/IEC 123'/>
813
+ </p>
814
+ </clause>
815
+ </sections>
816
+ <bibliography>
817
+ <clause id='_' obligation='informative'>
818
+ <title>Bibliography</title>
819
+ <references id='_' obligation='informative'>
820
+ <title>Clause 1</title>
821
+ <bibitem id='ref1' type='standard'>
822
+ <title format='text/plain'>Standard ISO 123</title>
823
+ <docidentifier>ISO 123</docidentifier>
824
+ <docnumber>123</docnumber>
825
+ <contributor>
826
+ <role type='publisher'/>
827
+ <organization>
828
+ <name>International Organization for Standardization</name>
829
+ <abbreviation>ISO</abbreviation>
830
+ </organization>
831
+ </contributor>
832
+ </bibitem>
833
+ <bibitem id='ref2' type='standard'>
820
834
  <title format='text/plain'>Standard ISO/IEC 123</title>
821
835
  <docidentifier>ISO/IEC 123</docidentifier>
836
+ <docnumber>123</docnumber>
822
837
  <contributor>
823
838
  <role type='publisher'/>
824
839
  <organization>
@@ -834,140 +849,146 @@ RSpec.describe Asciidoctor::ISO do
834
849
  </organization>
835
850
  </contributor>
836
851
  </bibitem>
837
- <bibitem id='ref1b' type='standard'>
838
- <title format='text/plain'>Standard ISO 123</title>
839
- <docidentifier>ISO/TS 123-1</docidentifier>
840
- <contributor>
841
- <role type='publisher'/>
842
- <organization>
843
- <name>International Organization for Standardization</name>
844
- <abbreviation>ISO</abbreviation>
845
- </organization>
846
- </contributor>
847
- <contributor>
848
- <role type='publisher'/>
849
- <organization>
850
- <name>TS</name>
851
- </organization>
852
- </contributor>
853
- </bibitem>
854
- <bibitem id='ref1a' type='standard'>
855
- <title format='text/plain'>Standard ISO 123</title>
856
- <docidentifier>ISO 123-100</docidentifier>
857
- <contributor>
858
- <role type='publisher'/>
859
- <organization>
860
- <name>International Organization for Standardization</name>
861
- <abbreviation>ISO</abbreviation>
862
- </organization>
863
- </contributor>
864
- </bibitem>
865
- <bibitem id="ref3" type="standard">
866
- <title format="text/plain">Standard IEC 123</title>
867
- <docidentifier>IEC 123</docidentifier>
868
- <contributor>
869
- <role type="publisher"/>
870
- <organization>
871
- <name>International Electrotechnical Commission</name>
872
- <abbreviation>IEC</abbreviation>
873
- </organization>
874
- </contributor>
875
- </bibitem><bibitem id="ref5">
876
- <formattedref format="application/x-isodoc+xml">
877
- <em>Standard 10</em>
878
- </formattedref>
879
- <docidentifier type="metanorma">[6]</docidentifier>
880
- </bibitem><bibitem id="ref4">
881
- <formattedref format="application/x-isodoc+xml">
882
- <em>Standard GB 123</em>
883
- </formattedref>
884
- <docidentifier>GB 123</docidentifier>
885
- </bibitem><bibitem id="ref7">
886
- <formattedref format="application/x-isodoc+xml">
887
- <em>Standard 30</em>
888
- </formattedref>
889
- <docidentifier type="metanorma">[A]</docidentifier>
890
- </bibitem><bibitem id="ref6">
891
- <formattedref format="application/x-isodoc+xml">
892
- <em>Standard 20</em>
893
- </formattedref>
894
- <docidentifier type="metanorma">[B]</docidentifier>
895
- </bibitem>
896
-
897
-
898
-
899
-
900
-
901
-
902
-
903
- </references>
904
- <references id="_" obligation="informative">
905
- <bibitem id="ref11" type="standard">
906
- <title format="text/plain">Standard ISO 123</title>
907
- <docidentifier>ISO 123</docidentifier>
908
- <contributor>
909
- <role type="publisher"/>
910
- <organization>
911
- <name>International Organization for Standardization</name>
912
- <abbreviation>ISO</abbreviation>
913
- </organization>
914
- </contributor>
915
- </bibitem><bibitem id="ref10" type="standard">
916
- <title format="text/plain">Standard ISO/IEC 123</title>
917
- <docidentifier>ISO/IEC 123</docidentifier>
918
- <contributor>
919
- <role type="publisher"/>
920
- <organization>
921
- <name>International Organization for Standardization</name>
922
- <abbreviation>ISO</abbreviation>
923
- </organization>
924
- </contributor>
925
- <contributor>
926
- <role type="publisher"/>
927
- <organization>
928
- <name>International Electrotechnical Commission</name>
929
- <abbreviation>IEC</abbreviation>
930
- </organization>
931
- </contributor>
932
- </bibitem><bibitem id="ref13" type="standard">
933
- <title format="text/plain">Standard IEC 123</title>
934
- <docidentifier>IEC 123</docidentifier>
935
- <contributor>
936
- <role type="publisher"/>
937
- <organization>
938
- <name>International Electrotechnical Commission</name>
939
- <abbreviation>IEC</abbreviation>
940
- </organization>
941
- </contributor>
942
- </bibitem><bibitem id="ref15">
943
- <formattedref format="application/x-isodoc+xml">
944
- <em>Standard 10</em>
945
- </formattedref>
946
- <docidentifier type="metanorma">[13]</docidentifier>
947
- </bibitem><bibitem id="ref14">
948
- <formattedref format="application/x-isodoc+xml">
949
- <em>Standard GB 123</em>
950
- </formattedref>
951
- <docidentifier>GB 123</docidentifier>
952
- </bibitem><bibitem id="ref17">
953
- <formattedref format="application/x-isodoc+xml">
954
- <em>Standard 30</em>
955
- </formattedref>
956
- <docidentifier type="metanorma">[A]</docidentifier>
957
- </bibitem><bibitem id="ref16">
958
- <formattedref format="application/x-isodoc+xml">
959
- <em>Standard 20</em>
960
- </formattedref>
961
- <docidentifier type="metanorma">[B]</docidentifier>
962
- </bibitem>
963
-
964
-
965
-
966
-
967
-
968
-
969
-
970
- </references></clause></bibliography>
852
+ <bibitem id='ref1b' type='standard'>
853
+ <title format='text/plain'>Standard ISO 123</title>
854
+ <docidentifier>ISO/TS 123-1</docidentifier>
855
+ <docnumber>123-1</docnumber>
856
+ <contributor>
857
+ <role type='publisher'/>
858
+ <organization>
859
+ <name>International Organization for Standardization</name>
860
+ <abbreviation>ISO</abbreviation>
861
+ </organization>
862
+ </contributor>
863
+ <contributor>
864
+ <role type='publisher'/>
865
+ <organization>
866
+ <name>TS</name>
867
+ </organization>
868
+ </contributor>
869
+ </bibitem>
870
+ <bibitem id='ref1a' type='standard'>
871
+ <title format='text/plain'>Standard ISO 123</title>
872
+ <docidentifier>ISO 123-100</docidentifier>
873
+ <docnumber>123-100</docnumber>
874
+ <contributor>
875
+ <role type='publisher'/>
876
+ <organization>
877
+ <name>International Organization for Standardization</name>
878
+ <abbreviation>ISO</abbreviation>
879
+ </organization>
880
+ </contributor>
881
+ </bibitem>
882
+ <bibitem id='ref3' type='standard'>
883
+ <title format='text/plain'>Standard IEC 123</title>
884
+ <docidentifier>IEC 123</docidentifier>
885
+ <docnumber>123</docnumber>
886
+ <contributor>
887
+ <role type='publisher'/>
888
+ <organization>
889
+ <name>International Electrotechnical Commission</name>
890
+ <abbreviation>IEC</abbreviation>
891
+ </organization>
892
+ </contributor>
893
+ </bibitem>
894
+ <bibitem id='ref5'>
895
+ <formattedref format='application/x-isodoc+xml'>
896
+ <em>Standard 10</em>
897
+ </formattedref>
898
+ <docidentifier type='metanorma'>[6]</docidentifier>
899
+ </bibitem>
900
+ <bibitem id='ref6'>
901
+ <formattedref format='application/x-isodoc+xml'>
902
+ <em>Standard 20</em>
903
+ </formattedref>
904
+ <docidentifier type='metanorma'>[B]</docidentifier>
905
+ </bibitem>
906
+ <bibitem id='ref7'>
907
+ <formattedref format='application/x-isodoc+xml'>
908
+ <em>Standard 30</em>
909
+ </formattedref>
910
+ <docidentifier type='metanorma'>[A]</docidentifier>
911
+ </bibitem>
912
+ <bibitem id='ref4'>
913
+ <formattedref format='application/x-isodoc+xml'>
914
+ <em>Standard GB 123</em>
915
+ </formattedref>
916
+ <docidentifier>GB 123</docidentifier>
917
+ <docnumber>123</docnumber>
918
+ </bibitem>
919
+ </references>
920
+ <references id='_' obligation='informative'>
921
+ <bibitem id='ref11' type='standard'>
922
+ <title format='text/plain'>Standard ISO 123</title>
923
+ <docidentifier>ISO 123</docidentifier>
924
+ <docnumber>123</docnumber>
925
+ <contributor>
926
+ <role type='publisher'/>
927
+ <organization>
928
+ <name>International Organization for Standardization</name>
929
+ <abbreviation>ISO</abbreviation>
930
+ </organization>
931
+ </contributor>
932
+ </bibitem>
933
+ <bibitem id='ref10' type='standard'>
934
+ <title format='text/plain'>Standard ISO/IEC 123</title>
935
+ <docidentifier>ISO/IEC 123</docidentifier>
936
+ <docnumber>123</docnumber>
937
+ <contributor>
938
+ <role type='publisher'/>
939
+ <organization>
940
+ <name>International Organization for Standardization</name>
941
+ <abbreviation>ISO</abbreviation>
942
+ </organization>
943
+ </contributor>
944
+ <contributor>
945
+ <role type='publisher'/>
946
+ <organization>
947
+ <name>International Electrotechnical Commission</name>
948
+ <abbreviation>IEC</abbreviation>
949
+ </organization>
950
+ </contributor>
951
+ </bibitem>
952
+ <bibitem id='ref13' type='standard'>
953
+ <title format='text/plain'>Standard IEC 123</title>
954
+ <docidentifier>IEC 123</docidentifier>
955
+ <docnumber>123</docnumber>
956
+ <contributor>
957
+ <role type='publisher'/>
958
+ <organization>
959
+ <name>International Electrotechnical Commission</name>
960
+ <abbreviation>IEC</abbreviation>
961
+ </organization>
962
+ </contributor>
963
+ </bibitem>
964
+ <bibitem id='ref15'>
965
+ <formattedref format='application/x-isodoc+xml'>
966
+ <em>Standard 10</em>
967
+ </formattedref>
968
+ <docidentifier type='metanorma'>[13]</docidentifier>
969
+ </bibitem>
970
+ <bibitem id='ref16'>
971
+ <formattedref format='application/x-isodoc+xml'>
972
+ <em>Standard 20</em>
973
+ </formattedref>
974
+ <docidentifier type='metanorma'>[B]</docidentifier>
975
+ </bibitem>
976
+ <bibitem id='ref17'>
977
+ <formattedref format='application/x-isodoc+xml'>
978
+ <em>Standard 30</em>
979
+ </formattedref>
980
+ <docidentifier type='metanorma'>[A]</docidentifier>
981
+ </bibitem>
982
+ <bibitem id='ref14'>
983
+ <formattedref format='application/x-isodoc+xml'>
984
+ <em>Standard GB 123</em>
985
+ </formattedref>
986
+ <docidentifier>GB 123</docidentifier>
987
+ <docnumber>123</docnumber>
988
+ </bibitem>
989
+ </references>
990
+ </clause>
991
+ </bibliography>
971
992
  </iso-standard>
972
993
  OUTPUT
973
994
  end