isodoc 0.5.7 → 0.5.8

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
  SHA1:
3
- metadata.gz: de4c3e74196d5812243cf431a1d013c2f13ec687
4
- data.tar.gz: 731a94da93e07e7494a7b565823f7c1904861996
3
+ metadata.gz: 57ca9a13e94e7c5861ee7694b1c543a304d35e2c
4
+ data.tar.gz: 4d1ca9fe799cc66bb3d6e1422585168e09da7c4a
5
5
  SHA512:
6
- metadata.gz: d0464408db2c12b91837bb66a523e7f149b376ece67044d47a6d92b1a5dc7756bdc8bc13d49e084287ed5c8f6dc5569491ec3b856021e2d22c6831bfee9e2cfe
7
- data.tar.gz: c3a5075be9cdb977ddc58787d857d1477c636fc037fe5cde78e2795c03e3450b515681a4751a7b2bb9db22b32c20a604272f6d9e2ed9537cd2bd24aead1ded09
6
+ metadata.gz: a382164e2ff256407dc864caa9638235970b84bff249291d690588ac880cd832cefd089505336603f4e920dd89053096fc96c5b9d2233fb4f023ac6bf9465d63
7
+ data.tar.gz: 54d6a2064d4b1fe1a72a8997ca842b1f9a45094a7f3778a9858af9c560757f72d078d38045cee41782d79043a743ecd6be8dbc2d31b657ab07292d2ac6efa090
@@ -184,8 +184,8 @@ module IsoDoc
184
184
  std = isoxml.at(ns("//bibdata/relation[@type = 'obsoletes']")) || return
185
185
  locality = std.at(ns(".//locality"))
186
186
  id = std.at(ns(".//docidentifier"))
187
- set_metadata(:obsoletes, id.text)
188
- set_metadata(:obsoletes_part, locality.text)
187
+ set_metadata(:obsoletes, id.text) if id
188
+ set_metadata(:obsoletes_part, locality.text) if locality
189
189
  end
190
190
  end
191
191
  end
@@ -48,6 +48,11 @@ module IsoDoc
48
48
  end
49
49
  end
50
50
 
51
+ def reference_format(b, r)
52
+ title = b.at(ns("./formattedref")) || b.at(ns("./title"))
53
+ title&.children&.each { |n| parse(n, r) }
54
+ end
55
+
51
56
  # TODO generate formatted ref if not present
52
57
  def noniso_bibitem(list, b, ordinal, bibliography)
53
58
  list.p **attr_code("id": b["id"], class: "Biblio") do |r|
@@ -57,7 +62,7 @@ module IsoDoc
57
62
  else
58
63
  r << "#{iso_bibitem_ref_code(b)}, "
59
64
  end
60
- b.at(ns("./formattedref"))&.children&.each { |n| parse(n, r) }
65
+ reference_format(b, r)
61
66
  end
62
67
  end
63
68
 
@@ -112,7 +117,7 @@ module IsoDoc
112
117
  end
113
118
 
114
119
  def bibliography(isoxml, out)
115
- q = "./*/references[title = 'Bibliography']"
120
+ q = "//clause[title = 'Bibliography'][descendant::references] | //references[title = 'Bibliography']"
116
121
  f = isoxml.at(ns(q)) || return
117
122
  page_break(out)
118
123
  out.div do |div|
@@ -43,9 +43,12 @@ module IsoDoc
43
43
  div.parent.at(".//h1")
44
44
  end
45
45
 
46
+ MIDDLE_CLAUSE =
47
+ "//clause[parent::sections][not(xmlns:title = 'Scope')]"\
48
+ "[not(descendant::terms)]".freeze
49
+
46
50
  def clause(isoxml, out)
47
- isoxml.xpath(ns("//clause[parent::sections]")).each do |c|
48
- next if c.at(ns("./title")).text == "Scope"
51
+ isoxml.xpath(ns(MIDDLE_CLAUSE)).each do |c|
49
52
  out.div **attr_code(id: c["id"]) do |s|
50
53
  c.elements.each do |c1|
51
54
  if c1.name == "title"
@@ -124,11 +127,15 @@ module IsoDoc
124
127
  @termsdef_lbl
125
128
  end
126
129
 
130
+ TERM_CLAUSE = "//sections/terms | "\
131
+ "//sections/clause[descendant::terms]".freeze
132
+
127
133
  def terms_defs(isoxml, out)
128
- f = isoxml.at(ns("//sections/terms")) || return
134
+ f = isoxml.at(ns(TERM_CLAUSE)) || return
129
135
  out.div **attr_code(id: f["id"]) do |div|
130
136
  clause_name("3.", terms_defs_title(f), div, nil)
131
- term_defs_boilerplate(div, f.xpath(ns("./source")), f.at(ns(".//term")))
137
+ term_defs_boilerplate(div, isoxml.xpath(ns(".//termdocsource")),
138
+ f.at(ns(".//term")))
132
139
  f.elements.each do |e|
133
140
  parse(e, div) unless %w{title source}.include? e.name
134
141
  end
@@ -12,16 +12,21 @@ module IsoDoc
12
12
 
13
13
  def deprecated_term_parse(node, out)
14
14
  out.p **{ class: "DeprecatedTerms" } do |p|
15
- p << l10n("#{@deprecated_lbl}: #{node.text}")
15
+ p << l10n("#{@deprecated_lbl}: ")
16
+ node.children.each { |c| parse(c, p) }
16
17
  end
17
18
  end
18
19
 
19
20
  def admitted_term_parse(node, out)
20
- out.p **{ class: "AltTerms" } { |p| p << node.text }
21
+ out.p **{ class: "AltTerms" } do |p|
22
+ node.children.each { |c| parse(c, p) }
23
+ end
21
24
  end
22
25
 
23
26
  def term_parse(node, out)
24
- out.p **{ class: "Terms" } { |p| p << node.text }
27
+ out.p **{ class: "Terms" } do |p|
28
+ node.children.each { |c| parse(c, p) }
29
+ end
25
30
  end
26
31
 
27
32
  def para_then_remainder(first, node, p, div)
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "0.5.7".freeze
2
+ VERSION = "0.5.8".freeze
3
3
  end
@@ -36,7 +36,8 @@ module IsoDoc
36
36
 
37
37
  SECTIONS_XPATH =
38
38
  "//foreword | //introduction | //sections/terms | //annex | "\
39
- "//sections/clause | //references[not(ancestor::references)]".freeze
39
+ "//sections/clause | //references[not(ancestor::clause)] | "\
40
+ "//clause[descendant::references][not(ancestor::clause)]".freeze
40
41
 
41
42
  CHILD_NOTES_XPATH =
42
43
  "./*[not(self::xmlns:subsection)]//xmlns:note | ./xmlns:note".freeze
@@ -14,7 +14,7 @@ module IsoDoc
14
14
  section_names(d.at(ns("//clause[title = 'Scope']")), "1", 1)
15
15
  section_names(d.at(ns(
16
16
  "//references[title = 'Normative References']")), "2", 1)
17
- section_names(d.at(ns("//sections/terms")), "3", 1)
17
+ section_names(d.at(ns("//sections/terms | //sections/clause[descendant::terms]")), "3", 1)
18
18
  middle_section_asset_names(d)
19
19
  end
20
20
 
@@ -27,7 +27,7 @@ module IsoDoc
27
27
  end
28
28
 
29
29
  def clause_names(docxml, sect_num)
30
- q = "//clause[parent::sections][not(xmlns:title = 'Scope')]"
30
+ q = "//clause[parent::sections][not(xmlns:title = 'Scope')][not(descendant::terms)]"
31
31
  docxml.xpath(ns(q)).each_with_index do |c, i|
32
32
  section_names(c, (i + sect_num).to_s, 1)
33
33
  end
@@ -23,7 +23,7 @@ RSpec.describe IsoDoc do
23
23
  <p id="E">Text</p>
24
24
  </clause>
25
25
 
26
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
26
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
27
27
  <title>Normal Terms</title>
28
28
  <term id="J">
29
29
  <preferred>Term2</preferred>
@@ -35,7 +35,7 @@ RSpec.describe IsoDoc do
35
35
  <dd>Definition</dd>
36
36
  </dl>
37
37
  </symbols-abbrevs>
38
- </terms>
38
+ </clause>
39
39
  <symbols-abbrevs id="L">
40
40
  <dl>
41
41
  <dt>Symbol</dt>
@@ -59,12 +59,12 @@ RSpec.describe IsoDoc do
59
59
  </subsection>
60
60
  </annex><references id="R" obligation="informative">
61
61
  <title>Normative References</title>
62
- </references><references id="S" obligation="informative">
62
+ </references><clause id="S" obligation="informative">
63
63
  <title>Bibliography</title>
64
64
  <references id="T" obligation="informative">
65
65
  <title>Bibliography Subsection</title>
66
66
  </references>
67
- </references>
67
+ </clause>
68
68
  </iso-standard>
69
69
  INPUT
70
70
  <html xmlns:epub="http://www.idpf.org/2007/ops">
@@ -185,7 +185,7 @@ RSpec.describe IsoDoc do
185
185
  <p id="E">Text</p>
186
186
  </clause>
187
187
 
188
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
188
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
189
189
  <title>Normal Terms</title>
190
190
  <term id="J">
191
191
  <preferred>Term2</preferred>
@@ -197,7 +197,7 @@ RSpec.describe IsoDoc do
197
197
  <dd>Definition</dd>
198
198
  </dl>
199
199
  </symbols-abbrevs>
200
- </terms>
200
+ </clause>
201
201
  <symbols-abbrevs id="L">
202
202
  <dl>
203
203
  <dt>Symbol</dt>
@@ -221,12 +221,12 @@ RSpec.describe IsoDoc do
221
221
  </subsection>
222
222
  </annex><references id="R" obligation="informative">
223
223
  <title>Normative References</title>
224
- </references><references id="S" obligation="informative">
224
+ </references><clause id="S" obligation="informative">
225
225
  <title>Bibliography</title>
226
226
  <references id="T" obligation="informative">
227
227
  <title>Bibliography Subsection</title>
228
228
  </references>
229
- </references>
229
+ </clause>
230
230
  </iso-standard>
231
231
  INPUT
232
232
  <html xmlns:epub="http://www.idpf.org/2007/ops">
@@ -347,7 +347,7 @@ RSpec.describe IsoDoc do
347
347
  <p id="E">Text</p>
348
348
  </clause>
349
349
 
350
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
350
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
351
351
  <title>Normal Terms</title>
352
352
  <term id="J">
353
353
  <preferred>Term2</preferred>
@@ -359,7 +359,7 @@ RSpec.describe IsoDoc do
359
359
  <dd>Definition</dd>
360
360
  </dl>
361
361
  </symbols-abbrevs>
362
- </terms>
362
+ </clause>
363
363
  <symbols-abbrevs id="L">
364
364
  <dl>
365
365
  <dt>Symbol</dt>
@@ -383,12 +383,12 @@ RSpec.describe IsoDoc do
383
383
  </subsection>
384
384
  </annex><references id="R" obligation="informative">
385
385
  <title>Normative References</title>
386
- </references><references id="S" obligation="informative">
386
+ </references><clause id="S" obligation="informative">
387
387
  <title>Bibliography</title>
388
388
  <references id="T" obligation="informative">
389
389
  <title>Bibliography Subsection</title>
390
390
  </references>
391
- </references>
391
+ </clause>
392
392
  </iso-standard>
393
393
  INPUT
394
394
  <html xmlns:epub="http://www.idpf.org/2007/ops">
@@ -509,7 +509,7 @@ RSpec.describe IsoDoc do
509
509
  <p id="E"><eref type="inline" bibitemid="ISO712"><locality type="table"><referenceFrom>1</referenceFrom><referenceTo>1</referenceTo></locality></eref></p>
510
510
  </clause>
511
511
 
512
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
512
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
513
513
  <title>Normal Terms</title>
514
514
  <term id="J">
515
515
  <preferred>Term2</preferred>
@@ -521,7 +521,7 @@ RSpec.describe IsoDoc do
521
521
  <dd>Definition</dd>
522
522
  </dl>
523
523
  </symbols-abbrevs>
524
- </terms>
524
+ </clause>
525
525
  <symbols-abbrevs id="L">
526
526
  <dl>
527
527
  <dt>Symbol</dt>
@@ -555,12 +555,12 @@ RSpec.describe IsoDoc do
555
555
  </organization>
556
556
  </contributor>
557
557
  </bibitem>
558
- </references><references id="S" obligation="informative">
558
+ </references><clause id="S" obligation="informative">
559
559
  <title>Bibliography</title>
560
560
  <references id="T" obligation="informative">
561
561
  <title>Bibliography Subsection</title>
562
562
  </references>
563
- </references>
563
+ </clause>
564
564
  </iso-standard>
565
565
  INPUT
566
566
  <html xmlns:epub="http://www.idpf.org/2007/ops">
@@ -20,7 +20,7 @@ RSpec.describe IsoDoc do
20
20
  <p id="E">Text</p>
21
21
  </clause>
22
22
 
23
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
23
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
24
24
  <title>Normal Terms</title>
25
25
  <term id="J">
26
26
  <preferred>Term2</preferred>
@@ -32,7 +32,7 @@ RSpec.describe IsoDoc do
32
32
  <dd>Definition</dd>
