isodoc 0.8.10 → 0.8.11

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: 490b26d07e91c826370a8a6696812ef57d85a88922cc155cf9f8ca516222c8ba
4
- data.tar.gz: 84e35c5302f47ed2d6df479c7294dd01b3077d6f279b5d3fd5a38e5dda414d70
3
+ metadata.gz: 9ae7f6c154716e6a0096058610667183d6f1b963bcc53349384bfc467266bf25
4
+ data.tar.gz: 0bc77874b82d3ab7212d15a3334402070e7c5d54e9f3b32a66c664535761901c
5
5
  SHA512:
6
- metadata.gz: 21b930c00f572fac0367cc06e08c2c901981804e0829231d55e48917c09ee6752cd49f2950760f33d1921c1ea0ee521008fe4986023e984d45c1243c00b34c7f
7
- data.tar.gz: 667364e6cb59e71c2c71188b5dd8e8cbefe1885dce1bd1f2aece10dfe7a53d830a08d326b9226f117d16afa5e58ee7cd9e81c2a93db071e44ede4b7bc9182504
6
+ metadata.gz: 32ff1b4b21ee64655f5c8f5fc85654322934342fe2800a99b7f3f01c4c47e259e2aa707c6ba60c2f8181bdb3a280e8652ccc841fca04d2c4b0a6794dbecfd654
7
+ data.tar.gz: e9a3bf1c450308324e884095aff193e92b7c77ed114d0c35790a47dcb618e70e433199031bd76ba448fbd01b4ca59076e0d29231e2d0a5c6c78738f1405e3426
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isodoc (0.8.10)
4
+ isodoc (0.8.11)
5
5
  asciimath
6
6
  html2doc (~> 0.8.1)
7
7
  htmlentities (~> 4.3.4)
@@ -41,7 +41,7 @@ GEM
41
41
  guard (~> 2.1)
42
42
  guard-compat (~> 1.1)
43
43
  rspec (>= 2.99.0, < 4.0)
44
- html2doc (0.8.2)
44
+ html2doc (0.8.3)
45
45
  asciimath
46
46
  htmlentities (~> 4.3.4)
47
47
  image_size
@@ -25,7 +25,8 @@ module IsoDoc::Function
25
25
  def anchor_linkend(node, linkend)
26
26
  if node["citeas"].nil? && node["bibitemid"] &&
27
27
  get_anchors.has_key?(node["bibitemid"])
28
- return get_anchors[node["bibitemid"]][:xref]
28
+ #return get_anchors[node["bibitemid"]][:xref]
29
+ return get_anchors.dig(node["bibitemid"] ,:xref)
29
30
  elsif node["target"] && get_anchors.has_key?(node["target"])
30
31
  linkend = get_anchors[node["target"]][:xref]
31
32
  container = get_anchors[node["target"]][:container]
@@ -14,7 +14,7 @@ module IsoDoc::Function
14
14
  iso_allparts = b.at(ns("./allparts"))
15
15
  reference = docid_l10n(isocode)
16
16
  reference += ":#{date_range(isodate)}" if isodate
17
- reference += " (all parts)" if iso_allparts&.text == "true"
17
+ reference += " (#{@all_parts_lbl})" if iso_allparts&.text == "true"
18
18
  reference
19
19
  end
20
20
 
@@ -96,14 +96,15 @@ module IsoDoc::Function
96
96
  end
97
97
 
98
98
  def external_terms_boilerplate(sources)
99
- @external_terms_boilerplate.gsub(/%/, sources)
99
+ @external_terms_boilerplate.gsub(/%/, sources || "???")
100
100
  end
101
101
 
102
102
  def internal_external_terms_boilerplate(sources)
103
- @internal_external_terms_boilerplate.gsub(/%/, sources)
103
+ @internal_external_terms_boilerplate.gsub(/%/, sources || "??")
104
104
  end
105
105
 
106
106
  def term_defs_boilerplate(div, source, term, preface)
107
+ source.each { |s| @anchors[s["bibitemid"]] or warn "#{s['bibitemid']} not referenced" }
107
108
  if source.empty? && term.nil?
108
109
  div << @no_terms_boilerplate
109
110
  else
@@ -113,11 +114,10 @@ module IsoDoc::Function
113
114
  end
114
115
 
115
116
  def term_defs_boilerplate_cont(src, term)
116
- sources = sentence_join(src.map { |s| @anchors[s["bibitemid"]][:xref] })
117
- if src.empty?
118
- @internal_terms_boilerplate
119
- elsif term.nil?
120
- external_terms_boilerplate(sources)
117
+ #sources = sentence_join(src.map { |s| @anchors[s["bibitemid"]][:xref] })
118
+ sources = sentence_join(src.map { |s| @anchors.dig(s["bibitemid"], :xref) })
119
+ if src.empty? then @internal_terms_boilerplate
120
+ elsif term.nil? then external_terms_boilerplate(sources)
121
121
  else
122
122
  internal_external_terms_boilerplate(sources)
123
123
  end
@@ -14,25 +14,27 @@ module IsoDoc::Function
14
14
  end
15
15
 
16
16
  def termnote_anchor_names(docxml)
17
- docxml.xpath(ns("//term[termnote]")).each do |t|
18
- t.xpath(ns("./termnote")).each_with_index do |n, i|
17
+ docxml.xpath(ns("//term[descendant::termnote]")).each do |t|
18
+ t.xpath(ns(".//termnote")).each_with_index do |n, i|
19
19
  return if n["id"].nil? || n["id"].empty?
20
20
  @anchors[n["id"]] =
21
21
  { label: termnote_label(i + 1),
22
- xref: l10n("#{@anchors[t['id']][:xref]}, "\
22
+ #xref: l10n("#{@anchors[t['id']][:xref]}, "\
23
+ xref: l10n("#{@anchors.dig(t['id'], :xref)}, "\
23
24
  "#{@note_xref_lbl} #{i + 1}") }
24
25
  end
25
26
  end
26
27
  end
27
28
 
28
29
  def termexample_anchor_names(docxml)
29
- docxml.xpath(ns("//term[termexample]")).each do |t|
30
- examples = t.xpath(ns("./termexample"))
30
+ docxml.xpath(ns("//term[descendant::termexample]")).each do |t|
31
+ examples = t.xpath(ns(".//termexample"))
31
32
  examples.each_with_index do |n, i|
32
33
  return if n["id"].nil? || n["id"].empty?
33
34
  idx = examples.size == 1 ? "" : (i + 1).to_s
34
35
  @anchors[n["id"]] = {
35
- label: idx, xref: l10n("#{@anchors[t['id']][:xref]}, "\
36
+ #label: idx, xref: l10n("#{@anchors[t['id']][:xref]}, "\
37
+ label: idx, xref: l10n("#{@anchors.dig(t['id'], :xref)}, "\
36
38
  "#{@note_xref_lbl} #{i + 1}") }
37
39
  end
38
40
  end
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "0.8.10".freeze
2
+ VERSION = "0.8.11".freeze
3
3
  end
@@ -94,7 +94,7 @@ RSpec.describe IsoDoc do
94
94
  <h1>1.&#160; Normative references</h1>
95
95
  <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>
96
96
  <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
97
- <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>
97
+ <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>
98
98
  <p id="ISO20483" class="NormRef">ISO 20483:2013&#8211;2014, <i> Cereals and pulses</i></p>
99
99
  <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>
100
100
  </div>
@@ -349,6 +349,22 @@ OUTPUT
349
349
  OUTPUT
350
350
  end
351
351
 
352
+ it "warn about external source for terms & definitions that does not point anywhere" do
353
+ expect{ IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true) }.to output(/not referenced/).to_stderr
354
+ <iso-standard xmlns="http://riboseinc.com/isoxml">
355
+ <termdocsource type="inline" bibitemid="ISO712"/>
356
+ <sections>
357
+ <terms id="H" obligation="normative"><title>Terms, Definitions, Symbols and Abbreviated Terms</title>
358
+ <term id="J">
359
+ <preferred>Term2</preferred>
360
+ </term>
361
+ </terms>
362
+ </sections>
363
+ </iso-standard>
364
+ INPUT
365
+ end
366
+
367
+
352
368
  it "processes terms & definitions with external source" do
353
369
  expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
354
370
  <iso-standard xmlns="http://riboseinc.com/isoxml">
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.8.10
4
+ version: 0.8.11
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-08-25 00:00:00.000000000 Z
11
+ date: 2018-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath