isodoc 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,8 +13,7 @@ module IsoDoc::Function
13
13
  list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
14
14
  id = bibitem_ref_code(b)
15
15
  identifier = render_identifier(id)
16
- if bibliography
17
- ref_entry_code(r, ordinal, identifier, id)
16
+ if bibliography then ref_entry_code(r, ordinal, identifier, id)
18
17
  else
19
18
  r << "#{identifier}, "
20
19
  end
@@ -48,8 +47,10 @@ module IsoDoc::Function
48
47
  end
49
48
 
50
49
  def bibitem_ref_code(b)
51
- id = b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' or @type = 'ISSN' or @type = 'ISBN')]"))
52
- id ||= b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'ISSN' or @type = 'ISBN')]"))
50
+ id = b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
51
+ "or @type = 'ISSN' or @type = 'ISBN')]"))
52
+ id ||= b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'ISSN' or "\
53
+ "@type = 'ISBN')]"))
53
54
  id ||= b.at(ns("./docidentifier"))
54
55
  return id if id
55
56
  id = Nokogiri::XML::Node.new("docidentifier", b.document)
@@ -122,19 +123,22 @@ module IsoDoc::Function
122
123
  def is_standard(b)
123
124
  ret = false
124
125
  b.xpath(ns("./docidentifier")).each do |id|
125
- next if id["type"].nil? || %w(metanorma DOI ISSN ISBN).include?(id["type"])
126
+ next if id["type"].nil? ||
127
+ %w(metanorma DOI ISSN ISBN).include?(id["type"])
126
128
  ret = true
127
129
  end
128
130
  ret
129
131
  end
130
132
 
131
- def biblio_list(f, div, bibliography)
132
- f.xpath(ns("./bibitem")).each_with_index do |b, i|
133
+ def biblio_list(f, div, biblio)
134
+ i = 0
135
+ f.xpath(ns("./bibitem | ./note")).each do |b|
133
136
  next if implicit_reference(b)
134
- if(is_standard(b))
135
- std_bibitem_entry(div, b, i + 1, bibliography)
137
+ i += 1 if b.name == "bibitem"
138
+ if b.name == "note" then note_parse(b, div)
139
+ elsif(is_standard(b)) then std_bibitem_entry(div, b, i, biblio)
136
140
  else
137
- nonstd_bibitem(div, b, i + 1, bibliography)
141
+ nonstd_bibitem(div, b, i, biblio)
138
142
  end
139
143
  end
140
144
  end
@@ -147,7 +151,7 @@ module IsoDoc::Function
147
151
  num = num + 1
148
152
  clause_name(num, @normref_lbl, div, nil)
149
153
  f.elements.reject do |e|
150
- ["reference", "title", "bibitem"].include? e.name
154
+ %w(reference title bibitem note).include? e.name
151
155
  end.each { |e| parse(e, div) }
152
156
  biblio_list(f, div, false)
153
157
  end
@@ -157,14 +161,13 @@ module IsoDoc::Function
157
161
  BIBLIOGRAPHY_XPATH = "//bibliography/clause[title = 'Bibliography'] | "\
158
162
  "//bibliography/references[title = 'Bibliography']".freeze
159
163
 
160
-
161
164
  def bibliography(isoxml, out)
162
165
  f = isoxml.at(ns(BIBLIOGRAPHY_XPATH)) || return
163
166
  page_break(out)
164
167
  out.div do |div|
165
168
  div.h1 @bibliography_lbl, **{ class: "Section3" }
166
169
  f.elements.reject do |e|
167
- ["reference", "title", "bibitem"].include? e.name
170
+ %w(reference title bibitem note).include? e.name
168
171
  end.each { |e| parse(e, div) }
169
172
  biblio_list(f, div, true)
170
173
  end
@@ -173,26 +176,21 @@ module IsoDoc::Function
173
176
  def bibliography_parse(node, out)
174
177
  title = node&.at(ns("./title"))&.text || ""
175
178
  out.div do |div|
176
- div.h2 title, **{ class: "Section3" }
179
+ anchor(node['id'], :label, false) and
180
+ clause_parse_title(node, div, node.at(ns("./title")), out) or
181
+ div.h2 title, **{ class: "Section3" }
177
182
  node.elements.reject do |e|
178
- ["reference", "title", "bibitem"].include? e.name
183
+ %w(reference title bibitem note).include? e.name
179
184
  end.each { |e| parse(e, div) }
180
185
  biblio_list(node, div, true)