33
33
  </dl>
34
34
  </symbols-abbrevs>
35
- </terms>
35
+ </clause>
36
36
  <symbols-abbrevs id="L">
37
37
  <dl>
38
38
  <dt>Symbol</dt>
@@ -56,12 +56,12 @@ RSpec.describe IsoDoc do
56
56
  </subsection>
57
57
  </annex><references id="R" obligation="informative">
58
58
  <title>Normative References</title>
59
- </references><references id="S" obligation="informative">
59
+ </references><clause id="S" obligation="informative">
60
60
  <title>Bibliography</title>
61
61
  <references id="T" obligation="informative">
62
62
  <title>Bibliography Subsection</title>
63
63
  </references>
64
- </references>
64
+ </clause>
65
65
  </iso-standard>
66
66
  INPUT
67
67
  <html xmlns:epub="http://www.idpf.org/2007/ops">
@@ -179,7 +179,7 @@ OUTPUT
179
179
  <p id="E">Text</p>
180
180
  </clause>
181
181
 
182
- <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
182
+ <clause id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title><terms id="I" obligation="normative">
183
183
  <title>Normal Terms</title>
184
184
  <term id="J">
185
185
  <preferred>Term2</preferred>
@@ -191,7 +191,7 @@ OUTPUT
191
191
  <dd>Definition</dd>
192
192
  </dl>
193
193
  </symbols-abbrevs>
194
- </terms>
194
+ </clause>
195
195
  <symbols-abbrevs id="L">
196
196
  <dl>
197
197
  <dt>Symbol</dt>
@@ -215,12 +215,12 @@ OUTPUT
215
215
  </subsection>
216
216
  </annex><references id="R" obligation="informative">
217
217
  <title>Normative References</title>
218
- </references><references id="S" obligation="informative">
218
+ </references><clause id="S" obligation="informative">
219
219
  <title>Bibliography</title>
220
220
  <references id="T" obligation="informative">
221
221
  <title>Bibliography Subsection</title>
222
222
  </references>
223
- </references>
223
+ </clause>
224
224
  </iso-standard>
225
225
  INPUT
226
226
  <html xmlns:epub="http://www.idpf.org/2007/ops">
@@ -371,9 +371,9 @@ OUTPUT
371
371
  it "processes terms & definitions with external source" do
372
372
  expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
373
373
  <iso-standard xmlns="http://riboseinc.com/isoxml">
374
+ <termdocsource type="inline" bibitemid="ISO712" citeas="ISO 712"/>
374
375
  <sections>
375
376
  <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
376
- <source type="inline" bibitemid="ISO712" citeas="ISO 712"/>
377
377
  <term id="J">
378
378
  <preferred>Term2</preferred>
379
379
  </term>
@@ -435,11 +435,11 @@ OUTPUT
435
435
  it "processes empty terms & definitions with external source" do
436
436
  expect(IsoDoc::Convert.new({}).convert_file(<<~"INPUT", "test", true)).to be_equivalent_to <<~"OUTPUT"
437
437
  <iso-standard xmlns="http://riboseinc.com/isoxml">
438
+ <termdocsource type="inline" bibitemid="ISO712" citeas="ISO 712"/>
439
+ <termdocsource type="inline" bibitemid="ISO712" citeas="ISO 712"/>
440
+ <termdocsource type="inline" bibitemid="ISO712" citeas="ISO 712"/>
438
441
  <sections>
439
442
  <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
440
- <source type="inline" bibitemid="ISO712" citeas="ISO 712"/>
441
- <source type="inline" bibitemid="ISO712" citeas="ISO 712"/>
442
- <source type="inline" bibitemid="ISO712" citeas="ISO 712"/>
443
443
  </terms>
444
444
  </sections>
445
445
  <references id="_normative_references" obligation="informative"><title>Normative References</title>
@@ -986,12 +986,12 @@ RSpec.describe IsoDoc do
986
986
  </subsection>
987
987
  </annex><references id="R" obligation="informative">
988
988
  <title>Normative References</title>
989
- </references><references id="S" obligation="informative">
989
+ </references><clause id="S" obligation="informative">
990
990
  <title>Bibliography</title>
991
991
  <references id="T" obligation="informative">
992
992
  <title>Bibliography Subsection</title>
993
993
  </references>
994
- </references>
994
+ </clause>
995
995
  </iso-standard>
996
996
  INPUT
997
997
  <html xmlns:epub="http://www.idpf.org/2007/ops">
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: 0.5.7
4
+ version: 0.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-18 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath