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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/isodoc/function/inline.rb +2 -1
- data/lib/isodoc/function/references.rb +1 -1
- data/lib/isodoc/function/section.rb +7 -7
- data/lib/isodoc/function/xref_gen.rb +8 -6
- data/lib/isodoc/version.rb +1 -1
- data/spec/isodoc/ref_spec.rb +1 -1
- data/spec/isodoc/section_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ae7f6c154716e6a0096058610667183d6f1b963bcc53349384bfc467266bf25
|
4
|
+
data.tar.gz: 0bc77874b82d3ab7212d15a3334402070e7c5d54e9f3b32a66c664535761901c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ff1b4b21ee64655f5c8f5fc85654322934342fe2800a99b7f3f01c4c47e259e2aa707c6ba60c2f8181bdb3a280e8652ccc841fca04d2c4b0a6794dbecfd654
|
7
|
+
data.tar.gz: e9a3bf1c450308324e884095aff193e92b7c77ed114d0c35790a47dcb618e70e433199031bd76ba448fbd01b4ca59076e0d29231e2d0a5c6c78738f1405e3426
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
isodoc (0.8.
|
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.
|
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 += " (
|
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
|
-
|
118
|
-
|
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("
|
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("
|
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
|
data/lib/isodoc/version.rb
CHANGED
data/spec/isodoc/ref_spec.rb
CHANGED
@@ -94,7 +94,7 @@ RSpec.describe IsoDoc do
|
|
94
94
|
<h1>1.  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:-- (
|
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–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>
|
data/spec/isodoc/section_spec.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2018-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|