181
186
  end
182
187
  end
183
188
 
184
189
  def format_ref(ref, prefix, isopub, date, allparts)
185
- if isopub
186
- #if date
187
- #on = date.at(ns("./on"))
188
- #ref += on&.text == "--" ? ":--" : "" # ":#{date_range(date)}"
189
- #ref += " (all parts)" if allparts
190
- # ref = docid_prefix(prefix, ref)
191
- #end
192
- end
193
190
  ref = docid_prefix(prefix, ref)
194
- return "[#{ref}]" if /^\d+$/.match(ref) && !prefix && !/^\[.*\]$/.match(ref)
195
- ref
191
+ return "[#{ref}]" if /^\d+$/.match(ref) && !prefix &&
192
+ !/^\[.*\]$/.match(ref)
193
+ ref
196
194
  end
197
195
 
198
196
  def reference_names(ref)
@@ -201,7 +199,8 @@ module IsoDoc::Function
201
199
  prefix = docid["type"]
202
200
  date = ref.at(ns("./date[@type = 'published']"))
203
201
  allparts = ref.at(ns("./extent[@type='part'][referenceFrom='all']"))
204
- reference = format_ref(docid_l10n(docid.text), prefix, isopub, date, allparts)
202
+ reference = format_ref(docid_l10n(docid.text), prefix, isopub, date,
203
+ allparts)
205
204
  @anchors[ref["id"]] = { xref: reference }
206
205
  end
207
206
 
@@ -40,12 +40,16 @@ module IsoDoc::Function
40
40
  end.to_h
41
41
  end
42
42
 
43
+ DOCTYPE_HDR = '<!DOCTYPE html SYSTEM
44
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.freeze
45
+
43
46
  def to_xhtml(xml)
44
47
  xml.gsub!(/<\?xml[^>]*>/, "")
45
- unless /<!DOCTYPE /.match xml
46
- xml = '<!DOCTYPE html SYSTEM
47
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' + xml
48
- end
48
+ /<!DOCTYPE /.match xml or xml = DOCTYPE_HDR + xml
49
+ xml = xml.split(/(\&[^ \r\n\t#;]+;)/).map do |t|
50
+ /^(\&[^ \t\r\n#;]+;)/.match(t) ?
51
+ HTMLEntities.new.encode(HTMLEntities.new.decode(t), :hexadecimal) : t
52
+ end.join("")
49
53
  Nokogiri::XML.parse(xml)
50
54
  end
51
55
 
@@ -85,11 +89,11 @@ module IsoDoc::Function
85
89
 
86
90
  def sentence_join(array)
87
91
  return "" if array.nil? || array.empty?
88
- if array.length == 1
89
- array[0]
92
+ if array.length == 1 then array[0]
90
93
  else
91
- IsoDoc::Function::I18n::l10n("#{array[0..-2].join(', ')} #{@and_lbl} #{array.last}",
92
- @lang, @script)
94
+ IsoDoc::Function::I18n::l10n("#{array[0..-2].join(', ')} "\
95
+ "#{@and_lbl} #{array.last}",
96
+ @lang, @script)
93
97
  end
94
98
  end
95
99
 
@@ -102,7 +102,7 @@ module IsoDoc::Function
102
102
  def annex_names(clause, num)
103
103
  @anchors[clause["id"]] = { label: annex_name_lbl(clause, num), type: "clause",
104
104
  xref: "#{@annex_lbl} #{num}", level: 1 }
105
- clause.xpath(ns("./clause")).each_with_index do |c, i|
105
+ clause.xpath(ns("./clause | ./references")).each_with_index do |c, i|
106
106
  annex_names1(c, "#{num}.#{i + 1}", 2)
107
107
  end
108
108
  hierarchical_asset_names(clause, num)
@@ -111,7 +111,7 @@ module IsoDoc::Function
111
111
  def annex_names1(clause, num, level)
112
112
  @anchors[clause["id"]] = { label: num, xref: "#{@annex_lbl} #{num}",
113
113
  level: level, type: "clause" }
114
- clause.xpath(ns("./clause")).each_with_index do |c, i|
114
+ clause.xpath(ns("./clause | ./references")).each_with_index do |c, i|
115
115
  annex_names1(c, "#{num}.#{i + 1}", level + 1)
116
116
  end
117
117
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.0.3".freeze
2
+ VERSION = "1.0.4".freeze
3
3
  end
@@ -213,6 +213,7 @@ module IsoDoc::WordFunction
213
213
  def image_parse(node, out, caption)
214
214
  attrs = { src: imgsrc(node["src"]),
215
215
  height: node["height"],
216
+ alt: node["alt"],
216
217
  width: node["width"] }
217
218
  if node["height"] == "auto" || node["width"] == "auto"
218
219
  attrs[:height] = nil
@@ -238,13 +239,13 @@ module IsoDoc::WordFunction
238
239
  end
239
240
 
240
241
  def make_table_attr(node)
241
- super.merge({
242
+ super.merge(attr_code({
242
243
  summary: node["summary"],
243
244
  style: "mso-table-lspace:15.0cm;margin-left:423.0pt;"\
244
245
  "mso-table-rspace:15.0cm;margin-right:423.0pt;mso-table-bspace:14.2pt;"\
245
246
  "mso-table-anchor-vertical:paragraph;mso-table-anchor-horizontal:column;"\
246
247
  "mso-table-overlap:never;border-spacing:0;border-width:1px;"
247
- })
248
+ }))
248
249
  end
249
250
 
250
251
  def table_parse(node, out)
@@ -349,6 +349,7 @@ B</pre>
349
349
  <iso-standard xmlns="http://riboseinc.com/isoxml">
350
350
  <preface><foreword>
351
351
  <example id="samplecode">
352
+ <name>Title</name>
352
353
  <p>Hello</p>
353
354
  </example>
354
355
  </foreword></preface>
@@ -359,7 +360,7 @@ B</pre>
359
360
  <div>
360
361
  <h1 class="ForewordTitle">Foreword</h1>
361
362
  <div id="samplecode" class="example">
362
- <p class="example-title">EXAMPLE</p>
363
+ <p class="example-title">EXAMPLE&#160;&#8212; Title</p>
363
364
  <p>Hello</p>
364
365
  </div>
365
366
  </div>
@@ -379,6 +380,7 @@ B</pre>
379
380
  <p>Hello</p>
380
381
  </example>
381
382
  <example id="samplecode2">
383
+ <name>Title</name>
382
384
  <p>Hello</p>
383
385
  </example>
384
386
  <example id="samplecode3" unnumbered="true">
@@ -396,7 +398,7 @@ B</pre>
396
398
  <p>Hello</p>
397
399
  </div>
398
400
  <div id="samplecode2" class="example">
399
- <p class="example-title">EXAMPLE 2</p>
401
+ <p class="example-title">EXAMPLE 2&#160;&#8212; Title</p>
400
402
  <p>Hello</p>
401
403
  </div>
402
404
  <div id="samplecode3" class="example">
@@ -263,7 +263,7 @@ RSpec.describe IsoDoc do
263
263
  <div><a name="_terms_and_definitions" id="_terms_and_definitions"></a><h1>1.<span style="mso-tab-count:1">&#xA0; </span>Terms and definitions</h1>
264
264
  <p class="TermNum"><a name="paddy1" id="paddy1"></a>1.1.</p><p class="Terms" style="text-align:left;">paddy</p>
265
265
  <p class="MsoNormal"><a name="_eb29b35e-123e-4d1c-b50b-2714d41e747f" id="_eb29b35e-123e-4d1c-b50b-2714d41e747f"></a>rice retaining its husk after threshing</p>
266
- <p class="MsoNormal">[SOURCE: <a href="#ISO7301">ISO 7301:2011, Clause 3.1</a>, modified &mdash; The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p></div>
266
+ <p class="MsoNormal">[SOURCE: <a href="#ISO7301">ISO 7301:2011, Clause 3.1</a>, modified &#x2014; The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]</p></div>
267
267
  </div>
268
268
  OUTPUT
269
269
  end
@@ -63,6 +63,7 @@ RSpec.describe IsoDoc do
63
63
  <formattedref format="application/x-isodoc+xml"><smallcap>Standard No I.C.C 167</smallcap>. <em>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</em> (see <link target="http://www.icc.or.at"/>)</formattedref>
64
64
  <docidentifier type="ICC">167</docidentifier>
65
65
  </bibitem>
66
+ <note><p>This is an annotation of ISO 20483:2013-2014</p></note>
66
67
 
67
68
  </references><references id="_bibliography" obligation="informative">
68
69
  <title>Bibliography</title>
@@ -88,6 +89,8 @@ RSpec.describe IsoDoc do
88
89
  </organization>
89
90
  </contributor>
90
91
  </bibitem>
92
+ <note><p>This is an annotation of document ISSN.</p></note>
93
+ <note><p>This is another annotation of document ISSN.</p></note>
91
94
  <bibitem id="ISO3696" type="standard">
92
95
  <title format="text/plain">Water for analytical laboratory use</title>
93
96
  <docidentifier type="ISO">ISO 3696</docidentifier>
@@ -138,12 +141,21 @@ RSpec.describe IsoDoc do
138
141
  <p id="ISO16634" class="NormRef">ISO 16634:-- (all parts)<a rel="footnote" href="#fn:1" epub:type="footnote"><sup>1</sup></a>, <i>Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs</i></p>
139
142
  <p id="ISO20483" class="NormRef">ISO 20483:2013-2014, <i>Cereals and pulses</i></p>
140
143
  <p id="ref1" class="NormRef">ICC 167, <span style="font-variant:small-caps;">Standard No I.C.C 167</span>. <i>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</i> (see <a href="http://www.icc.or.at">http://www.icc.or.at</a>)</p>
144
+ <div id="" class="Note">
145
+ <p><span class="note_label">NOTE</span>&#160; This is an annotation of ISO 20483:2013-2014</p>
146
+ </div>
141
147
  </div>
142
148
  <br/>
143
149
  <div>
144
150
  <h1 class="Section3">Bibliography</h1>
145
151
  <p id="ISBN" class="Biblio">[1]&#160; <i>Chemicals for analytical laboratory use</i></p>
146
152
  <p id="ISSN" class="Biblio">[2]&#160; <i>Instruments for analytical laboratory use</i></p>
153
+ <div id="" class="Note">
154
+ <p><span class="note_label">NOTE</span>&#160; This is an annotation of document ISSN.</p>
155
+ </div>
156
+ <div id="" class="Note">
157
+ <p><span class="note_label">NOTE</span>&#160; This is another annotation of document ISSN.</p>
158
+ </div>
147
159
  <p id="ISO3696" class="Biblio">[3]&#160; ISO 3696, <i>Water for analytical laboratory use</i></p>
148
160
  <p id="ref10" class="Biblio">[10]&#160; <span style="font-variant:small-caps;">Standard No I.C.C 167</span>. <i>Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method</i> (see <a href="http://www.icc.or.at">http://www.icc.or.at</a>)</p>
149
161
  <p id="ref11" class="Biblio">[5]&#160; IETF RFC 10, <i>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</i></p>
@@ -84,6 +84,7 @@ RSpec.describe IsoDoc do
84
84
  <clause id="Q1" inline-header="false" obligation="normative">
85
85
  <title>Annex A.1a</title>
86
86
  </clause>
87
+ <references id="Q2"><title>Annex Bibliography</title></references>
87
88
  </clause>
88
89
  </annex><bibliography><references id="R" obligation="informative">
89
90
  <title>Normative References</title>
@@ -160,6 +161,7 @@ RSpec.describe IsoDoc do
160
161
  <div id="Q1">
161
162
  <h3>A.1.1. Annex A.1a</h3>
162
163
  </div>
164
+ <div><h3>A.1.2. Annex Bibliography</h3></div>
163
165
  </div>
164
166
 
165
167
  </div>
@@ -142,6 +142,9 @@ RSpec.describe IsoDoc do
142
142
  <iso-standard xmlns="http://riboseinc.com/isoxml">
143
143
  <preface>
144
144
  <foreword>
145
+ <table id="tableD-0">
146
+ <tbody><tr><td>A</td></tr></tbody>
147
+ </table>
145
148
  <table id="tableD-1" alt="tool tip" summary="long desc">
146
149
  <name>Repeatability and reproducibility of husked rice yield</name>
147
150
  <thead>
@@ -206,8 +209,18 @@ RSpec.describe IsoDoc do
206
209
  <p><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p>
207
210
  <div>
208
211
  <h1 class="ForewordTitle">Foreword</h1>
209
- <p class="TableTitle" style="text-align:center;">Table 1&#160;&#8212; Repeatability and reproducibility of husked rice yield</p>
212
+ <p class="TableTitle" style="text-align:center;">Table 1</p>
210
213
  <div align="center">
214
+ <table id="tableD-0" class="MsoISOTable" style="mso-table-lspace:15.0cm;margin-left:423.0pt;mso-table-rspace:15.0cm;margin-right:423.0pt;mso-table-bspace:14.2pt;mso-table-anchor-vertical:paragraph;mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;">
215
+ <tbody>
216
+ <tr>
217
+ <td style="border-top:solid windowtext 1.5pt;mso-border-top-alt:solid windowtext 1.5pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;">A</td>
218
+ </tr>
219
+ </tbody>
220
+ </table>
221
+ </div>
222
+ <p class="TableTitle" style="text-align:center;">Table 2&#160;&#8212; Repeatability and reproducibility of husked rice yield</p>
223
+ <div align="center">
211
224
  <table id="tableD-1" class="MsoISOTable" style="mso-table-lspace:15.0cm;margin-left:423.0pt;mso-table-rspace:15.0cm;margin-right:423.0pt;mso-table-bspace:14.2pt;mso-table-anchor-vertical:paragraph;mso-table-anchor-horizontal:column;mso-table-overlap:never;border-spacing:0;border-width:1px;" title="tool tip" summary="long desc">
212
225
  <thead>
213
226
  <tr>
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: 1.0.3
4
+ version: 1.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: 2019-09-27 00:00:00.000000000 Z
11
+ date: 2019-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath
@@ -301,25 +301,34 @@ executables: []
301
301
  extensions: []
302
302
  extra_rdoc_files: []
303
303
  files:
304
+ - ".github/workflows/macos.yml"
305
+ - ".github/workflows/ubuntu.yml"
306
+ - ".github/workflows/windows.yml"
304
307
  - ".hound.yml"
305
308
  - ".oss-guides.rubocop.yml"
306
309
  - ".rubocop.ribose.yml"
307
310
  - ".rubocop.tb.yml"
308
311
  - ".rubocop.yml"
309
- - ".travis.yml"
310
312
  - CODE_OF_CONDUCT.md
311
313
  - Gemfile
312
314
  - Gemfile.lock
313
315
  - LICENSE
314
316
  - README.adoc
315
317
  - Rakefile
316
- - appveyor.yml
317
318
  - bin/rspec
318
319
  - isodoc.gemspec
319
320
  - lib/isodoc-yaml/i18n-en.yaml
320
321
  - lib/isodoc-yaml/i18n-fr.yaml
321
322
  - lib/isodoc-yaml/i18n-zh-Hans.yaml
322
323
  - lib/isodoc.rb
324
+ - lib/isodoc/base_style/all.scss
325
+ - lib/isodoc/base_style/bands.scss
326
+ - lib/isodoc/base_style/blocks.scss
327
+ - lib/isodoc/base_style/coverpage.scss
328
+ - lib/isodoc/base_style/defaults.scss
329
+ - lib/isodoc/base_style/nav.scss
330
+ - lib/isodoc/base_style/reset.scss
331
+ - lib/isodoc/base_style/typography.scss
323
332
  - lib/isodoc/class_utils.rb
324
333
  - lib/isodoc/common.rb
325
334
  - lib/isodoc/convert.rb
data/.travis.yml DELETED
@@ -1,22 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- language: ruby
4
- cache: bundler
5
- os:
6
- - linux
7
- - osx
8
- rvm:
9
- - 2.6
10
- - 2.5
11
- - 2.4
12
- - ruby-head
13
- before_install:
14
- - nvm install 8
15
- - npm install -g puppeteer
16
- - npm install
17
- - gem install bundler -v "~> 2"
18
- - bundle update
19
- matrix:
20
- allow_failures:
21
- - rvm: ruby-head
22
-
data/appveyor.yml DELETED
@@ -1,37 +0,0 @@
1
- # Auto-generated !!! Do not edit it manually
2
- # use ci-master https://github.com/metanorma/metanorma-build-scripts
3
- version: '{build}'
4
-
5
- cache:
6
- - vendor/bundle
7
-
8
- environment:
9
- matrix:
10
- - RUBY_VERSION: 26
11
- - RUBY_VERSION: 25
12
- - RUBY_VERSION: 24
13
- - RUBY_VERSION: _trunk
14
-
15
- matrix:
16
- allow_failures:
17
- - RUBY_VERSION: _trunk
18
-
19
- install:
20
- - ps: . { iwr -useb https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/appveyor.ps1 } | iex
21
- - refreshenv
22
-
23
- build_script:
24
- - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
25
- - set GIT_TERMINAL_PROMPT=0
26
- - gem install bundler -v "~> 2"
27
- - bundle config --local path vendor/bundle
28
- - bundle update
29
- - bundle install
30
-
31
- before_test:
32
- - ruby -v
33
- - gem -v
34
- - bundle -v
35
-
36
- test_script:
37
- - bundle exec rake