metanorma-iho 0.5.8 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ module IsoDoc
16
16
 
17
17
  def i18n_init(lang, script, i18nyaml = nil)
18
18
  @i18n = I18n.new(
19
- lang, script, i18nyaml ||
19
+ lang, script, i18nyaml: i18nyaml ||
20
20
  Metanorma::IHO.configuration.i18nyaml || @i18nyaml
21
21
  )
22
22
  end
@@ -4,14 +4,14 @@ module IsoDoc
4
4
  module IHO
5
5
  # A {Converter} implementation that generates PDF HTML output, and a
6
6
  # document schema encapsulation of the document for validation
7
- class PdfConvert < IsoDoc::XslfoPdfConvert
7
+ class PdfConvert < IsoDoc::XslfoPdfConvert
8
8
  def initialize(options)
9
9
  @libdir = File.dirname(__FILE__)
10
10
  super
11
11
  end
12
12
 
13
13
  def pdf_stylesheet(docxml)
14
- case doctype = docxml&.at(ns("//bibdata/ext/doctype"))&.text
14
+ case docxml&.at(ns("//bibdata/ext/doctype"))&.text
15
15
  when "standard" then "iho.standard.xsl"
16
16
  else
17
17
  "iho.specification.xsl"
@@ -20,4 +20,3 @@ module IsoDoc
20
20
  end
21
21
  end
22
22
  end
23
-
@@ -1,12 +1,16 @@
1
1
  require_relative "init"
2
2
  require "isodoc"
3
3
  require "metanorma-generic"
4
+ require_relative "../../relaton/render/general"
4
5
 
5
6
  module IsoDoc
6
7
  module IHO
7
8
  class PresentationXMLConvert < IsoDoc::Generic::PresentationXMLConvert
9
+ def bibrenderer
10
+ ::Relaton::Render::IHO::General.new(language: @lang)
11
+ end
12
+
8
13
  include Init
9
14
  end
10
15
  end
11
16
  end
12
-
@@ -21,8 +21,9 @@ module IsoDoc
21
21
  @anchors[clause["id"]] =
22
22
  { label: annex_name_lbl(clause, num), type: "clause", elem: lbl,
23
23
  xref: l10n("#{lbl} #{num}"), level: 1, value: num }
24
- if a = single_annex_special_section(clause)
25
- annex_names1(a, num.to_s, 1)
24
+ if @klass.single_term_clause?(clause)
25
+ annex_names1(clause.at(ns("./references | ./terms | ./definitions")),
26
+ num.to_s, 1)
26
27
  else
27
28
  i = Counter.new
28
29
  clause.xpath(ns("./clause | ./references | ./terms | ./definitions"))
@@ -36,17 +37,19 @@ module IsoDoc
36
37
 
37
38
  def back_anchor_names(docxml)
38
39
  super
39
- i = Counter.new
40
- docxml.xpath(ns("//annex[@obligation = 'informative']"))
41
- .each do |c|
42
- i.increment(c)
43
- annex_names(c, i.print)
44
- end
45
- i = Counter.new("@", skip_i: true)
46
- docxml.xpath(ns("//annex[not(@obligation = 'informative')]"))
47
- .each do |c|
48
- i.increment(c)
49
- annex_names(c, i.print)
40
+ if @parse_settings.empty? || @parse_settings[:clauses]
41
+ i = Counter.new
42
+ docxml.xpath(ns("//annex[@obligation = 'informative']"))
43
+ .each do |c|
44
+ i.increment(c)
45
+ annex_names(c, i.print)
46
+ end
47
+ i = Counter.new("@", skip_i: true)
48
+ docxml.xpath(ns("//annex[not(@obligation = 'informative')]"))
49
+ .each do |c|
50
+ i.increment(c)
51
+ annex_names(c, i.print)
52
+ end
50
53
  end
51
54
  end
52
55
 
@@ -851,17 +851,46 @@
851
851
  </define>
852
852
  <define name="bplace">
853
853
  <element name="place">
