isodoc 2.0.0 → 2.0.3

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: 94378642fdbff3fdfd64fc15d3f502fd3ac966926d19b060c5b7bbd4b9f9e545
4
- data.tar.gz: eeb1da05b0df09ea66cd55692f3d2f706991904216c5869025b9d936dc93cf12
3
+ metadata.gz: 645650786b21ed611b894e1e0f2be09efbb300f62997e021d331168b32488699
4
+ data.tar.gz: 9dc2ae2007b764bf33f2d406c55a666533f411e057a22eb58bb9b90cb279fe09
5
5
  SHA512:
6
- metadata.gz: b8164bf9d471f1b409ff4c0d933f69b9f834d340548caf3b441d7ca4584460b026420bb752903121561d573f8ddc618e5796d5e22dd09c1a9f3ca429cf567df5
7
- data.tar.gz: 75a73a94378f4d0fe6187b343d84961265e60d1417d23c43c38b11c819190cba0838dd0a99ba21d7e49824add339f7a6007c42748f87130a7abd2ce35d14105b
6
+ metadata.gz: f70dccf7ad11c7563a0ed9dad4d7c90b9ca104ca3c46ffbd290544cc31206a9dce2597acafd01a4a5f8ff84c433d430d06c27b96b5b961a76cbe22d204fbc629
7
+ data.tar.gz: e000fe9d824d2e8825d1656d52395120373a6e6d40386ca67802337174e3dfaa762d8a3573b21f3418efeaecc81cc9350e0f6ac84024e6b235a8aebb4324f3d5
data/Gemfile CHANGED
@@ -10,4 +10,3 @@ if File.exist? "Gemfile.devel"
10
10
  eval File.read("Gemfile.devel"), nil, "Gemfile.devel" # rubocop:disable Security/Eval
11
11
  end
12
12
 
13
- gem "reline", "~> 0.2.8.pre.11"
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]),
@@ -98,7 +110,7 @@ module IsoDoc
98
110
  def omit_docid_prefix(prefix)
99
111
  return true if prefix.nil? || prefix.empty?
100
112
 
101
- %w(ISO IEC IEV ITU W3C csd metanorma repository rfc-anchor)
113
+ %w(ISO IEC IEV ITU W3C csd metanorma repository metanorma-ordinal)
102
114
  .include? prefix
103
115
  end
104
116
 
@@ -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
@@ -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".freeze
2
+ VERSION = "2.0.3".freeze
3
3
  end
@@ -1691,7 +1691,7 @@ RSpec.describe IsoDoc do
1691
1691
  </foreword></preface>
1692
1692
  <bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder="2">
1693
1693
  <title>Bibliography</title>
1694
- <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1694
+ <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type="IETF">RFC 2616</docidentifier> <docidentifier type="IETF" scope="anchor">RFC2616</docidentifier> <docidentifier type="DOI">10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1695
1695
  </references></bibliography>
1696
1696
  </iso-standard>
1697
1697
  INPUT
@@ -1752,7 +1752,7 @@ RSpec.describe IsoDoc do
1752
1752
  </foreword></preface>
1753
1753
  <bibliography><references id="_bibliography" obligation="informative" normative="false" displayorder='2'>
1754
1754
  <title depth='1'>Bibliography</title>
1755
- <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type='metanorma-ordinal'>[1]</docidentifier> <docidentifier type="IETF">IETF RFC 2616</docidentifier> <docidentifier type="rfc-anchor">RFC2616</docidentifier> <docidentifier type="DOI">DOI 10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1755
+ <bibitem id="rfc2616" type="standard"> <fetched>2020-03-27</fetched> <title format="text/plain" language="en" script="Latn">Hypertext Transfer Protocol — HTTP/1.1</title> <uri type="xml">https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2616.xml</uri> <uri type="src">https://www.rfc-editor.org/info/rfc2616</uri> <docidentifier type='metanorma-ordinal'>[1]</docidentifier> <docidentifier type="IETF">IETF RFC 2616</docidentifier> <docidentifier type="IETF" scope="anchor">IETF RFC2616</docidentifier> <docidentifier type="DOI">DOI 10.17487/RFC2616</docidentifier> <date type="published"> <on>1999-06</on> </date> <contributor> <role type="author"/> <person> <name> <completename language="en">R. Fielding</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Gettys</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">J. Mogul</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">H. Frystyk</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">L. Masinter</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">P. Leach</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <contributor> <role type="author"/> <person> <name> <completename language="en">T. Berners-Lee</completename> </name> <affiliation> <organization> <name>IETF</name> <abbreviation>IETF</abbreviation> </organization> </affiliation> </person> </contributor> <language>en</language> <script>Latn</script> <abstract format="text/plain" language="en" script="Latn">HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as “HTTP/1.1”, and is an update to RFC 2068. [STANDARDS-TRACK]</abstract> <series type="main"> <title format="text/plain" language="en" script="Latn">RFC</title> <number>2616</number> </series> <place>Fremont, CA</place></bibitem>
1756
1756
  </references></bibliography>
1757
1757
  </iso-standard>
1758
1758
  OUTPUT
@@ -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
4
+ version: 2.0.3
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-07 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