metanorma-nist 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bab11b072819d5c1ca9ddf38c87144d724fbb4bdd24908ef07ba463448917027
4
- data.tar.gz: 7d9153055e1f188f1355b289dc22da96754a1864b64ccaf87c503dc02ab75a4a
3
+ metadata.gz: '058ea96daf6a2940d6a1b2b2ddb8464f13a62389c006cfcf423dfa57d5d33c11'
4
+ data.tar.gz: 47dd1e6208cdf299e9b2146dfe92f0003a66e7b0ca6f169c50dd9a1792627c48
5
5
  SHA512:
6
- metadata.gz: 29e8aab3e4e244abe3c889e354eb368c67b3c2a66922ab7efd0be885a7b8118163e8e45ae453177ffdba9ebf12c2fa68091b20347d6257590ccc91df38d5fb39
7
- data.tar.gz: e13976985ddb04f3c30d8dca1aa74306231d62b883b93be40fee082fe35b8e6b31c94311f1f50dee5c5614c8f11a7a8471c765595452a2abdc4b480814866fda
6
+ metadata.gz: 423c8ba7e534b31b3176e22234937d58a3ae2599e45f0bb476822c05752d4fd9b407df989bba48c19be262c28fcb80fe67df4e107b8632f50fb80ffc9803b8b8
7
+ data.tar.gz: 9ed5d3661a6804ac4c75a58a2b17effe96115e066d7179bc376a539f097e6249383c1baeed5c26ad4bfddac500142e78741abf8c8030de1ecb69f11c339301a0
data/Gemfile CHANGED
@@ -1,6 +1,11 @@
1
- source "https://rubygems.org"
2
- git_source(:github) {|repo| "https://github.com/#{repo}" }
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
3
 
4
- #gem "metanorma-standoc", git: "https://github.com/metanorma/metanorma-standoc"
4
+ source "https://rubygems.org"
5
+ git_source(:github) { |repo| "https://github.com/#{repo}" }
5
6
 
6
7
  gemspec
8
+
9
+ if File.exist? 'Gemfile.devel'
10
+ eval File.read('Gemfile.devel'), nil, 'Gemfile.devel' # rubocop:disable Security/Eval
11
+ end
@@ -135,6 +135,44 @@ module Asciidoctor
135
135
  end
136
136
  ret
137
137
  end
138
+
139
+ TERM_CLAUSE = "//sections/terms | "\
140
+ "//sections/clause[descendant::terms] | "\
141
+ "//annex/terms | "\
142
+ "//annex/clause[descendant::terms] ".freeze
143
+
144
+ def boilerplate_cleanup(xmldoc)
145
+ isodoc = IsoDoc::Convert.new({})
146
+ @lang = xmldoc&.at("//bibdata/language")&.text
147
+ @script = xmldoc&.at("//bibdata/script")&.text
148
+ isodoc.i18n_init(@lang, @script)
149
+ f = xmldoc.at(self.class::TERM_CLAUSE) and
150
+ term_defs_boilerplate(f.at("../title"),
151
+ xmldoc.xpath(".//termdocsource"),
152
+ f.at(".//term"), f.at(".//p"), isodoc)
153
+ end
154
+
155
+ def sort_biblio(bib)
156
+ @citation_order = {}
157
+ bib.document.xpath("//xref | //origin").each_with_index do |x, i|
158
+ cit = x["target"] || x["bibitemid"]
159
+ next unless refid? cit
160
+ @citation_order[cit] ||= i
161
+ end
162
+ bib.sort do |a, b|
163
+ sort_biblio_key(a) <=> sort_biblio_key(b)
164
+ end
165
+ end
166
+
167
+ # if numeric citation, order by appearance. if alphanumeric, sort alphabetically
168
+ def sort_biblio_key(bib)
169
+ if metaid = bib&.at("./docidentifier[@type = 'metanorma']")&.text&.gsub(%r{[\[\]]}, "")
170
+ key = /^\[\d+\]$/.match(metaid) ? ( @citation_order[metaid] % "09%d" ) : metaid
171
+ end
172
+ title = bib&.at("./title[@type = 'main']")&.text ||
173
+ bib&.at("./title")&.text || bib&.at("./formattedref")&.text
174
+ "#{key} :: #{title}"
175
+ end
138
176
  end
139
177
  end
140
178
  end
@@ -237,22 +237,6 @@ module Asciidoctor
237
237
  end
238
238
  end
239
239
 
240
- TERM_CLAUSE = "//sections/terms | "\
241
- "//sections/clause[descendant::terms] | "\
242
- "//annex/terms | "\
243
- "//annex/clause[descendant::terms] ".freeze
244
-
245
- def boilerplate_cleanup(xmldoc)
246
- isodoc = IsoDoc::Convert.new({})
247
- @lang = xmldoc&.at("//bibdata/language")&.text
248
- @script = xmldoc&.at("//bibdata/script")&.text
249
- isodoc.i18n_init(@lang, @script)
250
- f = xmldoc.at(self.class::TERM_CLAUSE) and
251
- term_defs_boilerplate(f.at("../title"),
252
- xmldoc.xpath(".//termdocsource"),
253
- f.at(".//term"), f.at(".//p"), isodoc)
254
- end
255
-
256
240
  NIST_PREFIX_REFS = "SP|FIPS"
257
241
 
258
242
  def refitem(xml, item, node)
@@ -26,28 +26,28 @@ module Asciidoctor
26
26
  def title_subtitle(node, t, at)
27
27
  return unless node.attr("title-sub")
28
28
  t.title(**attr_code(at.merge(type: "subtitle"))) do |t1|
29
- t1 << asciidoc_sub(node.attr("title-sub"))
29
+ t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub"))
30
30
  end
31
31
  node.attr("title-sub-short") and
32
32
  t.title(**attr_code(at.merge(type: "short-subtitle"))) do |t1|
33
- t1 << asciidoc_sub(node.attr("title-sub-short"))
33
+ t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub-short"))
34
34
  end
35
35
  end
36
36
 
37
37
  def title_document_class(node, t, at)
38
38
  return unless node.attr("title-document-class")
39
39
  t.title(**attr_code(at.merge(type: "document-class"))) do |t1|
40
- t1 << asciidoc_sub(node.attr("title-document-class"))
40
+ t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-document-class"))
41
41
  end
42
42
  end
43
43
 
44
44
  def title_main(node, t, at)
45
45
  t.title(**attr_code(at.merge(type: "main"))) do |t1|
46
- t1 << asciidoc_sub(node.attr("title-main") || node.title)
46
+ t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main") || node.title)
47
47
  end
48
48
  node.attr("title-main-short") and
49
49
  t.title(**attr_code(at.merge(type: "short-title"))) do |t1|
50
- t1 << asciidoc_sub(node.attr("title-main-short"))
50
+ t1 << Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main-short"))
51
51
  end
52
52
  end
53
53
 
@@ -263,16 +263,16 @@ module Asciidoctor
263
263
 
264
264
  def metadata_superseding_titles(b, node)
265
265
  if node.attr("superseding-title")
266
- b.title asciidoc_sub(node.attr("superseding-title")),
266
+ b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-title")),
267
267
  **{ type: "main" }
268
268
  node.attr("superseding-subtitle") and
269
- b.title asciidoc_sub(node.attr("superseding-subtitle")),
269
+ b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("superseding-subtitle")),
270
270
  **{ type: "subtitle" }
271
271
  else
272
- b.title asciidoc_sub(node.attr("title-main") || node.title),
272
+ b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-main") || node.title),
273
273
  **{ type: "main" }
274
274
  node.attr("title-sub") and
275
- b.title asciidoc_sub(node.attr("title-sub")), **{ type: "subtitle" }
275
+ b.title Asciidoctor::Standoc::Utils::asciidoc_sub(node.attr("title-sub")), **{ type: "subtitle" }
276
276
  end
277
277
  end
278
278
 
@@ -251,13 +251,14 @@ module IsoDoc
251
251
  end
252
252
 
253
253
  def reference_format(b, r)
254
- code = bibitem_ref_code(b)
255
- if /^\d+$/.match(code)
254
+ id = bibitem_ref_code(b)
255
+ code = render_identifier(id)
256
+ if id["type"] == "metanorma"
256
257
  r << "[#{code}] "
257
258
  insert_tab(r, 1)
258
259
  end
259
260
  reference_format1(b, r)
260
- r << " [#{code}] " unless /^\d+$/.match(code)
261
+ r << " [#{code}] " unless id["type"] == "metanorma"
261
262
  end
262
263
 
263
264
  def reference_format1(b, r)
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module NIST
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-nist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-02 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: asciidoctor