854
- <optional>
855
- <attribute name="uri">
856
- <data type="anyURI"/>
857
- </attribute>
858
- </optional>
859
- <optional>
860
- <attribute name="region"/>
861
- </optional>
854
+ <choice>
855
+ <text/>
856
+ <group>
857
+ <ref name="bibliocity"/>
858
+ <zeroOrMore>
859
+ <ref name="biblioregion"/>
860
+ </zeroOrMore>
861
+ <zeroOrMore>
862
+ <ref name="bibliocountry"/>
863
+ </zeroOrMore>
864
+ </group>
865
+ </choice>
866
+ </element>
867
+ </define>
868
+ <define name="bibliocity">
869
+ <element name="city">
862
870
  <text/>
863
871
  </element>
864
872
  </define>
873
+ <define name="biblioregion">
874
+ <element name="region">
875
+ <ref name="RegionType"/>
876
+ </element>
877
+ </define>
878
+ <define name="bibliocountry">
879
+ <element name="country">
880
+ <ref name="RegionType"/>
881
+ </element>
882
+ </define>
883
+ <define name="RegionType">
884
+ <optional>
885
+ <attribute name="iso"/>
886
+ </optional>
887
+ <optional>
888
+ <attribute name="recommended">
889
+ <data type="boolean"/>
890
+ </attribute>
891
+ </optional>
892
+ <text/>
893
+ </define>
865
894
  <define name="bprice">
866
895
  <element name="price">
867
896
  <attribute name="currency"/>
@@ -32,6 +32,43 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="admonition">
36
+ <element name="admonition">
37
+ <attribute name="type">
38
+ <ref name="AdmonitionType"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="class"/>
42
+ </optional>
43
+ <attribute name="id">
44
+ <data type="ID"/>
45
+ </attribute>
46
+ <optional>
47
+ <attribute name="uri">
48
+ <data type="anyURI"/>
49
+ </attribute>
50
+ </optional>
51
+ <optional>
52
+ <attribute name="coverpage">
53
+ <data type="boolean"/>
54
+ </attribute>
55
+ </optional>
56
+ <optional>
57
+ <attribute name="notag">
58
+ <data type="boolean"/>
59
+ </attribute>
60
+ </optional>
61
+ <optional>
62
+ <ref name="tname"/>
63
+ </optional>
64
+ <zeroOrMore>
65
+ <ref name="paragraph-with-footnote"/>
66
+ </zeroOrMore>
67
+ <zeroOrMore>
68
+ <ref name="note"/>
69
+ </zeroOrMore>
70
+ </element>
71
+ </define>
35
72
  <define name="index">
36
73
  <element name="index">
37
74
  <optional>
@@ -851,6 +888,16 @@
851
888
  <ref name="MultilingualRenderingType"/>
852
889
  </attribute>
853
890
  </optional>
891
+ <optional>
892
+ <attribute name="coverpage">
893
+ <data type="boolean"/>
894
+ </attribute>
895
+ </optional>
896
+ <optional>
897
+ <attribute name="notag">
898
+ <data type="boolean"/>
899
+ </attribute>
900
+ </optional>
854
901
  <oneOrMore>
855
902
  <choice>
856
903
  <ref name="paragraph"/>
@@ -1178,6 +1225,7 @@
1178
1225
  <ref name="concept"/>
1179
1226
  <ref name="add"/>
1180
1227
  <ref name="del"/>
1228
+ <ref name="span"/>
1181
1229
  </choice>
1182
1230
  </define>
1183
1231
  <define name="add">
@@ -1204,6 +1252,14 @@
1204
1252
  </choice>
1205
1253
  </element>
1206
1254
  </define>
1255
+ <define name="span">
1256
+ <element name="span">
1257
+ <attribute name="class"/>
1258
+ <oneOrMore>
1259
+ <ref name="TextElement"/>
1260
+ </oneOrMore>
1261
+ </element>
1262
+ </define>
1207
1263
  <define name="concept">
1208
1264
  <element name="concept">
1209
1265
  <optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IHO
3
- VERSION = "0.5.8".freeze
3
+ VERSION = "0.6.0".freeze
4
4
  end
5
5
  end
