metanorma-ogc 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,106 @@
1
+ module IsoDoc
2
+ module Ogc
3
+ module BaseConvert
4
+ def iso_bibitem_entry(list, b, ordinal, biblio)
5
+ return if implicit_reference(b)
6
+ list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
7
+ prefix_bracketed_ref(ref, ordinal) if biblio
8
+ standard_citation(ref, b)
9
+ end
10
+ end
11
+
12
+ def noniso_bibitem(list, b, ordinal, bibliography)
13
+ list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
14
+ if bibliography
15
+ id = docid_l10n(b.at(ns("./docidentifier")).text.gsub(/[\[\]]/, ""))
16
+ prefix = b&.at(ns("./docidentifier/@type"))&.text
17
+ ref_entry_code(r, ordinal, prefix, id) unless prefix
18
+ end
19
+ reference_format(b, r)
20
+ end
21
+ end
22
+
23
+ def reference_format(b, r)
24
+ if ftitle = b.at(ns("./formattedref"))
25
+ ftitle&.children&.each { |n| parse(n, r) }
26
+ else
27
+ # eventually will be full LNCS reference
28
+ standard_citation(r, b)
29
+ end
30
+ end
31
+
32
+ def multiplenames(names)
33
+ names.join(", ")
34
+ end
35
+
36
+ def multiplenames_and(names)
37
+ return "" if names.length == 0
38
+ return names[0] if names.length == 1
39
+ return "#{names[0]} and #{names[1]}" if names.length == 2
40
+ names[0..-2].join(", ") + " and #{names[-1]}"
41
+ end
42
+
43
+ def nodes_to_span(n)
44
+ noko do |xml|
45
+ xml.span do |s|
46
+ n&.children&.each { |x| parse(x, s) }
47
+ end
48
+ end.join("")
49
+ end
50
+
51
+ def extract_publisher(b)
52
+ c = b.xpath(ns("./contributor[role/@type = 'publisher'][organization]"))
53
+ abbrs = []
54
+ names = []
55
+ c&.each do |c1|
56
+ n = c1.at(ns("./organization/name")) or next
57
+ abbrs << (c1.at(ns("./organization/abbreviation")) || n)
58
+ names << nodes_to_span(n)
59
+ end
60
+ return [nil, nil] if names.empty?
61
+ return [multiplenames_and(names), (abbrs.map { |x| x.text }).join("/")]
62
+ end
63
+
64
+ def date_render(date)
65
+ return nil if date.nil?
66
+ on = date&.at(ns("./on"))&.text
67
+ from = date&.at(ns("./from"))&.text
68
+ to = date&.at(ns("./to"))&.text
69
+ return on if on
70
+ return "#{from}&ndash;#{to}" if from
71
+ nil
72
+ end
73
+
74
+ def extract_year(b)
75
+ d = b.at(ns("./date[@type = 'published']")) ||
76
+ b.at(ns("./date[@type = 'issued']")) ||
77
+ b.at(ns("./date[@type = 'circulated']")) ||
78
+ b.at(ns("./date"))
79
+ date_render(d)
80
+ end
81
+
82
+ def extract_city(b)
83
+ b.at(ns("./place"))
84
+ end
85
+
86
+ # {author}: {document identifier}, {title}. {publisher}, {city} ({year})
87
+ def standard_citation(out, b)
88
+ pub, pub_abbrev = extract_publisher(b)
89
+ c = extract_city(b)
90
+ y = extract_year(b)
91
+ out << "#{pub_abbrev}: " if pub_abbrev
92
+ out << iso_bibitem_ref_code(b)
93
+ out << ", "
94
+ out.i do |i|
95
+ iso_title(b)&.children&.each { |n| parse(n, i) }
96
+ end
97
+ out << ". "
98
+ out << pub if pub
99
+ out << ", " if pub && c
100
+ c&.children&.each { |n| parse(n, out) }
101
+ out << " " if (pub || c) && y
102
+ out << "(#{y})." if y
103
+ end
104
+ end
105
+ end
106
+ end
@@ -888,7 +888,7 @@ h2 p {
888
888
  font-weight: 100;
889
889
  padding-left: 1em;
890
890
  padding-right: 1em;
891
- text-transform: uppercase;
891
+ /* text-transform: uppercase; */
892
892
  }
893
893
 
894
894
  .coverpage-title span {
@@ -0,0 +1,81 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+ require "fileutils"
4
+
5
+ module IsoDoc
6
+ module Ogc
7
+ module BaseConvert
8
+ def recommend_table_attr(node)
9
+ attr_code(id: node["id"], class: "recommend",
10
+ cellspacing: 0, cellpadding: 0,
11
+ style: "border-collapse:collapse" )
12
+ end
13
+
14
+ REQ_TBL_ATTR =
15
+ { valign: "top", class: "example_label",
16
+ style: "width:100.0pt;padding:0 0 0 1em;margin-left:0pt" }.freeze
17
+
18
+ def recommendation_name(node, out, type)
19
+ out.p **{ class: "AdmonitionTitle" } do |b|
20
+ lbl = anchor(node['id'], :label, false)
21
+ b << (lbl.nil? ? l10n("#{type}:") : l10n("#{type} #{lbl}:"))
22
+ end
23
+ end
24
+
25
+ def recommend_title(node, div)
26
+ label = node.at(ns("./label"))
27
+ title = node.at(ns("./title"))
28
+ label || title or return
29
+ div.p do |p|
30
+ p.b do |b|
31
+ label and label.children.each { |n| parse(n,b) }
32
+ b << "#{clausedelim} " if label && title
33
+ title and title.children.each { |n| parse(n,b) }
34
+ end
35
+ end
36
+ end
37
+
38
+ def recommendation_body(node, tr)
39
+ tr.td **{ valign: "top", class: "recommend" } do |td|
40
+ recommend_title(node, td)
41
+ node.children.each do |n|
42
+ parse(n, td) unless %(label title).include?(n.name)
43
+ end
44
+ end
45
+ end
46
+
47
+ def recommendation_parse(node, out)
48
+ out.table **recommend_table_attr(node) do |t|
49
+ t.tr do |tr|
50
+ tr.td **REQ_TBL_ATTR do |td|
51
+ recommendation_name(node, td, @recommendation_lbl)
52
+ end
53
+ recommendation_body(node, tr)
54
+ end
55
+ end
56
+ end
57
+
58
+ def requirement_parse(node, out)
59
+ out.table **recommend_table_attr(node) do |t|
60
+ t.tr do |tr|
61
+ tr.td **REQ_TBL_ATTR do |td|
62
+ recommendation_name(node, td, @requirement_lbl)
63
+ end
64
+ recommendation_body(node, tr)
65
+ end
66
+ end
67
+ end
68
+
69
+ def permission_parse(node, out)
70
+ out.table **recommend_table_attr(node) do |t|
71
+ t.tr do |tr|
72
+ tr.td **REQ_TBL_ATTR do |td|
73
+ recommendation_name(node, td, @permission_lbl)
74
+ end
75
+ recommendation_body(node, tr)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Ogc
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-ogc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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-07-29 00:00:00.000000000 Z
11
+ date: 2019-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -272,6 +272,7 @@ files:
272
272
  - bin/rspec
273
273
  - bin/setup
274
274
  - lib/asciidoctor/ogc.rb
275
+ - lib/asciidoctor/ogc/basicdoc.rng
275
276
  - lib/asciidoctor/ogc/biblio.rng
276
277
  - lib/asciidoctor/ogc/converter.rb
277
278
  - lib/asciidoctor/ogc/front.rb
@@ -282,6 +283,7 @@ files:
282
283
  - lib/asciidoctor/ogc/validate.rb
283
284
  - lib/isodoc/ogc.rb
284
285
  - lib/isodoc/ogc/base_convert.rb
286
+ - lib/isodoc/ogc/biblio.rb
285
287
  - lib/isodoc/ogc/html/header.html
286
288
  - lib/isodoc/ogc/html/html_ogc_intro.html
287
289
  - lib/isodoc/ogc/html/html_ogc_titlepage.html
@@ -296,6 +298,7 @@ files:
296
298
  - lib/isodoc/ogc/i18n-en.yaml
297
299
  - lib/isodoc/ogc/metadata.rb
298
300
  - lib/isodoc/ogc/pdf_convert.rb
301
+ - lib/isodoc/ogc/reqt.rb
299
302
  - lib/isodoc/ogc/word_convert.rb
300
303
  - lib/metanorma-ogc.rb
301
304
  - lib/metanorma/ogc.rb