metanorma-iho 0.3.0 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +3 -13
- data/.hound.yml +5 -0
- data/.rubocop.yml +4 -8
- data/lib/asciidoctor/iho/biblio.rng +1 -0
- data/lib/asciidoctor/iho/converter.rb +8 -6
- data/lib/asciidoctor/iho/iho.rng +3 -0
- data/lib/asciidoctor/iho/isodoc.rng +191 -3
- data/lib/isodoc/iho/base_convert.rb +40 -46
- data/lib/isodoc/iho/iho.specification.xsl +533 -67
- data/lib/isodoc/iho/iho.standard.xsl +533 -67
- data/lib/isodoc/iho/init.rb +4 -4
- data/lib/isodoc/iho/xref.rb +1 -2
- data/lib/metanorma/iho/version.rb +1 -1
- data/metanorma-iho.gemspec +1 -1
- data/metanorma.yml +3 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74009f28ae0e8d7d53ae1ba871d3d343cb343e2c907455d50507de29ef3824d9
|
4
|
+
data.tar.gz: 25ec650bf51cdcbb5fab99d9ba8716dcd25b2b301f05f384daf55efa19aa3e1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa71c58b70bf5a1cf8f3c3b5f6c4a6606f2fafbb5683719b3601e3485a81ce297f7f1f1bcfc551b867999636824825ba8e2d357360e8019e3d1b73eaae17482
|
7
|
+
data.tar.gz: 5551240737a8d2ec9f765fcf4db38b33916c81ae0a3f8ca977f6418fa29793d1cda0ec3e943c5aea94337760bc5e6b0fca29a8b86929a062fde7302f551062ed
|
data/.github/workflows/rake.yml
CHANGED
@@ -4,7 +4,7 @@ name: rake
|
|
4
4
|
|
5
5
|
on:
|
6
6
|
push:
|
7
|
-
branches: [ master, main
|
7
|
+
branches: [ master, main ]
|
8
8
|
tags: [ v* ]
|
9
9
|
pull_request:
|
10
10
|
|
@@ -16,19 +16,9 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '2.7', '2.6', '2.5', '2.4' ]
|
19
|
+
ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
|
-
include:
|
23
|
-
- ruby: '3.0'
|
24
|
-
os: 'ubuntu-latest'
|
25
|
-
experimental: true
|
26
|
-
- ruby: '3.0'
|
27
|
-
os: 'windows-latest'
|
28
|
-
experimental: true
|
29
|
-
- ruby: '3.0'
|
30
|
-
os: 'macos-latest'
|
31
|
-
experimental: true
|
32
22
|
steps:
|
33
23
|
- uses: actions/checkout@master
|
34
24
|
|
@@ -49,5 +39,5 @@ jobs:
|
|
49
39
|
with:
|
50
40
|
token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
|
51
41
|
repository: ${{ github.repository }}
|
52
|
-
event-type:
|
42
|
+
event-type: tests-passed
|
53
43
|
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
data/.hound.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
#
|
2
|
-
# https://github.com/
|
3
|
-
# All project-specific additions and overrides should be specified in this file.
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
4
3
|
inherit_from:
|
5
4
|
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
5
|
|
7
6
|
# local repo-specific modifications
|
7
|
+
# ...
|
8
8
|
|
9
9
|
AllCops:
|
10
|
-
|
11
|
-
StyleGuideCopsOnly: false
|
12
|
-
TargetRubyVersion: 2.4
|
13
|
-
Rails:
|
14
|
-
Enabled: true
|
10
|
+
TargetRubyVersion: 2.5
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require "asciidoctor/standoc/converter"
|
2
|
-
require
|
2
|
+
require "asciidoctor/generic/converter"
|
3
3
|
|
4
4
|
module Asciidoctor
|
5
5
|
module IHO
|
@@ -7,8 +7,8 @@ module Asciidoctor
|
|
7
7
|
# schema encapsulation of the document for validation
|
8
8
|
#
|
9
9
|
class Converter < Asciidoctor::Generic::Converter
|
10
|
-
XML_ROOT_TAG =
|
11
|
-
XML_NAMESPACE =
|
10
|
+
XML_ROOT_TAG = "iho-standard".freeze
|
11
|
+
XML_NAMESPACE = "https://www.metanorma.org/ns/iho".freeze
|
12
12
|
|
13
13
|
register_for "iho"
|
14
14
|
|
@@ -33,7 +33,7 @@ module Asciidoctor
|
|
33
33
|
M: "Miscellaneous",
|
34
34
|
P: "Periodic",
|
35
35
|
S: "Standards and Specifications",
|
36
|
-
}
|
36
|
+
}.freeze
|
37
37
|
|
38
38
|
def metadata_series(node, xml)
|
39
39
|
series = node.attr("series") or return
|
@@ -59,7 +59,8 @@ module Asciidoctor
|
|
59
59
|
|
60
60
|
def metadata_committee(node, xml)
|
61
61
|
unless node.attr("workgroup")
|
62
|
-
@log.add("AsciiDoc Input", nil,
|
62
|
+
@log.add("AsciiDoc Input", nil,
|
63
|
+
"Missing workgroup attribute for document")
|
63
64
|
return
|
64
65
|
end
|
65
66
|
metadata_committee1(node, xml)
|
@@ -75,7 +76,7 @@ module Asciidoctor
|
|
75
76
|
end
|
76
77
|
end
|
77
78
|
i = 2
|
78
|
-
while node.attr("workgroup_#{i}")
|
79
|
+
while node.attr("workgroup_#{i}")
|
79
80
|
xml.editorialgroup do |a|
|
80
81
|
a.committee do |n|
|
81
82
|
n.abbreviation node.attr("committee_#{i}").upcase
|
@@ -102,6 +103,7 @@ module Asciidoctor
|
|
102
103
|
|
103
104
|
def pdf_converter(node)
|
104
105
|
return nil if node.attr("no-pdf")
|
106
|
+
|
105
107
|
IsoDoc::IHO::PdfConvert.new(html_extract_attributes(node))
|
106
108
|
end
|
107
109
|
|
data/lib/asciidoctor/iho/iho.rng
CHANGED
@@ -45,6 +45,11 @@
|
|
45
45
|
<optional>
|
46
46
|
<attribute name="alt"/>
|
47
47
|
</optional>
|
48
|
+
<optional>
|
49
|
+
<attribute name="updatetype">
|
50
|
+
<data type="boolean"/>
|
51
|
+
</attribute>
|
52
|
+
</optional>
|
48
53
|
<text/>
|
49
54
|
</element>
|
50
55
|
</define>
|
@@ -543,6 +548,9 @@
|
|
543
548
|
</define>
|
544
549
|
<define name="BibDataExtensionType">
|
545
550
|
<ref name="doctype"/>
|
551
|
+
<optional>
|
552
|
+
<ref name="docsubtype"/>
|
553
|
+
</optional>
|
546
554
|
<optional>
|
547
555
|
<ref name="editorialgroup"/>
|
548
556
|
</optional>
|
@@ -876,8 +884,28 @@
|
|
876
884
|
</zeroOrMore>
|
877
885
|
</element>
|
878
886
|
</define>
|
887
|
+
<define name="pagebreak">
|
888
|
+
<element name="pagebreak">
|
889
|
+
<optional>
|
890
|
+
<attribute name="orientation">
|
891
|
+
<choice>
|
892
|
+
<value>landscape</value>
|
893
|
+
<value>portrait</value>
|
894
|
+
</choice>
|
895
|
+
</attribute>
|
896
|
+
</optional>
|
897
|
+
</element>
|
898
|
+
</define>
|
879
899
|
</include>
|
880
900
|
<!-- end overrides -->
|
901
|
+
<define name="docsubtype">
|
902
|
+
<element name="docsubtype">
|
903
|
+
<ref name="DocumentSubtype"/>
|
904
|
+
</element>
|
905
|
+
</define>
|
906
|
+
<define name="DocumentSubtype">
|
907
|
+
<text/>
|
908
|
+
</define>
|
881
909
|
<define name="colgroup">
|
882
910
|
<element name="colgroup">
|
883
911
|
<oneOrMore>
|
@@ -943,8 +971,170 @@
|
|
943
971
|
<ref name="permission"/>
|
944
972
|
<ref name="imagemap"/>
|
945
973
|
<ref name="svgmap"/>
|
974
|
+
<ref name="inputform"/>
|
975
|
+
</choice>
|
976
|
+
</define>
|
977
|
+
<define name="inputform">
|
978
|
+
<element name="form">
|
979
|
+
<attribute name="id">
|
980
|
+
<data type="ID"/>
|
981
|
+
</attribute>
|
982
|
+
<attribute name="name"/>
|
983
|
+
<attribute name="action"/>
|
984
|
+
<zeroOrMore>
|
985
|
+
<choice>
|
986
|
+
<ref name="TextElement"/>
|
987
|
+
<ref name="FormInput"/>
|
988
|
+
</choice>
|
989
|
+
</zeroOrMore>
|
990
|
+
</element>
|
991
|
+
</define>
|
992
|
+
<define name="FormInput">
|
993
|
+
<choice>
|
994
|
+
<ref name="input"/>
|
995
|
+
<ref name="formlabel"/>
|
996
|
+
<ref name="select"/>
|
997
|
+
<ref name="textarea"/>
|
998
|
+
</choice>
|
999
|
+
</define>
|
1000
|
+
<define name="InputType">
|
1001
|
+
<choice>
|
1002
|
+
<value>button</value>
|
1003
|
+
<value>checkbox</value>
|
1004
|
+
<value>date</value>
|
1005
|
+
<value>file</value>
|
1006
|
+
<value>password</value>
|
1007
|
+
<value>radio</value>
|
1008
|
+
<value>submit</value>
|
1009
|
+
<value>text</value>
|
946
1010
|
</choice>
|
947
1011
|
</define>
|
1012
|
+
<define name="input">
|
1013
|
+
<element name="input">
|
1014
|
+
<attribute name="type">
|
1015
|
+
<ref name="InputType"/>
|
1016
|
+
</attribute>
|
1017
|
+
<optional>
|
1018
|
+
<attribute name="checked">
|
1019
|
+
<data type="boolean"/>
|
1020
|
+
</attribute>
|
1021
|
+
</optional>
|
1022
|
+
<optional>
|
1023
|
+
<attribute name="disabled">
|
1024
|
+
<data type="boolean"/>
|
1025
|
+
</attribute>
|
1026
|
+
</optional>
|
1027
|
+
<optional>
|
1028
|
+
<attribute name="readonly">
|
1029
|
+
<data type="boolean"/>
|
1030
|
+
</attribute>
|
1031
|
+
</optional>
|
1032
|
+
<optional>
|
1033
|
+
<attribute name="maxlength">
|
1034
|
+
<data type="int"/>
|
1035
|
+
</attribute>
|
1036
|
+
</optional>
|
1037
|
+
<optional>
|
1038
|
+
<attribute name="minlength">
|
1039
|
+
<data type="int"/>
|
1040
|
+
</attribute>
|
1041
|
+
</optional>
|
1042
|
+
<optional>
|
1043
|
+
<attribute name="name"/>
|
1044
|
+
</optional>
|
1045
|
+
<optional>
|
1046
|
+
<attribute name="value"/>
|
1047
|
+
</optional>
|
1048
|
+
<optional>
|
1049
|
+
<attribute name="id">
|
1050
|
+
<data type="ID"/>
|
1051
|
+
</attribute>
|
1052
|
+
</optional>
|
1053
|
+
</element>
|
1054
|
+
</define>
|
1055
|
+
<define name="formlabel">
|
1056
|
+
<element name="label">
|
1057
|
+
<attribute name="for">
|
1058
|
+
<data type="IDREF"/>
|
1059
|
+
</attribute>
|
1060
|
+
<zeroOrMore>
|
1061
|
+
<ref name="PureTextElement"/>
|
1062
|
+
</zeroOrMore>
|
1063
|
+
</element>
|
1064
|
+
</define>
|
1065
|
+
<define name="select">
|
1066
|
+
<element name="select">
|
1067
|
+
<optional>
|
1068
|
+
<attribute name="name"/>
|
1069
|
+
</optional>
|
1070
|
+
<optional>
|
1071
|
+
<attribute name="value"/>
|
1072
|
+
</optional>
|
1073
|
+
<optional>
|
1074
|
+
<attribute name="id">
|
1075
|
+
<data type="ID"/>
|
1076
|
+
</attribute>
|
1077
|
+
</optional>
|
1078
|
+
<optional>
|
1079
|
+
<attribute name="disabled">
|
1080
|
+
<data type="boolean"/>
|
1081
|
+
</attribute>
|
1082
|
+
</optional>
|
1083
|
+
<optional>
|
1084
|
+
<attribute name="multiple">
|
1085
|
+
<data type="boolean"/>
|
1086
|
+
</attribute>
|
1087
|
+
</optional>
|
1088
|
+
<optional>
|
1089
|
+
<attribute name="size">
|
1090
|
+
<data type="int"/>
|
1091
|
+
</attribute>
|
1092
|
+
</optional>
|
1093
|
+
<oneOrMore>
|
1094
|
+
<ref name="option"/>
|
1095
|
+
</oneOrMore>
|
1096
|
+
</element>
|
1097
|
+
</define>
|
1098
|
+
<define name="option">
|
1099
|
+
<element name="option">
|
1100
|
+
<optional>
|
1101
|
+
<attribute name="disabled">
|
1102
|
+
<data type="boolean"/>
|
1103
|
+
</attribute>
|
1104
|
+
</optional>
|
1105
|
+
<optional>
|
1106
|
+
<attribute name="value"/>
|
1107
|
+
</optional>
|
1108
|
+
<zeroOrMore>
|
1109
|
+
<ref name="PureTextElement"/>
|
1110
|
+
</zeroOrMore>
|
1111
|
+
</element>
|
1112
|
+
</define>
|
1113
|
+
<define name="textarea">
|
1114
|
+
<element name="textarea">
|
1115
|
+
<optional>
|
1116
|
+
<attribute name="name"/>
|
1117
|
+
</optional>
|
1118
|
+
<optional>
|
1119
|
+
<attribute name="value"/>
|
1120
|
+
</optional>
|
1121
|
+
<optional>
|
1122
|
+
<attribute name="id">
|
1123
|
+
<data type="ID"/>
|
1124
|
+
</attribute>
|
1125
|
+
</optional>
|
1126
|
+
<optional>
|
1127
|
+
<attribute name="rows">
|
1128
|
+
<data type="int"/>
|
1129
|
+
</attribute>
|
1130
|
+
</optional>
|
1131
|
+
<optional>
|
1132
|
+
<attribute name="cols">
|
1133
|
+
<data type="int"/>
|
1134
|
+
</attribute>
|
1135
|
+
</optional>
|
1136
|
+
</element>
|
1137
|
+
</define>
|
948
1138
|
<define name="bibliography">
|
949
1139
|
<element name="bibliography">
|
950
1140
|
<oneOrMore>
|
@@ -1017,9 +1207,7 @@
|
|
1017
1207
|
</define>
|
1018
1208
|
<define name="IsoWorkgroup">
|
1019
1209
|
<optional>
|
1020
|
-
<attribute name="number"
|
1021
|
-
<data type="int"/>
|
1022
|
-
</attribute>
|
1210
|
+
<attribute name="number"/>
|
1023
1211
|
</optional>
|
1024
1212
|
<optional>
|
1025
1213
|
<attribute name="type"/>
|
@@ -15,30 +15,32 @@ module IsoDoc
|
|
15
15
|
super
|
16
16
|
end
|
17
17
|
|
18
|
-
def std_bibitem_entry(list,
|
19
|
-
list.p **attr_code(iso_bibitem_entry_attrs(
|
18
|
+
def std_bibitem_entry(list, bib, ordinal, biblio)
|
19
|
+
list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
|
20
20
|
prefix_bracketed_ref(ref, "[#{ordinal}]")
|
21
|
-
standard_citation(ref,
|
21
|
+
standard_citation(ref, bib)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def nodes_to_span(
|
25
|
+
def nodes_to_span(node)
|
26
26
|
noko do |xml|
|
27
27
|
xml.span do |s|
|
28
|
-
|
28
|
+
node&.children&.each { |x| parse(x, s) }
|
29
29
|
end
|
30
30
|
end.join("")
|
31
31
|
end
|
32
32
|
|
33
33
|
def multiplenames_and(names)
|
34
|
-
return "" if names.
|
34
|
+
return "" if names.empty?
|
35
35
|
return names[0] if names.length == 1
|
36
36
|
return "#{names[0]} and #{names[1]}" if names.length == 2
|
37
|
+
|
37
38
|
names[0..-2].join(", ") + " and #{names[-1]}"
|
38
39
|
end
|
39
40
|
|
40
|
-
def extract_publisher(
|
41
|
-
c =
|
41
|
+
def extract_publisher(bib)
|
42
|
+
c = bib
|
43
|
+
.xpath(ns("./contributor[role/@type = 'publisher'][organization]"))
|
42
44
|
abbrs = []
|
43
45
|
names = []
|
44
46
|
c&.each do |c1|
|
@@ -47,63 +49,55 @@ module IsoDoc
|
|
47
49
|
names << nodes_to_span(n)
|
48
50
|
end
|
49
51
|
return [nil, nil] if names.empty?
|
50
|
-
|
52
|
+
|
53
|
+
[multiplenames_and(names), abbrs.map(&:text).join("/")]
|
51
54
|
end
|
52
55
|
|
53
|
-
def inline_bibitem_ref_code(
|
54
|
-
id =
|
55
|
-
|
56
|
-
|
56
|
+
def inline_bibitem_ref_code(bib)
|
57
|
+
id = bib.at(ns("./docidentifier[not(@type = 'DOI' or "\
|
58
|
+
"@type = 'metanorma' or @type = 'ISSN' or "\
|
59
|
+
"@type = 'ISBN' or @type = 'rfc-anchor')]"))
|
60
|
+
id ||= bib.at(ns("./docidentifier[not(@type = 'metanorma')]"))
|
57
61
|
return [nil, id, nil] if id
|
58
|
-
|
62
|
+
|
63
|
+
id = Nokogiri::XML::Node.new("docidentifier", bib.document)
|
59
64
|
id << "(NO ID)"
|
60
65
|
[nil, id, nil]
|
61
66
|
end
|
62
67
|
|
63
|
-
def extract_edition(
|
64
|
-
|
68
|
+
def extract_edition(bib)
|
69
|
+
bib&.at(ns("./edition"))&.text
|
65
70
|
end
|
66
71
|
|
67
|
-
def extract_uri(
|
68
|
-
|
72
|
+
def extract_uri(bib)
|
73
|
+
bib.at(ns("./uri"))
|
69
74
|
end
|
70
75
|
|
71
76
|
def omit_docid_prefix(prefix)
|
72
77
|
return true if prefix == "IHO"
|
78
|
+
|
73
79
|
super
|
74
80
|
end
|
75
81
|
|
76
82
|
def render_identifier(id)
|
77
|
-
if !id[1].nil?
|
83
|
+
if !id[1].nil? && (id[1]["type"] == "IHO")
|
78
84
|
id[1].children = id[1].text.sub(/^IHO /, "")
|
79
85
|
end
|
80
86
|
super
|
81
87
|
end
|
82
88
|
|
83
|
-
def
|
84
|
-
c =
|
85
|
-
|
86
|
-
|
87
|
-
c&.each do |c1|
|
88
|
-
n = c1.at(ns("./organization/name")) or next
|
89
|
-
abbrs << (c1.at(ns("./organization/abbreviation")) || n)
|
90
|
-
names << nodes_to_span(n)
|
91
|
-
end
|
92
|
-
return [nil, nil] if names.empty?
|
93
|
-
return [multiplenames_and(names), (abbrs.map { |x| x.text }).join("/")]
|
94
|
-
end
|
89
|
+
def extract_author(bib)
|
90
|
+
c = bib.xpath(ns("./contributor[role/@type = 'author']"))
|
91
|
+
c = bib.xpath(ns("./contributor[role/@type = 'editor']")) if c.empty?
|
92
|
+
return extract_publisher(bib)[0] if c.empty?
|
95
93
|
|
96
|
-
def extract_author(b)
|
97
|
-
c = b.xpath(ns("./contributor[role/@type = 'author']"))
|
98
|
-
c = b.xpath(ns("./contributor[role/@type = 'editor']")) if c.empty?
|
99
|
-
return extract_publisher(b)[0] if c.empty?
|
100
94
|
c.map do |c1|
|
101
95
|
c1&.at(ns("./organization/name"))&.text || extract_person_name(c1)
|
102
96
|
end.reject { |e| e.nil? || e.empty? }.join(", ")
|
103
97
|
end
|
104
98
|
|
105
|
-
def extract_person_name(
|
106
|
-
p =
|
99
|
+
def extract_person_name(bib)
|
100
|
+
p = bib.at(ns("./person/name")) or return
|
107
101
|
c = p.at(ns("./completename")) and return c.text
|
108
102
|
s = p&.at(ns("./surname"))&.text or return
|
109
103
|
i = p.xpath(ns("./initial")) and
|
@@ -113,25 +107,25 @@ module IsoDoc
|
|
113
107
|
front ? "#{s} #{front}" : s
|
114
108
|
end
|
115
109
|
|
116
|
-
def
|
117
|
-
extract_publisher(
|
110
|
+
def iho?(bib)
|
111
|
+
extract_publisher(bib)[1] == "IHO"
|
118
112
|
end
|
119
113
|
|
120
114
|
# [{number}] {docID} edition {edition}: {title}, {author/organization}
|
121
|
-
def standard_citation(out,
|
122
|
-
if ftitle =
|
115
|
+
def standard_citation(out, bib)
|
116
|
+
if ftitle = bib.at(ns("./formattedref"))
|
123
117
|
ftitle&.children&.each { |n| parse(n, out) }
|
124
118
|
else
|
125
|
-
id = render_identifier(inline_bibitem_ref_code(
|
119
|
+
id = render_identifier(inline_bibitem_ref_code(bib))
|
126
120
|
out << id[1] if id[1]
|
127
|
-
ed = extract_edition(
|
121
|
+
ed = extract_edition(bib) if iho?(bib)
|
128
122
|
out << " edition #{ed}" if ed
|
129
123
|
out << ": " if id[1] || ed
|
130
|
-
iso_title(
|
124
|
+
iso_title(bib)&.children&.each { |n| parse(n, out) }
|
131
125
|
out << ", "
|
132
|
-
author = extract_author(
|
126
|
+
author = extract_author(bib)
|
133
127
|
out << author
|
134
|
-
u = extract_uri(
|
128
|
+
u = extract_uri(bib)
|
135
129
|
out << " (<a href='#{u.text}'>#{u.text}</a>)" if u
|
136
130
|
end
|
137
131
|
end
|