isodoc 2.0.0.1 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cf2e2e18bcb28744fc2f4cf2525267935dc981281ab4642c7b0e57ea8b68b6d
4
- data.tar.gz: 12f9afbb69bd5e9903dd15ace22e5a3357520dfc8c58e4a316bc8e92a42e34bb
3
+ metadata.gz: 1a9645f7c8069398010a6b360e94069382fec990f4d8c2563e2c35ccde801b45
4
+ data.tar.gz: 3209942625f1f64ba90e9de9dfd1780de61368d227830cbdc36e65046697eb06
5
5
  SHA512:
6
- metadata.gz: b3996461e5a31740161f1bf08c0305b7e9faa229f263da26deaaf9fd50924c9cb39f2eaffacf4b6e69992a197d81c10b130a82b06d0c630917b3c22b34eca615
7
- data.tar.gz: 7c3a9fe8073d10c915e56f06bf973b6e7dfbd2e6296604598d93b90267496f74ebf5cbb2bcfd970eafafc0c808dc69e9273b0a1e1975a459e32993bfe0f57de6
6
+ metadata.gz: cdee63b9b9d3e2b0b4b4fa7b1dea74f5faa50c07d5ed3637744f5f52521821554513f3f4812bd57e5de9c0f6c61c4e73005be0d46127f39347f0f19e5912915c
7
+ data.tar.gz: 4d01286691c228c29100d79f78bb7f819a832fe05a730f56a8416422a1e59eb70c6a900242fb41fd631a63592600f3950e8dbe8079f1731754738a0aed8d6d4c
data/isodoc.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
30
30
 
31
31
  spec.add_dependency "asciimath"
32
- spec.add_dependency "html2doc", "~> 1.2.0"
32
+ spec.add_dependency "html2doc", "~> 1.3.0"
33
33
  spec.add_dependency "htmlentities", "~> 4.3.4"
34
34
  spec.add_dependency "liquid", "~> 4"
35
35
  # spec.add_dependency "metanorma", ">= 1.2.0"
@@ -49,10 +49,14 @@ module IsoDoc
49
49
  end
50
50
 
51
51
  def pref_ref_code(bib)
52
- bib.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
53
- "or @type = 'metanorma-ordinal' or "\
54
- "@type = 'ISSN' or @type = 'ISBN' or "\
55
- "@type = 'rfc-anchor')]"))
52
+ ret = bib.xpath(ns("./docidentifier[@primary = 'true']"))
53
+ ret.empty? and
54
+ ret = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
55
+ "@type = 'metanorma' "\
56
+ "or @type = 'metanorma-ordinal' or "\
57
+ "@type = 'ISSN' or @type = 'ISBN' or "\
58
+ "@type = 'rfc-anchor')]"))
59
+ ret
56
60
  end
57
61
 
58
62
  # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
@@ -78,10 +82,18 @@ module IsoDoc
78
82
  num
79
83
  end
80
84
 
81
- def unbracket(ident)
85
+ def unbracket1(ident)
82
86
  ident&.text&.sub(/^\[/, "")&.sub(/\]$/, "")
83
87
  end
84
88
 
89
+ def unbracket(ident)
90
+ if ident.respond_to?(:size)
91
+ ident.map { |x| unbracket1(x) }.join(" / ")
92
+ else
93
+ unbracket1(ident)
94
+ end
95
+ end
96
+
85
97
  def render_identifier(ident)
86
98
  { metanorma: bracket_if_num(ident[0]),
87
99
  sdo: unbracket(ident[1]),
@@ -54,11 +54,12 @@ module IsoDoc
54
54
  end
55
55
  end
56
56
 
57
+ # top level clause names
57
58
  def clause_name(_num, title, div, header_class)
59
+ preceding_floating_titles(title, div)
58
60
  header_class = {} if header_class.nil?
59
61
  div.h1 **attr_code(header_class) do |h1|
60
- if title.is_a?(String)
61
- h1 << title
62
+ if title.is_a?(String) then h1 << title
62
63
  else
63
64
  title&.children&.each { |c2| parse(c2, h1) }
64
65
  clause_parse_subtitle(title, h1)
@@ -68,6 +69,7 @@ module IsoDoc
68
69
  end
69
70
 
70
71
  def annex_name(_annex, name, div)
72
+ preceding_floating_titles(name, div)
71
73
  return if name.nil?
72
74
 
73
75
  div.h1 **{ class: "Annex" } do |t|
@@ -82,6 +84,18 @@ module IsoDoc
82
84
  node.children.each { |c| parse(c, p) }
83
85
  end
84
86
  end
87
+
88
+ def preceding_floating_titles(name, div)
89
+ return if name.nil? || name.is_a?(String)
90
+
91
+ out = name.parent.xpath("./preceding-sibling::*")
92
+ .reverse.each_with_object([]) do |p, m|
93
+ break m unless p.name == "p"
94
+
95
+ m << p
96
+ end or return
97
+ out.each { |c| parse(c, div) }
98
+ end
85
99
  end
86
100
  end
87
101
  end
@@ -128,6 +128,12 @@ module IsoDoc
128
128
 
129
129
  def table_long_strings_cleanup(docxml); end
130
130
 
131
+ def table_attrs(node)
132
+ ret = super
133
+ node.at(ns("./colgroup")) and ret[:style] += "table-layout:fixed;"
134
+ ret
135
+ end
136
+
131
137
  def image_parse(node, out, caption)
132
138
  if svg = node.at("./m:svg", "m" => "http://www.w3.org/2000/svg")
133
139
  svg_parse(svg, out)
@@ -69,7 +69,7 @@ module IsoDoc
69
69
  end
70
70
 
71
71
  def stage_abbr(docstatus)
72
- status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join("")
72
+ status_print(docstatus).split(/ /).map { |s| s[0].upcase }.join
73
73
  end
74
74
 
75
75
  def unpublished(status)
@@ -135,5 +135,29 @@ module IsoDoc
135
135
  elem.xpath(ns("./description")).each { |a| a.replace(a.children) }
136
136
  elem.replace(elem.children)
137
137
  end
138
+
139
+ def ol(docxml)
140
+ docxml.xpath(ns("//ol")).each do |f|
141
+ ol1(f)
142
+ end
143
+ @xrefs.list_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
144
+ end
145
+
146
+ # We don't really want users to specify type of ordered list;
147
+ # we will use by default a fixed hierarchy as practiced by ISO (though not
148
+ # fully spelled out): a) 1) i) A) I)
149
+ def ol_depth(node)
150
+ depth = node.ancestors("ul, ol").size + 1
151
+ type = :alphabet
152
+ type = :arabic if [2, 7].include? depth
153
+ type = :roman if [3, 8].include? depth
154
+ type = :alphabet_upper if [4, 9].include? depth
155
+ type = :roman_upper if [5, 10].include? depth
156
+ type
157
+ end
158
+
159
+ def ol1(elem)
160
+ elem["type"] ||= ol_depth(elem).to_s
161
+ end
138
162
  end
139
163
  end
@@ -65,15 +65,14 @@ module IsoDoc
65
65
  uri = svg_to_emf_uri(node)
66
66
  ret = svg_to_emf_filename(uri)
67
67
  File.exists?(ret) and return ret
68
- exe = inkscape_installed? or return nil
68
+ exe = inkscape_installed? or raise "Inkscape missing in PATH, unable" \
69
+ "to convert EMF to SVG. Aborting."
69
70
  uri = Metanorma::Utils::external_path uri
70
71
  exe = Metanorma::Utils::external_path exe
71
72
  system(%(#{exe} --export-type="emf" #{uri})) and
72
73
  return Metanorma::Utils::datauri(ret)
73
74
 
74
- warn %(Fail on #{exe} --export-type="emf" #{uri})
75
-
76
- nil
75
+ raise %(Fail on #{exe} --export-type="emf" #{uri})
77
76
  end
78
77
 
79
78
  def svg_to_emf_uri(node)
@@ -69,7 +69,8 @@ module IsoDoc
69
69
  c1 = non_locality_elems(node).select { |c| !c.text? || /\S/.match(c) }
70
70
  return unless c1.empty?
71
71
 
72
- link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
72
+ link = anchor_linkend(node, docid_l10n(node["target"] ||
73
+ expand_citeas(node["citeas"])))
73
74
  link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
74
75
  link, node)
75
76
  non_locality_elems(node).each(&:remove)
@@ -78,6 +79,11 @@ module IsoDoc
78
79
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
79
80
  # <locality type="section"><reference>3.1</reference></locality></origin>
80
81
 
82
+ def expand_citeas(text)
83
+ text.nil? and return text
84
+ HTMLEntities.new.decode(text.gsub(/&amp;#x/, "&#"))
85
+ end
86
+
81
87
  def eref_localities(refs, target, node)
82
88
  ret = ""
83
89
  refs.each_with_index do |r, i|
@@ -26,6 +26,8 @@ module IsoDoc
26
26
  .each do |f|
27
27
  floattitle1(f)
28
28
  end
29
+ # top-level
30
+ docxml.xpath(ns("//sections | //preface")).each { |f| floattitle1(f) }
29
31
  end
30
32
 
31
33
  def floattitle1(elem)
@@ -50,6 +50,7 @@ module IsoDoc
50
50
  formula docxml
51
51
  example docxml
52
52
  note docxml
53
+ ol docxml
53
54
  permission docxml
54
55
  requirement docxml
55
56
  recommendation docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.0.0.1".freeze
2
+ VERSION = "2.0.4".freeze
3
3
  end
@@ -925,87 +925,23 @@ RSpec.describe IsoDoc do
925
925
  .to receive(:inkscape_installed?)
926
926
 
927
927
  input = <<~INPUT
928
- <iso-standard xmlns="http://riboseinc.com/isoxml">
929
- <preface><foreword>
930
- <figure id="figureA-1">
931
- <image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
932
- <image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
933
- <image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
934
- </figure>
935
- </foreword></preface>
936
- </iso-standard>
937
- INPUT
938
- presxml = <<~OUTPUT
939
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
928
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
940
929
  <preface>
941
- <foreword displayorder='1'>
942
- <figure id='figureA-1'>
943
- <name>Figure 1</name>
944
- <image src='spec/assets/odf.svg' mimetype='image/svg+xml'>
945
- <emf src='spec/assets/odf.emf'/>
946
- </image>
947
- <image src='spec/assets/odf1.svg' mimetype='image/svg+xml'/>
948
- <image src='' id='_d3731866-1a07-435a-a6c2-1acd41023a4e' mimetype='image/svg+xml' height='auto' width='auto'>
949
- <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>
950
- <circle fill='#009' r='45' cx='50' cy='50'/>
951
- <path d='M33,26H78A37,37,0,0,1,33,83V57H59V43H33Z' fill='#FFF'/>
952
- </svg>
953
- </image>
930
+ <foreword>
931
+ <figure id="figureA-1">
932
+ <image src="spec/assets/odf.svg" mimetype="image/svg+xml"/>
933
+ <image src="spec/assets/odf1.svg" mimetype="image/svg+xml"/>
934
+ <image src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICA8Y2lyY2xlIGZpbGw9IiMwMDkiIHI9IjQ1IiBjeD0iNTAiIGN5PSI1MCIvPgogIDxwYXRoIGQ9Ik0zMywyNkg3OEEzNywzNywwLDAsMSwzMyw4M1Y1N0g1OVY0M0gzM1oiIGZpbGw9IiNGRkYiLz4KPC9zdmc+Cg==" id="_d3731866-1a07-435a-a6c2-1acd41023a4e" mimetype="image/svg+xml" height="auto" width="auto"/>
954
935
  </figure>
955
936
  </foreword>
956
937
  </preface>
957
938
  </iso-standard>
958
- OUTPUT
959
- output = <<~OUTPUT
960
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
961
- <head>
962
- <style>
963
- </style>
964
- </head>
965
- <body lang='EN-US' link='blue' vlink='#954F72'>
966
- <div class='WordSection1'>
967
- <p>&#160;</p>
968
- </div>
969
- <p>
970
- <br clear='all' class='section'/>
971
- </p>
972
- <div class='WordSection2'>
973
- <p>
974
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
975
- </p>
976
- <div>
977
- <h1 class='ForewordTitle'>Foreword</h1>
978
- <div id='figureA-1' class='figure'>
979
- <img src='spec/assets/odf.emf'/>
980
- <img src='spec/assets/odf1.svg'/>
981
- <img src='' height='auto' width='auto'/>
982
- <p class='FigureTitle' style='text-align:center;'>Figure 1</p>
983
- </div>
984
- </div>
985
- <p>&#160;</p>
986
- </div>
987
- <p>
988
- <br clear='all' class='section'/>
989
- </p>
990
- <div class='WordSection3'>
991
- <p class='zzSTDTitle1'/>
992
- </div>
993
- </body>
994
- </html>
995
- OUTPUT
996
- expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
997
- .convert("test", input, true)
998
- .gsub(/&lt;/, "&#x3c;")
999
- .gsub(%r{data:application/x-msmetafile[^"']+},
1000
- "data:application/x-msmetafile")))
1001
- .to be_equivalent_to xmlpp(presxml
1002
- .gsub(%r{data:application/x-msmetafile[^"']+},
1003
- "data:application/x-msmetafile"))
1004
- expect(xmlpp(strip_guid(IsoDoc::WordConvert.new({})
1005
- .convert("test", presxml, true)
1006
- .gsub(/['"][^'".]+(?<!odf1)(?<!odf)\.svg['"]/, "'_.svg'")
1007
- .gsub(/mso-bookmark:_Ref\d+/, "mso-bookmark:_Ref"))))
1008
- .to be_equivalent_to xmlpp(output)
939
+ INPUT
940
+ expect do
941
+ IsoDoc::PresentationXMLConvert.new({})
942
+ .convert("test", input, true)
943
+ end.to raise_error("Inkscape missing in PATH, unable" \
944
+ "to convert EMF to SVG. Aborting.")
1009
945
  end
1010
946
  end
1011
947
 
@@ -1782,4 +1782,41 @@ RSpec.describe IsoDoc do
1782
1782
  expect(xmlpp(IsoDoc::HtmlConvert.new({})
1783
1783
  .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1784
1784
  end
1785
+
1786
+ it "processes formatting in eref/@citeas" do
1787
+ input = <<~INPUT
1788
+ <itu-standard xmlns="https://www.calconnect.org/standards/itu">
1789
+ <preface>
1790
+ <foreword id='_' obligation='informative'>
1791
+ <title>Foreword</title>
1792
+ <p id='_'>
1793
+ <eref type='inline' bibitemid='iso124' citeas='[&amp;#x3c;strong&amp;#x3e;A&amp;#x3c;/strong&amp;#x3e;.&amp;#x3c;fn reference=&amp;#x22;1&amp;#x22;&amp;#x3e;&amp;#xa; &amp;#x3c;p&amp;#x3e;hello&amp;#x3c;/p&amp;#x3e;&amp;#xa;&amp;#x3c;/fn&amp;#x3e;]'/>
1794
+ </p>
1795
+ </foreword>
1796
+ </preface>
1797
+ </itu-standard>
1798
+ INPUT
1799
+ output = <<~OUTPUT
1800
+ <itu-standard xmlns='https://www.calconnect.org/standards/itu' type='presentation'>
1801
+ <preface>
1802
+ <foreword id='_' obligation='informative' displayorder='1'>
1803
+ <title>Foreword</title>
1804
+ <p id='_'>
1805
+ <eref type='inline' bibitemid='iso124' citeas='[&amp;#x3c;strong&amp;#x3e;A&amp;#x3c;/strong&amp;#x3e;.&amp;#x3c;fn reference=&amp;#x22;1&amp;#x22;&amp;#x3e;&amp;#xa; &amp;#x3c;p&amp;#x3e;hello&amp;#x3c;/p&amp;#x3e;&amp;#xa;&amp;#x3c;/fn&amp;#x3e;]'>
1806
+ [
1807
+ <strong>A</strong>
1808
+ .
1809
+ <fn reference='1'>
1810
+ <p>hello</p>
1811
+ </fn>
1812
+ ]
1813
+ </eref>
1814
+ </p>
1815
+ </foreword>
1816
+ </preface>
1817
+ </itu-standard>
1818
+ OUTPUT
1819
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1820
+ .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1821
+ end
1785
1822
  end
@@ -844,84 +844,84 @@ RSpec.describe IsoDoc do
844
844
  </html>
845
845
  OUTPUT
846
846
  doc = <<~OUTPUT
847
- <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
848
- <head>
849
- <style>
850
- </style>
851
- </head>
852
- <body lang='EN-US' link='blue' vlink='#954F72'>
853
- <div class='WordSection1'>
854
- <p>&#160;</p>
855
- </div>
856
- <p>
857
- <br clear='all' class='section'/>
858
- </p>
859
- <div class='WordSection2'>
860
- <p>&#160;</p>
861
- </div>
862
- <p>
863
- <br clear='all' class='section'/>
864
- </p>
865
- <div class='WordSection3'>
866
- <p class='zzSTDTitle1'/>
867
- <div id='_'>
868
- <h1>
869
- <b>Annex A</b>
870
- <br/>
871
- (normative).
872
- <span style='mso-tab-count:1'>&#160; </span>
873
- Clause
874
- </h1>
875
- <p id='_'>Text</p>
876
- <div id='_'>
877
- <h1>
878
- <b>Annex A</b>
879
- <br/>
880
- (normative).
881
- <span style='mso-tab-count:1'>&#160; </span>
882
- Subclause
883
- <br/>
884
- <br/>
885
- &#8220;A&#8221; &#8216;B&#8217;
886
- </h1>
887
- <p style='display:none;' class='variant-title-toc'>
888
- Clause
889
- <i>A</i>
890
- <span class='stem'>
891
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
892
- <mi>x</mi>
893
- </math>
894
- </span>
895
- </p>
896
- <p id='_'>Text</p>
897
- </div>
898
- </div>
899
- <p>
900
- <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
901
- </p>
902
- <div id='_' class='Section3'>
903
- <h1 class='Annex'>
904
- <b>Annex A</b>
905
- <br/>
906
- (normative)
907
- <br/>
908
- <br/>
909
- <b>Clause</b>
910
- </h1>
911
- <p style='display:none;' class='variant-title-toc'>
912
- Clause
913
- <i>A</i>
914
- <span class='stem'>
915
- <math xmlns='http://www.w3.org/1998/Math/MathML'>
916
- <mi>x</mi>
917
- </math>
918
- </span>
919
- </p>
920
- <p id='_'>Text</p>
921
- </div>
922
- </div>
923
- </body>
924
- </html>
847
+ <html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
848
+ <head>
849
+ <style>
850
+ </style>
851
+ </head>
852
+ <body lang='EN-US' link='blue' vlink='#954F72'>
853
+ <div class='WordSection1'>
854
+ <p>&#160;</p>
855
+ </div>
856
+ <p>
857
+ <br clear='all' class='section'/>
858
+ </p>
859
+ <div class='WordSection2'>
860
+ <p>&#160;</p>
861
+ </div>
862
+ <p>
863
+ <br clear='all' class='section'/>
864
+ </p>
865
+ <div class='WordSection3'>
866
+ <p class='zzSTDTitle1'/>
867
+ <div id='_'>
868
+ <h1>
869
+ <b>Annex A</b>
870
+ <br/>
871
+ (normative).
872
+ <span style='mso-tab-count:1'>&#160; </span>
873
+ Clause
874
+ </h1>
875
+ <p id='_'>Text</p>
876
+ <div id='_'>
877
+ <h1>
878
+ <b>Annex A</b>
879
+ <br/>
880
+ (normative).
881
+ <span style='mso-tab-count:1'>&#160; </span>
882
+ Subclause
883
+ <br/>
884
+ <br/>
885
+ &#8220;A&#8221; &#8216;B&#8217;
886
+ </h1>
887
+ <p style='display:none;' class='variant-title-toc'>
888
+ Clause
889
+ <i>A</i>
890
+ <span class='stem'>
891
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
892
+ <mi>x</mi>
893
+ </math>
894
+ </span>
895
+ </p>
896
+ <p id='_'>Text</p>
897
+ </div>
898
+ </div>
899
+ <p>
900
+ <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
901
+ </p>
902
+ <div id='_' class='Section3'>
903
+ <h1 class='Annex'>
904
+ <b>Annex A</b>
905
+ <br/>
906
+ (normative)
907
+ <br/>
908
+ <br/>
909
+ <b>Clause</b>
910
+ </h1>
911
+ <p style='display:none;' class='variant-title-toc'>
912
+ Clause
913
+ <i>A</i>
914
+ <span class='stem'>
915
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
916
+ <mi>x</mi>
917
+ </math>
918
+ </span>
919
+ </p>
920
+ <p id='_'>Text</p>
921
+ </div>
922
+ </div>
923
+ </body>
924
+ </html>
925
925
  OUTPUT
926
926
  expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
927
927
  .convert("test", input, true))
@@ -993,6 +993,169 @@ RSpec.describe IsoDoc do
993
993
  .to be_equivalent_to (output)
994
994
  end
995
995
 
996
+ it "adds types to ordered lists" do
997
+ input = <<~INPUT
998
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
999
+ <bibdata/>
1000
+ <sections>
1001
+ <clause id='A' inline-header='false' obligation='normative'>
1002
+ <title>Clause</title>
1003
+ <ol id="B1">
1004
+ <li>A1
1005
+ <ol id="B2">
1006
+ <li>A2
1007
+ <ol id="B3">
1008
+ <li>A3
1009
+ <ol id="B4">
1010
+ <li>A4
1011
+ <ol id="B5">
1012
+ <li>A5
1013
+ <ol id="B6">
1014
+ <li>A6
1015
+ <ol id="B7">
1016
+ <li>A7
1017
+ <ol id="B8">
1018
+ <li>A8
1019
+ <ol id="B9">
1020
+ <li>A9
1021
+ <ol id="B0">
1022
+ <li>A0</li>
1023
+ </ol></li>
1024
+ </ol></li>
1025
+ </ol></li>
1026
+ </ol></li>
1027
+ </ol></li>
1028
+ </ol></li>
1029
+ </ol></li>
1030
+ </ol></li>
1031
+ </ol></li>
1032
+ </ol>
1033
+ </clause>
1034
+ </sections>
1035
+ </iso-standard>#{' '}
1036
+ INPUT
1037
+ presxml = <<~OUTPUT
1038
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1039
+ <bibdata/>
1040
+ <sections>
1041
+ <clause id='A' inline-header='false' obligation='normative' displayorder='1'>
1042
+ <title depth='1'>
1043
+ 1.
1044
+ <tab/>
1045
+ Clause
1046
+ </title>
1047
+ <ol id='B1' type='alphabet'>
1048
+ <li>
1049
+ A1
1050
+ <ol id='B2' type='arabic'>
1051
+ <li>
1052
+ A2
1053
+ <ol id='B3' type='roman'>
1054
+ <li>
1055
+ A3
1056
+ <ol id='B4' type='alphabet_upper'>
1057
+ <li>
1058
+ A4
1059
+ <ol id='B5' type='roman_upper'>
1060
+ <li>
1061
+ A5
1062
+ <ol id='B6' type='alphabet'>
1063
+ <li>
1064
+ A6
1065
+ <ol id='B7' type='arabic'>
1066
+ <li>
1067
+ A7
1068
+ <ol id='B8' type='roman'>
1069
+ <li>
1070
+ A8
1071
+ <ol id='B9' type='alphabet_upper'>
1072
+ <li>
1073
+ A9
1074
+ <ol id='B0' type='roman_upper'>
1075
+ <li>A0</li>
1076
+ </ol>
1077
+ </li>
1078
+ </ol>
1079
+ </li>
1080
+ </ol>
1081
+ </li>
1082
+ </ol>
1083
+ </li>
1084
+ </ol>
1085
+ </li>
1086
+ </ol>
1087
+ </li>
1088
+ </ol>
1089
+ </li>
1090
+ </ol>
1091
+ </li>
1092
+ </ol>
1093
+ </li>
1094
+ </ol>
1095
+ </clause>
1096
+ </sections>
1097
+ </iso-standard>
1098
+ OUTPUT
1099
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1100
+ .convert("test", input, true))
1101
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
1102
+ .to be_equivalent_to xmlpp(presxml)
1103
+ end
1104
+
1105
+ it "considers ul when adding types to ordered lists" do
1106
+ input = <<~INPUT
1107
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
1108
+ <bibdata/>
1109
+ <sections>
1110
+ <clause id='A' inline-header='false' obligation='normative'>
1111
+ <title>Clause</title>
1112
+ <ol id="B1">
1113
+ <li>A1
1114
+ <ul id="B2">
1115
+ <li>A2
1116
+ <ol id="B3">
1117
+ <li>A3
1118
+ </ol></li>
1119
+ </ul></li>
1120
+ </ol>
1121
+ </clause>
1122
+ </sections>
1123
+ </iso-standard>
1124
+ INPUT
1125
+ presxml = <<~OUTPUT
1126
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1127
+ <bibdata/>
1128
+
1129
+ <sections>
1130
+ <clause id='A' inline-header='false' obligation='normative' displayorder='1'>
1131
+ <title depth='1'>
1132
+ 1.
1133
+ <tab/>
1134
+ Clause
1135
+ </title>
1136
+ <ol id='B1' type='alphabet'>
1137
+ <li>
1138
+ A1
1139
+ <ul id='B2'>
1140
+ <li>
1141
+ A2
1142
+ <ol id='B3' type='roman'>
1143
+ <li>A3 </li>
1144
+ </ol>
1145
+ </li>
1146
+ </ul>
1147
+ </li>
1148
+ </ol>
1149
+ </clause>
1150
+ </sections>
1151
+ </iso-standard>
1152
+ OUTPUT
1153
+ expect(xmlpp(IsoDoc::PresentationXMLConvert.new({})
1154
+ .convert("test", input, true))
1155
+ .sub(%r{<localized-strings>.*</localized-strings>}m, ""))
1156
+ .to be_equivalent_to xmlpp(presxml)
1157
+ end
1158
+
996
1159
  private
997
1160
 
998
1161
  def mock_symbols
@@ -654,8 +654,9 @@ RSpec.describe IsoDoc do
654
654
  </body>
655
655
  </html>
656
656
  OUTPUT
657
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml,
658
- true))).to be_equivalent_to xmlpp(html)
657
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
658
+ .convert("test", presxml, true)))
659
+ .to be_equivalent_to xmlpp(html)
659
660
  end
660
661
 
661
662
  it "processes hidden references sections in Relaton bibliographies" do
@@ -766,7 +767,91 @@ RSpec.describe IsoDoc do
766
767
  </body>
767
768
  </html>
768
769
  OUTPUT
769
- expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml,
770
- true))).to be_equivalent_to xmlpp(html)
770
+ expect(xmlpp(IsoDoc::HtmlConvert.new({})
771
+ .convert("test", presxml, true)))
772
+ .to be_equivalent_to xmlpp(html)
773
+ end
774
+
775
+ it "selects the primary identifier" do
776
+ input = <<~INPUT
777
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
778
+ <bibdata>
779
+ <language>en</language>
780
+ </bibdata>
781
+ <preface><foreword>
782
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
783
+ <eref bibitemid="ISO712"/>
784
+ </p>
785
+ </foreword></preface>
786
+ <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
787
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
788
+ <bibitem id="ISO712" type="standard">
789
+ <title format="text/plain">Cereals or cereal products</title>
790
+ <title type="main" format="text/plain">Cereals and cereal products</title>
791
+ <docidentifier type="ISO">ISO 712</docidentifier>
792
+ <docidentifier type="IEC" primary="true">IEC 217</docidentifier>
793
+ <contributor>
794
+ <role type="publisher"/>
795
+ <organization>
796
+ <name>International Organization for Standardization</name>
797
+ </organization>
798
+ </contributor>
799
+ </bibitem>
800
+ </references></bibliography></iso-standard>
801
+ INPUT
802
+ presxml = <<~PRESXML
803
+ <foreword displayorder='1'>
804
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
805
+ <eref bibitemid='ISO712'>IEC 217</eref>
806
+ </p>
807
+ </foreword>
808
+ PRESXML
809
+ expect(xmlpp(Nokogiri::XML(
810
+ IsoDoc::PresentationXMLConvert.new({})
811
+ .convert("test", input, true),
812
+ ).at("//xmlns:foreword").to_xml))
813
+ .to be_equivalent_to xmlpp(presxml)
814
+ end
815
+
816
+ it "selects multiple primary identifiers" do
817
+ input = <<~INPUT
818
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
819
+ <bibdata>
820
+ <language>en</language>
821
+ </bibdata>
822
+ <preface><foreword>
823
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
824
+ <eref bibitemid="ISO712"/>
825
+ </p>
826
+ </foreword></preface>
827
+ <bibliography><references id="_normative_references" obligation="informative" normative="true"><title>Normative References</title>
828
+ <p>The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.</p>
829
+ <bibitem id="ISO712" type="standard">
830
+ <title format="text/plain">Cereals or cereal products</title>
831
+ <title type="main" format="text/plain">Cereals and cereal products</title>
832
+ <docidentifier type="ISO" primary="true">ISO 712</docidentifier>
833
+ <docidentifier type="IEC" primary="true">IEC 217</docidentifier>
834
+ <contributor>
835
+ <role type="publisher"/>
836
+ <organization>
837
+ <name>International Organization for Standardization</name>
838
+ </organization>
839
+ </contributor>
840
+ </bibitem>
841
+ </references></bibliography></iso-standard>
842
+ INPUT
843
+ presxml = <<~PRESXML
844
+ <foreword displayorder='1'>
845
+ <p id='_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f'>
846
+ <eref bibitemid='ISO712'>ISO 712&#xA0;/ IEC 217</eref>
847
+ </p>
848
+ </foreword>
849
+ PRESXML
850
+ expect(xmlpp(Nokogiri::XML(
851
+ IsoDoc::PresentationXMLConvert.new({})
852
+ .convert("test", input, true),
853
+ ).at("//xmlns:foreword").to_xml))
854
+ .to be_equivalent_to xmlpp(presxml)
771
855
  end
856
+
772
857
  end
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe IsoDoc do
4
+ =begin
4
5
  it "processes prefatory blocks" do
5
6
  input = <<~INPUT
6
7
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -1495,11 +1496,12 @@ RSpec.describe IsoDoc do
1495
1496
  .new({ suppressheadingnumbers: true })
1496
1497
  .convert("test", input, true))).to be_equivalent_to xmlpp(output)
1497
1498
  end
1498
-
1499
+ =end
1499
1500
  it "processes floating titles" do
1500
1501
  input = <<~INPUT
1501
1502
  <iso-standard xmlns="http://riboseinc.com/isoxml">
1502
1503
  <preface>
1504
+ <floating-title depth="1">A0</p>
1503
1505
  <introduction id="B" obligation="informative">
1504
1506
  <title>Introduction</title>
1505
1507
  <floating-title depth="1">A</p>
@@ -1513,18 +1515,35 @@ RSpec.describe IsoDoc do
1513
1515
  </clause>
1514
1516
  </introduction>
1515
1517
  </preface>
1518
+ <sections>
1519
+ <clause id="C" obligation="informative">
1520
+ <title>Introduction</title>
1521
+ <floating-title depth="1">A</p>
1522
+ <clause id="C1" obligation="informative">
1523
+ <title>Introduction Subsection</title>
1524
+ <floating-title depth="2">B</p>
1525
+ <clause id="C2" obligation="informative">
1526
+ <title>Introduction Sub-subsection</title>
1527
+ <floating-title depth="1">C</p>
1528
+ </clause>
1529
+ </clause>
1530
+ </clause>
1531
+ <floating-title depth="1">D</p>
1532
+ <clause id="C4"><title>Clause 2</title></clause>
1533
+ </sections>
1516
1534
  </iso-standard>
1517
1535
  INPUT
1518
1536
 
1519
1537
  presxml = <<~PRESXML
1520
- <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1538
+ <iso-standard xmlns='http://riboseinc.com/isoxml' type='presentation'>
1521
1539
  <preface>
1522
- <introduction id='B' obligation='informative' displayorder='1'>
1540
+ <p depth='1' type='floating-title' displayorder='1'>A0</p>
1541
+ <introduction id='B' obligation='informative' displayorder='2'>
1523
1542
  <title>Introduction</title>
1524
1543
  <p depth='1' type='floating-title'>A</p>
1525
1544
  <clause id='B1' obligation='informative'>
1526
1545
  <title depth='2'>Introduction Subsection</title>
1527
- <p type='floating-title' depth="2">B</p>
1546
+ <p depth='2' type='floating-title'>B</p>
1528
1547
  <clause id='B2' obligation='informative'>
1529
1548
  <title depth='3'>Introduction Sub-subsection</title>
1530
1549
  <p depth='1' type='floating-title'>C</p>
@@ -1532,13 +1551,49 @@ RSpec.describe IsoDoc do
1532
1551
  </clause>
1533
1552
  </introduction>
1534
1553
  </preface>
1554
+ <sections>
1555
+ <clause id='C' obligation='informative' displayorder='3'>
1556
+ <title depth='1'>
1557
+ 1.
1558
+ <tab/>
1559
+ Introduction
1560
+ </title>
1561
+ <p depth='1' type='floating-title'>A</p>
1562
+ <clause id='C1' obligation='informative'>
1563
+ <title depth='2'>
1564
+ 1.1.
1565
+ <tab/>
1566
+ Introduction Subsection
1567
+ </title>
1568
+ <p depth='2' type='floating-title'>B</p>
1569
+ <clause id='C2' obligation='informative'>
1570
+ <title depth='3'>
1571
+ 1.1.1.
1572
+ <tab/>
1573
+ Introduction Sub-subsection
1574
+ </title>
1575
+ <p depth='1' type='floating-title'>C</p>
1576
+ </clause>
1577
+ </clause>
1578
+ </clause>
1579
+ <p depth='1' type='floating-title'>D</p>
1580
+ <clause id='C4' displayorder='4'>
1581
+ <title depth='1'>
1582
+ 2.
1583
+ <tab/>
1584
+ Clause 2
1585
+ </title>
1586
+ </clause>
1587
+ </sections>
1535
1588
  </iso-standard>
1536
1589
  PRESXML
1537
1590
 
1538
1591
  html = <<~OUTPUT
1539
1592
  #{HTML_HDR}
1593
+ <p class='h1'>A0</p>
1540
1594
  <br/>
1541
1595
  <div class='Section3' id='B'>
1596
+ <p class='h1'>A0</p>
1542
1597
  <h1 class='IntroTitle'>Introduction</h1>
1543
1598
  <p class='h1'>A</p>
1544
1599
  <div id='B1'>
@@ -1551,6 +1606,22 @@ RSpec.describe IsoDoc do
1551
1606
  </div>
1552
1607
  </div>
1553
1608
  <p class='zzSTDTitle1'/>
1609
+ <div id='C'>
1610
+ <h1> 1. &#160; Introduction </h1>
1611
+ <p class='h1'>A</p>
1612
+ <div id='C1'>
1613
+ <h2> 1.1. &#160; Introduction Subsection </h2>
1614
+ <p class='h2'>B</p>
1615
+ <div id='C2'>
1616
+ <h3> 1.1.1. &#160; Introduction Sub-subsection </h3>
1617
+ <p class='h1'>C</p>
1618
+ </div>
1619
+ </div>
1620
+ </div>
1621
+ <div id='C4'>
1622
+ <p class='h1'>D</p>
1623
+ <h1> 2. &#160; Clause 2 </h1>
1624
+ </div>
1554
1625
  </div>
1555
1626
  </body>
1556
1627
  </html>
@@ -1569,10 +1640,12 @@ RSpec.describe IsoDoc do
1569
1640
  <br clear='all' class='section'/>
1570
1641
  </p>
1571
1642
  <div class='WordSection2'>
1643
+ <p>A0</p>
1572
1644
  <p>
1573
1645
  <br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
1574
1646
  </p>
1575
1647
  <div class='Section3' id='B'>
1648
+ <p>A0</p>
1576
1649
  <h1 class='IntroTitle'>Introduction</h1>
1577
1650
  <p>A</p>
1578
1651
  <div id='B1'>
@@ -1591,6 +1664,38 @@ RSpec.describe IsoDoc do
1591
1664
  </p>
1592
1665
  <div class='WordSection3'>
1593
1666
  <p class='zzSTDTitle1'/>
1667
+ <div id='C'>
1668
+ <h1>
1669
+ 1.
1670
+ <span style='mso-tab-count:1'>&#160; </span>
1671
+ Introduction
1672
+ </h1>
1673
+ <p>A</p>
1674
+ <div id='C1'>
1675
+ <h2>
1676
+ 1.1.
1677
+ <span style='mso-tab-count:1'>&#160; </span>
1678
+ Introduction Subsection
1679
+ </h2>
1680
+ <p>B</p>
1681
+ <div id='C2'>
1682
+ <h3>
1683
+ 1.1.1.
1684
+ <span style='mso-tab-count:1'>&#160; </span>
1685
+ Introduction Sub-subsection
1686
+ </h3>
1687
+ <p>C</p>
1688
+ </div>
1689
+ </div>
1690
+ </div>
1691
+ <div id='C4'>
1692
+ <p>D</p>
1693
+ <h1>
1694
+ 2.
1695
+ <span style='mso-tab-count:1'>&#160; </span>
1696
+ Clause 2
1697
+ </h1>
1698
+ </div>
1594
1699
  </div>
1595
1700
  </body>
1596
1701
  </html>
@@ -174,7 +174,7 @@ RSpec.describe IsoDoc do
174
174
  <sup>1</sup>
175
175
  </a>
176
176
  </p>
177
- <table id="tableD-1" class="MsoISOTable" style="border-width:1px;border-spacing:0;width:70%;page-break-after: avoid;page-break-inside: avoid;" title="tool tip" >
177
+ <table id="tableD-1" class="MsoISOTable" style="border-width:1px;border-spacing:0;width:70%;page-break-after: avoid;page-break-inside: avoid;table-layout:fixed;" title="tool tip" >
178
178
  <caption>
179
179
  <span style="display:none">long desc</span>
180
180
  </caption>
@@ -2504,6 +2504,8 @@ RSpec.describe IsoDoc do
2504
2504
  <foreword>
2505
2505
  <p>
2506
2506
  <xref target="N1"/>
2507
+ <xref target="N11"/>
2508
+ <xref target="N12"/>
2507
2509
  <xref target="N2"/>
2508
2510
  <xref target="N"/>
2509
2511
  <xref target="note1"/>
@@ -2515,8 +2517,13 @@ RSpec.describe IsoDoc do
2515
2517
  </foreword>
2516
2518
  <introduction id="intro">
2517
2519
  <ol id="N01">
2518
- <li id="N1"><p>A</p></li>
2519
- </ol>
2520
+ <li id="N1"><p>A</p>
2521
+ <ol id="N011">
2522
+ <li id="N11"><p>A</p>
2523
+ <ol id="N012">
2524
+ <li id="N12"><p>A</p>
2525
+ </li>
2526
+ </ol></li></ol></li></ol>
2520
2527
  <clause id="xyz"><title>Preparatory</title>
2521
2528
  <ol id="N02" type="arabic">
2522
2529
  <li id="N2"><p>A</p></li>
@@ -2563,6 +2570,8 @@ RSpec.describe IsoDoc do
2563
2570
  <foreword displayorder='1'>
2564
2571
  <p>
2565
2572
  <xref target='N1'>Introduction, a)</xref>
2573
+ <xref target='N11'>Introduction, a.1)</xref>
2574
+ <xref target='N12'>Introduction, a.1.i)</xref>
2566
2575
  <xref target='N2'>Preparatory, 1)</xref>
2567
2576
  <xref target='N'>Clause 1, i)</xref>
2568
2577
  <xref target='note1'>Clause 3.1, List 1 a)</xref>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isodoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.1
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-10 00:00:00.000000000 Z
11
+ date: 2022-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2.0
33
+ version: 1.3.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.2.0
40
+ version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: htmlentities
43
43
  requirement: !ruby/object:Gem::Requirement