@@ -0,0 +1,8 @@
1
+ template:
2
+ # skip standardidentifier, it is inserted in front of formattedref within metanorma
3
+ standard: "{{ standardidentifier | first }} edition_{{ edition }} : {{ title }}, {{ creatornames }} ,_{{role}} ({{ uri }}) ."
4
+ misc: standard
5
+ nametemplate:
6
+ one: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0]}}{% endif %}"
7
+ two: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0]}}{% endif %} and {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1]}}{% endif %}"
8
+ more: "{% if nonpersonal[0] %}{{ nonpersonal[0] }}{% else %}{{surname[0] }} {{initials[0]}} {% endif %} , {% if nonpersonal[1] %}{{ nonpersonal[1] }}{% else %}{{surname[1]}} {{ initials[1]}} {% endif %} and {% if nonpersonal[2] %}{{ nonpersonal[2] }}{% else %}{{surname[2]}} {{initials[2]}}{% endif %}"
@@ -0,0 +1,23 @@
1
+ module Relaton
2
+ module Render
3
+ module IHO
4
+ class Fields < ::Relaton::Render::Fields
5
+ def edition_fields_format(hash)
6
+ super
7
+ hash[:publisher_raw]&.any? do |p|
8
+ ["IHO", "International Hydrographic Organization"]
9
+ .include?(p[:nonpersonal])
10
+ end or hash[:edition] = nil
11
+ end
12
+
13
+ def misc_fields_format(hash)
14
+ super
15
+ hash[:standardidentifier].map! do |x|
16
+ x.sub(/^IHO /, "")
17
+ end
18
+ hash
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require "relaton-render"
2
+ require_relative "fields"
3
+ require_relative "parse"
4
+
5
+ module Relaton
6
+ module Render
7
+ module IHO
8
+ class General < ::Relaton::Render::IsoDoc::General
9
+ def config_loc
10
+ YAML.load_file(File.join(File.dirname(__FILE__), "config.yml"))
11
+ end
12
+
13
+ def klass_initialize(_options)
14
+ @nametemplateklass = Relaton::Render::Template::Name
15
+ @seriestemplateklass = Relaton::Render::Template::Series
16
+ @extenttemplateklass = Relaton::Render::Template::Extent
17
+ @sizetemplateklass = Relaton::Render::Template::Size
18
+ @generaltemplateklass = Relaton::Render::Template::General
19
+ @fieldsklass = Relaton::Render::IHO::Fields
20
+ @parseklass = Relaton::Render::IHO::Parse
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ module Relaton
2
+ module Render
3
+ module IHO
4
+ class Parse < ::Relaton::Render::Parse
5
+ def standardidentifier(doc)
6
+ out = doc.docidentifier.each_with_object([]) do |id, ret|
7
+ ret << id.id unless standardidentifier_exclude1.include? id.type
8
+ end
9
+ return out unless out.empty?
10
+
11
+ super
12
+ end
13
+
14
+ def standardidentifier_exclude1
15
+ %w(metanorma metanorma-ordinal DOI ISSN ISBN rfc-anchor)
16
+ end
17
+
18
+ def uri(doc)
19
+ uri = nil
20
+ %w(src).each do |t|
21
+ uri = doc.link.detect { |u| u.type == t } and break
22
+ end
23
+ uri ||= doc.link.first
24
+ return nil unless uri
25
+
26
+ uri.content.to_s
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
- spec.add_dependency "metanorma-generic", "~> 2.0.0"
30
+ spec.add_dependency "metanorma-generic", "~> 2.1.0"
31
31
 
32
32
  spec.add_development_dependency "debug"
33
33
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-18 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.0
33
+ version: 2.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.0
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: debug
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -239,6 +239,10 @@ files:
239
239
  - lib/metanorma/iho/processor.rb
240
240
  - lib/metanorma/iho/reqt.rng
241
241
  - lib/metanorma/iho/version.rb
242
+ - lib/relaton/render/config.yml
243
+ - lib/relaton/render/fields.rb
244
+ - lib/relaton/render/general.rb
245
+ - lib/relaton/render/parse.rb
242
246
  - metanorma-iho.gemspec
243
247
  - metanorma.yml
244
248
  homepage: https://github.com/metanorma/metanorma-iho