metanorma-iho 0.5.8 → 0.6.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.
@@ -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
 
@@ -614,12 +614,12 @@
614
614
  <optional>
615
615
  <ref name="fetched"/>
616
616
  </optional>
617
- <choice>
618
- <oneOrMore>
619
- <ref name="btitle"/>
620
- </oneOrMore>
617
+ <optional>
621
618
  <ref name="formattedref"/>
622
- </choice>
619
+ </optional>
620
+ <oneOrMore>
621
+ <ref name="btitle"/>
622
+ </oneOrMore>
623
623
  <zeroOrMore>
624
624
  <ref name="bsource"/>
625
625
  </zeroOrMore>
@@ -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"/>
@@ -957,36 +986,34 @@
957
986
  <ref name="SeriesType"/>
958
987
  </attribute>
959
988
  </optional>
960
- <choice>
989
+ <optional>
961
990
  <ref name="formattedref"/>
962
- <group>
963
- <ref name="btitle"/>
964
- <optional>
965
- <ref name="bplace"/>
966
- </optional>
967
- <optional>
968
- <ref name="seriesorganization"/>
969
- </optional>
970
- <optional>
971
- <ref name="abbreviation"/>
972
- </optional>
973
- <optional>
974
- <ref name="seriesfrom"/>
975
- </optional>
976
- <optional>
977
- <ref name="seriesto"/>
978
- </optional>
979
- <optional>
980
- <ref name="seriesnumber"/>
981
- </optional>
982
- <optional>
983
- <ref name="seriespartnumber"/>
984
- </optional>
985
- <optional>
986
- <ref name="seriesrun"/>
987
- </optional>
988
- </group>
989
- </choice>
991
+ </optional>
992
+ <ref name="btitle"/>
993
+ <optional>
994
+ <ref name="bplace"/>
995
+ </optional>
996
+ <optional>
997
+ <ref name="seriesorganization"/>
998
+ </optional>
999
+ <optional>
1000
+ <ref name="abbreviation"/>
1001
+ </optional>
1002
+ <optional>
1003
+ <ref name="seriesfrom"/>
1004
+ </optional>
1005
+ <optional>
1006
+ <ref name="seriesto"/>
1007
+ </optional>
1008
+ <optional>
1009
+ <ref name="seriesnumber"/>
1010
+ </optional>
1011
+ <optional>
1012
+ <ref name="seriespartnumber"/>
1013
+ </optional>
1014
+ <optional>
1015
+ <ref name="seriesrun"/>
1016
+ </optional>
990
1017
  </element>
991
1018
  </define>
992
1019
  <define name="SeriesType">
@@ -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>
@@ -245,6 +282,9 @@
245
282
  <ref name="MultilingualRenderingType"/>
246
283
  </attribute>
247
284
  </optional>
285
+ <optional>
286
+ <ref name="tname"/>
287
+ </optional>
248
288
  <oneOrMore>
249
289
  <ref name="ul_li"/>
250
290
  </oneOrMore>
@@ -287,6 +327,9 @@
287
327
  </choice>
288
328
  </attribute>
289
329
  </optional>
330
+ <optional>
331
+ <ref name="tname"/>
332
+ </optional>
290
333
  <oneOrMore>
291
334
  <ref name="li"/>
292
335
  </oneOrMore>
@@ -323,6 +366,9 @@
323
366
  <ref name="MultilingualRenderingType"/>
324
367
  </attribute>
325
368
  </optional>
369
+ <optional>
370
+ <ref name="tname"/>
371
+ </optional>
326
372
  <oneOrMore>
327
373
  <ref name="dt"/>
328
374
  <ref name="dd"/>
@@ -851,6 +897,16 @@
851
897
  <ref name="MultilingualRenderingType"/>
852
898
  </attribute>
853
899
  </optional>
900
+ <optional>
901
+ <attribute name="coverpage">
902
+ <data type="boolean"/>
903
+ </attribute>
904
+ </optional>
905
+ <optional>
906
+ <attribute name="notag">
907
+ <data type="boolean"/>
908
+ </attribute>
909
+ </optional>
854
910
  <oneOrMore>
855
911
  <choice>
856
912
  <ref name="paragraph"/>
@@ -1178,6 +1234,7 @@
1178
1234
  <ref name="concept"/>
1179
1235
  <ref name="add"/>
1180
1236
  <ref name="del"/>
1237
+ <ref name="span"/>
1181
1238
  </choice>
1182
1239
  </define>
1183
1240
  <define name="add">
@@ -1204,6 +1261,14 @@
1204
1261
  </choice>
1205
1262
  </element>
1206
1263
  </define>
1264
+ <define name="span">
1265
+ <element name="span">
1266
+ <attribute name="class"/>
1267
+ <oneOrMore>
1268
+ <ref name="TextElement"/>
1269
+ </oneOrMore>
1270
+ </element>
1271
+ </define>
1207
1272
  <define name="concept">
1208
1273
  <element name="concept">
1209
1274
  <optional>
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module IHO
3
- VERSION = "0.5.8".freeze
3
+ VERSION = "0.6.2".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
@@ -26,8 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
  spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
28
28
 
29
- spec.add_dependency "htmlentities", "~> 4.3.4"
30
- spec.add_dependency "metanorma-generic", "~> 2.0.0"
29
+ spec.add_dependency "metanorma-generic", "~> 2.1.1"
31
30
 
32
31
  spec.add_development_dependency "debug"
33
32
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
metadata CHANGED
@@ -1,43 +1,29 @@
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.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: 2022-04-18 00:00:00.000000000 Z
11
+ date: 2022-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: htmlentities
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 4.3.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 4.3.4
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: metanorma-generic
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: 2.0.0
19
+ version: 2.1.1
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: 2.0.0
26
+ version: 2.1.1
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: debug
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -239,6 +225,10 @@ files:
239
225
  - lib/metanorma/iho/processor.rb
240
226
  - lib/metanorma/iho/reqt.rng
241
227
  - lib/metanorma/iho/version.rb
228
+ - lib/relaton/render/config.yml
229
+ - lib/relaton/render/fields.rb
230
+ - lib/relaton/render/general.rb
231
+ - lib/relaton/render/parse.rb
242
232
  - metanorma-iho.gemspec
243
233
  - metanorma.yml
244
234
  homepage: https://github.com/metanorma/metanorma-iho
@@ -260,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
250
  - !ruby/object:Gem::Version
261
251
  version: '0'
262
252
  requirements: []
263
- rubygems_version: 3.3.9
253
+ rubygems_version: 3.3.7
264
254
  signing_key:
265
255
  specification_version: 4
266
256
  summary: metanorma-iho lets you write IHO in AsciiDoc.