isodoc 1.0.1 → 1.0.2

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: 6f012ee1dfcb45c453231b1dbafd3eb84f4e3f1703998d7b804a42101fefbc03
4
- data.tar.gz: 48fb80967bdbd2265408c90c3fcabcef3e0539dff92d2d68a5422b3787ca5617
3
+ metadata.gz: 5dfad47b4bae84826332835e54c1010c3ffb1baad8c847db087255ba8a84099d
4
+ data.tar.gz: 7eda7444d72c11ef8993306d04fc400a4721174d6d379d12b87a2ba18bc710e6
5
5
  SHA512:
6
- metadata.gz: ff221e3f46b2e62a9c6bcb9df4676dfb4757dd73cc7d740d6dc366ec68a26cfa657af226a99592554046d78907ba9260fdd55a29d39e832332248887ad37d45c
7
- data.tar.gz: 61e23537cffb488ecd57346c1c47e6db6af63cdb7e9e96d3d7066e959cfea08a8709235ca4d0fce92431e823c5b4e3b94a8f7e7566388b687155d3518a936959
6
+ metadata.gz: 0d739c93248a158a13a553fbc2056883a873508caf32b26fbb61857ec899415f7bc4a06f732bed6885db34c926c79e6bb76199663ec444e6010eebae1239834f
7
+ data.tar.gz: 85b469117c9c27b0cda0de0979657bb4008bae9a225af388c6e9fc07c0813d56a07fd4812cced716864091406ebd04a41dec4ec7e2ebc7ce5f19e3728b59ca49
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
1
4
  source "https://rubygems.org"
5
+ git_source(:github) { |repo| "https://github.com/#{repo}" }
2
6
 
3
- # Specify your gem's dependencies in ribose.gemspec
4
7
  gemspec
8
+
9
+ if File.exist? 'Gemfile.devel'
10
+ eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
11
+ end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- isodoc (1.0.1)
4
+ isodoc (1.0.2)
5
5
  asciimath
6
6
  html2doc (~> 0.8.11)
7
7
  htmlentities (~> 4.3.4)
@@ -28,7 +28,7 @@ GEM
28
28
  nokogiri (>= 1.4.3)
29
29
  ffi (1.11.1)
30
30
  formatador (0.2.5)
31
- guard (2.15.0)
31
+ guard (2.15.1)
32
32
  formatador (>= 0.2.4)
33
33
  listen (>= 2.7, < 4.0)
34
34
  lumberjack (>= 1.0.12, < 2.0)
@@ -63,9 +63,9 @@ GEM
63
63
  asciidoctor
64
64
  htmlentities
65
65
  method_source (0.9.2)
66
- mime-types (3.2.2)
66
+ mime-types (3.3)
67
67
  mime-types-data (~> 3.2015)
68
- mime-types-data (3.2019.0331)
68
+ mime-types-data (3.2019.0904)
69
69
  mini_portile2 (2.4.0)
70
70
  nenv (0.3.0)
71
71
  nokogiri (1.10.4)
@@ -74,7 +74,7 @@ GEM
74
74
  nenv (~> 0.1)
75
75
  shellany (~> 0.0)
76
76
  parallel (1.17.0)
77
- parser (2.6.4.0)
77
+ parser (2.6.4.1)
78
78
  ast (~> 2.4.0)
79
79
  powerpack (0.1.2)
80
80
  pry (0.12.2)
@@ -12,10 +12,11 @@ module IsoDoc::Function
12
12
  def nonstd_bibitem(list, b, ordinal, bibliography)
13
13
  list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
14
14
  id = bibitem_ref_code(b)
15
+ identifier = render_identifier(id)
15
16
  if bibliography
16
- ref_entry_code(r, ordinal, id)
17
+ ref_entry_code(r, ordinal, identifier, id)
17
18
  else
18
- r << "#{id}, "
19
+ r << "#{identifier}, "
19
20
  end
20
21
  reference_format(b, r)
21
22
  end
@@ -24,7 +25,9 @@ module IsoDoc::Function
24
25
  def std_bibitem_entry(list, b, ordinal, biblio)
25
26
  list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
26
27
  prefix_bracketed_ref(ref, ordinal) if biblio
27
- ref << bibitem_ref_code(b)
28
+ id = bibitem_ref_code(b)
29
+ identifier = render_identifier(id)
30
+ ref << identifier
28
31
  date_note_process(b, ref)
29
32
  ref << ", "
30
33
  reference_format(b, ref)
@@ -33,19 +36,28 @@ module IsoDoc::Function
33
36
 
34
37
  # if t is just a number, only use that ([1] Non-Standard)
35
38
  # else, use both ordinal, as prefix, and t
36
- def ref_entry_code(r, ordinal, t)
37
- if /^\d+$/.match(t)
39
+ def ref_entry_code(r, ordinal, t, id)
40
+ if id["type"] == "metanorma"
38
41
  prefix_bracketed_ref(r, t)
39
42
  else
40
43
  prefix_bracketed_ref(r, ordinal)
41
- r << "#{t}, "
44
+ if !t.empty? && !%w(DOI ISSN ISBN).include?(id["type"])
45
+ r << "#{t}, "
46
+ end
42
47
  end
43
48
  end
44
49
 
45
50
  def bibitem_ref_code(b)
46
- id = b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma')]"))
47
- id ||= b.at(ns("./docidentifier[not(@type = 'DOI')]"))
48
- id ||= b.at(ns("./docidentifier")) or return "(NO ID)"
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')]"))
53
+ id ||= b.at(ns("./docidentifier"))
54
+ return id if id
55
+ id = Nokogiri::XML::Node.new("docidentifier", b.document)
56
+ id.text = "(NO ID)"
57
+ id
58
+ end
59
+
60
+ def render_identifier(id)
49
61
  docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
50
62
  end
51
63
 
@@ -110,7 +122,7 @@ module IsoDoc::Function
110
122
  def is_standard(b)
111
123
  ret = false
112
124
  b.xpath(ns("./docidentifier")).each do |id|
113
- next if id["type"].nil? || %w(metanorma DOI).include?(id["type"])
125
+ next if id["type"].nil? || %w(metanorma DOI ISSN ISBN).include?(id["type"])
114
126
  ret = true
115
127
  end
116
128
  ret
@@ -185,12 +197,11 @@ module IsoDoc::Function
185
197
 
186
198
  def reference_names(ref)
187
199
  isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
188
- docid = ref.at(ns("./docidentifier"))
189
- prefix = ref.at(ns("./docidentifier/@type"))
190
- # return ref_names(ref) unless docid
200
+ docid = bibitem_ref_code(ref)
201
+ prefix = docid["type"]
191
202
  date = ref.at(ns("./date[@type = 'published']"))
192
203
  allparts = ref.at(ns("./extent[@type='part'][referenceFrom='all']"))
193
- reference = format_ref(docid_l10n(docid.text), prefix&.text, isopub, date, allparts)
204
+ reference = format_ref(docid_l10n(docid.text), prefix, isopub, date, allparts)
194
205
  @anchors[ref["id"]] = { xref: reference }
195
206
  end
196
207
 
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
@@ -861,8 +861,8 @@ TOCLEVEL
861
861
  OUTPUT
862
862
  end
863
863
 
864
- it "propagates example style to paragraphs in postprocessing (Word)" do
865
- FileUtils.rm_f "test.doc"
864
+ it "propagates example style to paragraphs in postprocessing (Word)" do
865
+ FileUtils.rm_f "test.doc"
866
866
  FileUtils.rm_f "test.html"
867
867
  IsoDoc::WordConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
868
868
  <iso-standard xmlns="http://riboseinc.com/isoxml">
@@ -10,9 +10,12 @@ RSpec.describe IsoDoc do
10
10
  <preface><foreword>
11
11
  <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
12
12
  <eref bibitemid="ISO712"/>
13
+ <eref bibitemid="ISBN"/>
14
+ <eref bibitemid="ISSN"/>
13
15
  <eref bibitemid="ISO16634"/>
14
16
  <eref bibitemid="ref1"/>
15
17
  <eref bibitemid="ref10"/>
18
+ <eref bibitemid="ref12"/>
16
19
  </p>
17
20
  </foreword></preface>
18
21
  <bibliography><references id="_normative_references" obligation="informative"><title>Normative References</title>
@@ -63,6 +66,28 @@ RSpec.describe IsoDoc do
63
66
 
64
67
  </references><references id="_bibliography" obligation="informative">
65
68
  <title>Bibliography</title>
69
+ <bibitem id="ISBN" type="ISBN">
70
+ <title format="text/plain">Chemicals for analytical laboratory use</title>
71
+ <docidentifier type="ISBN">ISBN</docidentifier>
72
+ <docidentifier type="metanorma">[1]</docidentifier>
73
+ <contributor>
74
+ <role type="publisher"/>
75
+ <organization>
76
+ <abbreviation>ISBN</abbreviation>
77
+ </organization>
78
+ </contributor>
79
+ </bibitem>
80
+ <bibitem id="ISSN" type="ISSN">
81
+ <title format="text/plain">Instruments for analytical laboratory use</title>
82
+ <docidentifier type="ISSN">ISSN</docidentifier>
83
+ <docidentifier type="metanorma">[2]</docidentifier>
84
+ <contributor>
85
+ <role type="publisher"/>
86
+ <organization>
87
+ <abbreviation>ISSN</abbreviation>
88
+ </organization>
89
+ </contributor>
90
+ </bibitem>
66
91
  <bibitem id="ISO3696" type="standard">
67
92
  <title format="text/plain">Water for analytical laboratory use</title>
68
93
  <docidentifier type="ISO">ISO 3696</docidentifier>
@@ -81,6 +106,10 @@ RSpec.describe IsoDoc do
81
106
  <title>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</title>
82
107
  <docidentifier type="IETF">RFC 10</docidentifier>
83
108
  </bibitem>
109
+ <bibitem id="ref12">
110
+ <formattedref format="application/x-isodoc+xml">CitationWorks. 2019. <em>How to cite a reference</em>.</formattedref>
111
+ <docidentifier type="metanorma">[Citn]</docidentifier>
112
+ </bibitem>
84
113
 
85
114
 
86
115
  </references>
@@ -88,37 +117,43 @@ RSpec.describe IsoDoc do
88
117
  </iso-standard>
89
118
  INPUT
90
119
  #{HTML_HDR}
91
- <br/>
92
- <div>
93
- <h1 class="ForewordTitle">Foreword</h1>
94
- <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
120
+ <br/>
121
+ <div>
122
+ <h1 class="ForewordTitle">Foreword</h1>
123
+ <p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
95
124
  <a href="#ISO712">ISO 712</a>
125
+ <a href="#ISBN">[1]</a>
126
+ <a href="#ISSN">[2]</a>
96
127
  <a href="#ISO16634">ISO 16634:-- (all parts)</a>
97
128
  <a href="#ref1">ICC 167</a>
98
129
  <a href="#ref10">[10]</a>
130
+ <a href="#ref12">[Citn]</a>
99
131
  </p>
100
- </div>
101
- <p class="zzSTDTitle1"/>
102
- <div>
103
- <h1>1.&#160; Normative references</h1>
104
- <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>
105
- <p id="ISO712" class="NormRef">ISO 712, <i> Cereals and cereal products</i></p>
106
- <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>
107
- <p id="ISO20483" class="NormRef">ISO 20483:2013-2014, <i> Cereals and pulses</i></p>
108
- <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>
109
- </div>
110
- <br/>
111
- <div>
112
- <h1 class="Section3">Bibliography</h1>
113
- <p id="ISO3696" class="Biblio">[1]&#160; ISO 3696, <i> Water for analytical laboratory use</i></p>
114
- <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>
115
- <p id="ref11" class="Biblio">[3]&#160; IETF RFC 10, <i>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</i></p>
116
- </div>
117
- <aside id="fn:1" class="footnote">
132
+ </div>
133
+ <p class="zzSTDTitle1"/>
134
+ <div>
135
+ <h1>1.&#160; Normative references</h1>
136
+ <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>
137
+ <p id="ISO712" class="NormRef">ISO 712, <i>Cereals and cereal products</i></p>
138
+ <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
+ <p id="ISO20483" class="NormRef">ISO 20483:2013-2014, <i>Cereals and pulses</i></p>
140
+ <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>
141
+ </div>
142
+ <br/>
143
+ <div>
144
+ <h1 class="Section3">Bibliography</h1>
145
+ <p id="ISBN" class="Biblio">[1]&#160; <i>Chemicals for analytical laboratory use</i></p>
146
+ <p id="ISSN" class="Biblio">[2]&#160; <i>Instruments for analytical laboratory use</i></p>
147
+ <p id="ISO3696" class="Biblio">[3]&#160; ISO 3696, <i>Water for analytical laboratory use</i></p>
148
+ <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
+ <p id="ref11" class="Biblio">[5]&#160; IETF RFC 10, <i>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</i></p>
150
+ <p id="ref12" class="Biblio">[Citn]&#160; CitationWorks. 2019. <i>How to cite a reference</i>.</p>
151
+ </div>
152
+ <aside id="fn:1" class="footnote">
118
153
  <p>Under preparation. (Stage at the time of publication ISO/DIS 16634)</p>
119
154
  </aside>
120
- </div>
121
- </body>
155
+ </div>
156
+ </body>
122
157
  </html>
123
158
  OUTPUT
124
159
  end
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.1
4
+ version: 1.0.2
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-01 00:00:00.000000000 Z
11
+ date: 2019-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath