metanorma-standoc 1.9.3 → 1.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fb0657fc8f9c086fa560b509e2e7e5829b9ab5d902e727ce221c040f2aad3ec4
4
- data.tar.gz: eac14431d7f0317023a49993dee40a440fbc47d32136091cd4adfea5a5d36823
3
+ metadata.gz: d42939fe573eddd8bd58ff20a2e3eaacd3eb9de328afccabba60453a8b94cd43
4
+ data.tar.gz: e2d2e0f516b11587c5dcc6e8f87d39e4d63095b8e96014e7d1bfa610ceb6bae8
5
5
  SHA512:
6
- metadata.gz: 72d1aece1ed13421fa2fdcd87f8d4468cae148cc415b3a982fc9fea236cbf5f01113e87b11fc88b0aa68ce52f057d5dcdc1441b37c028798cd66458146d0b540
7
- data.tar.gz: b736bd6de43ace4da0c31f14b1f7f28349eb7272baf073e5b68558f68cd88e68b84fb72c76d578f0a69c8b56ae8021b5dfe75792dde64fae1a121eeaa156cfc6
6
+ metadata.gz: 653295f7c1dbdb48a201f0784e6d123058a2ccd0abc018fe9ae68049b9c01f29d0120c3a3ec5a25b968e18fbbf4ca3c85c0da294985f2dcee42ea2d049cdb526
7
+ data.tar.gz: d36fd8fa5b679f71c780bab99fe4c5a18d58c40e8995065975d87cbc0ce51f6459748c1c5310f3c4419d3058087a78d5e9d481839e4579c2d872d0359852ee28
@@ -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: notify
42
+ event-type: tests-passed
53
43
  client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
data/.hound.yml CHANGED
@@ -1,3 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
1
3
  ruby:
2
- Enabled: true
4
+ enabled: true
3
5
  config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -1,12 +1,10 @@
1
- # This project follows the Ribose OSS style guide.
2
- # https://github.com/riboseinc/oss-guides
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
- DisplayCopNames: false
11
- StyleGuideCopsOnly: false
12
10
  TargetRubyVersion: 2.4
@@ -48,11 +48,13 @@ module Asciidoctor
48
48
  htmlcoverpage: node.attr("htmlcoverpage"),
49
49
  htmlintropage: node.attr("htmlintropage"),
50
50
  scripts: node.attr("scripts"),
51
+ scripts_override: node.attr("scripts-override"),
51
52
  scripts_pdf: node.attr("scripts-pdf"),
52
53
  datauriimage: node.attr("data-uri-image"),
53
54
  htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
54
55
  doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
55
56
  break_up_urls_in_tables: node.attr("break-up-urls-in-tables"),
57
+ bare: node.attr("bare"),
56
58
  sectionsplit: node.attr("sectionsplit"),
57
59
  }
58
60
  end
@@ -80,6 +82,7 @@ module Asciidoctor
80
82
  htmltoclevels: node.attr("htmltoclevels") || node.attr("toclevels"),
81
83
  doctoclevels: node.attr("doctoclevels") || node.attr("toclevels"),
82
84
  break_up_urls_in_tables: node.attr("break-up-urls-in-tables"),
85
+ bare: node.attr("bare"),
83
86
  }
84
87
 
85
88
  if font_manifest_file = node.attr("mn2pdf-font-manifest-file")
@@ -3,20 +3,21 @@ require "htmlentities"
3
3
  require "json"
4
4
  require "open-uri"
5
5
  require "mathml2asciimath"
6
+ require_relative "cleanup_section_names"
6
7
 
7
8
  module Asciidoctor
8
9
  module Standoc
9
10
  module Cleanup
10
- def make_preface(xml, s)
11
+ def make_preface(xml, sect)
11
12
  if xml.at("//foreword | //introduction | //acknowledgements | "\
12
13
  "//*[@preface]")
13
- preface = s.add_previous_sibling("<preface/>").first
14
+ preface = sect.add_previous_sibling("<preface/>").first
14
15
  f = xml.at("//foreword") and preface.add_child f.remove
15
16
  f = xml.at("//introduction") and preface.add_child f.remove
16
17
  move_clauses_into_preface(xml, preface)
17
18
  f = xml.at("//acknowledgements") and preface.add_child f.remove
18
19
  end
19
- make_abstract(xml, s)
20
+ make_abstract(xml, sect)
20
21
  end
21
22
 
22
23
  def move_clauses_into_preface(xml, preface)
@@ -26,10 +27,10 @@ module Asciidoctor
26
27
  end
27
28
  end
28
29
 
29
- def make_abstract(xml, s)
30
+ def make_abstract(xml, sect)
30
31
  if xml.at("//abstract[not(ancestor::bibitem)]")
31
- preface = s.at("//preface") ||
32
- s.add_previous_sibling("<preface/>").first
32
+ preface = sect.at("//preface") ||
33
+ sect.add_previous_sibling("<preface/>").first
33
34
  abstract = xml.at("//abstract[not(ancestor::bibitem)]").remove
34
35
  preface.prepend_child abstract.remove
35
36
  bibabstract = bibabstract_location(xml)
@@ -53,17 +54,19 @@ module Asciidoctor
53
54
  xml.at("//bibdata/title[not(following-sibling::title)]")
54
55
  end
55
56
 
56
- def make_bibliography(xml, s)
57
+ def make_bibliography(xml, sect)
57
58
  if xml.at("//sections/references")
58
- biblio = s.add_next_sibling("<bibliography/>").first
59
+ biblio = sect.add_next_sibling("<bibliography/>").first
59
60
  xml.xpath("//sections/references").each do |r|
60
61
  biblio.add_child r.remove
61
62
  end
62
63
  end
63
64
  end
64
65
 
65
- def make_indexsect(xml, s)
66
- xml.xpath("//sections/indexsect").reverse_each { |r| s.next = r.remove }
66
+ def make_indexsect(xml, sect)
67
+ xml.xpath("//sections/indexsect").reverse_each do |r|
68
+ sect.next = r.remove
69
+ end
67
70
  end
68
71
 
69
72
  def sections_order_cleanup(xml)
@@ -177,76 +180,6 @@ module Asciidoctor
177
180
  ins.previous = x.remove
178
181
  end
179
182
  end
180
-
181
- def get_or_make_title(node)
182
- unless node.at("./title")
183
- if node.children.empty?
184
- node << "<title/>"
185
- else
186
- node.children.first.previous = "<title/>"
187
- end
188
- end
189
- node.at("./title")
190
- end
191
-
192
- def replace_title(doc, xpath, text, first = false)
193
- return unless text
194
-
195
- doc.xpath(xpath).each_with_index do |node, i|
196
- next if first && !i.zero?
197
-
198
- title = get_or_make_title(node)
199
- fn = title.xpath("./fn")
200
- fn.each(&:remove)
201
- title.content = text
202
- fn.each { |n| title << n }
203
- end
204
- end
205
-
206
- def sections_names_cleanup(xml)
207
- replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
208
- replace_title(xml, "//preface//abstract", @i18n&.abstract)
209
- replace_title(xml, "//foreword", @i18n&.foreword)
210
- replace_title(xml, "//introduction", @i18n&.introduction)
211
- replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
212
- section_names_refs_cleanup(xml)
213
- section_names_terms_cleanup(xml)
214
- end
215
-
216
- def section_names_refs_cleanup(xml)
217
- replace_title(xml, "//references[@normative = 'true']",
218
- @i18n&.normref, true)
219
- replace_title(xml, "//references[@normative = 'false']",
220
- @i18n&.bibliography, true)
221
- end
222
-
223
- NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
224
- SYMABBR = "[.//definitions[@type = 'symbols']]"\
225
- "[.//definitions[@type = 'abbreviated_terms']]".freeze
226
- SYMnoABBR = "[.//definitions[@type = 'symbols']]"\
227
- "[not(.//definitions[@type = 'abbreviated_terms'])]".freeze
228
- ABBRnoSYM = "[.//definitions[@type = 'abbreviated_terms']]"\
229
- "[not(.//definitions[@type = 'symbols'])]".freeze
230
-
231
- def section_names_terms_cleanup(x)
232
- replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
233
- replace_title(x, "//definitions[@type = 'abbreviated_terms']",
234
- @i18n&.abbrev)
235
- replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
236
- replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
237
- @i18n&.termsdefsymbols, true)
238
- replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
239
- @i18n&.termsdefabbrev, true)
240
- replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
241
- @i18n&.termsdefsymbolsabbrev, true)
242
- replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
243
- @i18n&.termsdefsymbolsabbrev, true)
244
- replace_title(
245
- x,
246
- "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
247
- @i18n&.termsdef, true
248
- )
249
- end
250
183
  end
251
184
  end
252
185
  end
@@ -0,0 +1,75 @@
1
+ module Asciidoctor
2
+ module Standoc
3
+ module Cleanup
4
+ def get_or_make_title(node)
5
+ unless node.at("./title")
6
+ if node.children.empty?
7
+ node << "<title/>"
8
+ else
9
+ node.children.first.previous = "<title/>"
10
+ end
11
+ end
12
+ node.at("./title")
13
+ end
14
+
15
+ def replace_title(doc, xpath, text, first = false)
16
+ return unless text
17
+
18
+ doc.xpath(xpath).each_with_index do |node, i|
19
+ next if first && !i.zero?
20
+
21
+ title = get_or_make_title(node)
22
+ fn = title.xpath("./fn")
23
+ fn.each(&:remove)
24
+ title.content = text
25
+ fn.each { |n| title << n }
26
+ end
27
+ end
28
+
29
+ def sections_names_cleanup(xml)
30
+ replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
31
+ replace_title(xml, "//preface//abstract", @i18n&.abstract)
32
+ replace_title(xml, "//foreword", @i18n&.foreword)
33
+ replace_title(xml, "//introduction", @i18n&.introduction)
34
+ replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
35
+ section_names_refs_cleanup(xml)
36
+ section_names_terms_cleanup(xml)
37
+ end
38
+
39
+ def section_names_refs_cleanup(xml)
40
+ replace_title(xml, "//references[@normative = 'true']",
41
+ @i18n&.normref, true)
42
+ replace_title(xml, "//references[@normative = 'false']",
43
+ @i18n&.bibliography, true)
44
+ end
45
+
46
+ NO_SYMABBR = "[.//definitions[not(@type)]]".freeze
47
+ SYMABBR = "[.//definitions[@type = 'symbols']]"\
48
+ "[.//definitions[@type = 'abbreviated_terms']]".freeze
49
+ SYMnoABBR = "[.//definitions[@type = 'symbols']]"\
50
+ "[not(.//definitions[@type = 'abbreviated_terms'])]".freeze
51
+ ABBRnoSYM = "[.//definitions[@type = 'abbreviated_terms']]"\
52
+ "[not(.//definitions[@type = 'symbols'])]".freeze
53
+
54
+ def section_names_terms_cleanup(x)
55
+ replace_title(x, "//definitions[@type = 'symbols']", @i18n&.symbols)
56
+ replace_title(x, "//definitions[@type = 'abbreviated_terms']",
57
+ @i18n&.abbrev)
58
+ replace_title(x, "//definitions[not(@type)]", @i18n&.symbolsabbrev)
59
+ replace_title(x, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
60
+ @i18n&.termsdefsymbols, true)
61
+ replace_title(x, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
62
+ @i18n&.termsdefabbrev, true)
63
+ replace_title(x, "//terms#{SYMABBR} | //clause[.//terms]#{SYMABBR}",
64
+ @i18n&.termsdefsymbolsabbrev, true)
65
+ replace_title(x, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
66
+ @i18n&.termsdefsymbolsabbrev, true)
67
+ replace_title(
68
+ x,
69
+ "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
70
+ @i18n&.termsdef, true
71
+ )
72
+ end
73
+ end
74
+ end
75
+ end
@@ -10,13 +10,13 @@ module Asciidoctor
10
10
  module Front
11
11
  def committee_component(compname, node, out)
12
12
  out.send compname.gsub(/-/, "_"), node.attr(compname),
13
- **attr_code(number: node.attr("#{compname}-number"),
14
- type: node.attr("#{compname}-type"))
13
+ **attr_code(number: node.attr("#{compname}-number"),
14
+ type: node.attr("#{compname}-type"))
15
15
  i = 2
16
- while node.attr(compname+"_#{i}") do
17
- out.send compname.gsub(/-/, "_"), node.attr(compname+"_#{i}"),
18
- **attr_code(number: node.attr("#{compname}-number_#{i}"),
19
- type: node.attr("#{compname}-type_#{i}"))
16
+ while node.attr(compname + "_#{i}")
17
+ out.send compname.gsub(/-/, "_"), node.attr(compname + "_#{i}"),
18
+ **attr_code(number: node.attr("#{compname}-number_#{i}"),
19
+ type: node.attr("#{compname}-type_#{i}"))
20
20
  i += 1
21
21
  end
22
22
  end
@@ -32,34 +32,36 @@ module Asciidoctor
32
32
  is_pub && node and org_address(node, org)
33
33
  end
34
34
 
35
- def org_address(node, p)
36
- node.attr("pub-address") and p.address do |ad|
35
+ def org_address(node, person)
36
+ node.attr("pub-address") and person.address do |ad|
37
37
  ad.formattedAddress do |f|
38
38
  f << node.attr("pub-address").gsub(/ \+\n/, "<br/>")
39
39
  end
40
40
  end
41
- node.attr("pub-phone") and p.phone node.attr("pub-phone")
42
- node.attr("pub-fax") and p.phone node.attr("pub-fax"), **{type: "fax"}
43
- node.attr("pub-email") and p.email node.attr("pub-email")
44
- node.attr("pub-uri") and p.uri node.attr("pub-uri")
41
+ node.attr("pub-phone") and person.phone node.attr("pub-phone")
42
+ node.attr("pub-fax") and
43
+ person.phone node.attr("pub-fax"), **{ type: "fax" }
44
+ node.attr("pub-email") and person.email node.attr("pub-email")
45
+ node.attr("pub-uri") and person.uri node.attr("pub-uri")
45
46
  end
46
47
 
47
48
  # , " => ," : CSV definition does not deal with space followed by quote
48
49
  # at start of field
49
- def csv_split(s, delim = ";")
50
- return if s.nil?
51
- CSV.parse_line(s&.gsub(/#{delim} "(?!")/, "#{delim}\""),
50
+ def csv_split(text, delim = ";")
51
+ return if text.nil?
52
+
53
+ CSV.parse_line(text&.gsub(/#{delim} "(?!")/, "#{delim}\""),
52
54
  liberal_parsing: true,
53
- col_sep: delim)&.compact&.map { |x| x.strip }
55
+ col_sep: delim)&.compact&.map(&:strip)
54
56
  end
55
57
 
56
58
  def metadata_author(node, xml)
57
- csv_split(node.attr("publisher") || default_publisher || "")&.
58
- each do |p|
59
+ csv_split(node.attr("publisher") || default_publisher || "")
60
+ &.each do |p|
59
61
  xml.contributor do |c|
60
62
  c.role **{ type: "author" }
61
63
  c.organization do |a|
62
- organization(a, p, false, node, !node.attr("publisher"))
64
+ organization(a, p, false, node, !node.attr("publisher"))
63
65
  end
64
66
  end
65
67
  end
@@ -76,17 +78,18 @@ module Asciidoctor
76
78
  end
77
79
  end
78
80
 
79
- def personal_role(node, c, suffix)
80
- c.role **{ type: node.attr("role#{suffix}")&.downcase || "author" }
81
+ def personal_role(node, contrib, suffix)
82
+ type = node.attr("role#{suffix}")&.downcase || "author"
83
+ contrib.role **{ type: type }
81
84
  end
82
85
 
83
- def personal_contact(node, suffix, p)
84
- node.attr("phone#{suffix}") and p.phone node.attr("phone#{suffix}")
86
+ def personal_contact(node, suffix, person)
87
+ node.attr("phone#{suffix}") and person.phone node.attr("phone#{suffix}")
85
88
  node.attr("fax#{suffix}") and
86
- p.phone node.attr("fax#{suffix}"), **{type: "fax"}
87
- node.attr("email#{suffix}") and p.email node.attr("email#{suffix}")
89
+ person.phone node.attr("fax#{suffix}"), **{ type: "fax" }
90
+ node.attr("email#{suffix}") and person.email node.attr("email#{suffix}")
88
91
  node.attr("contributor-uri#{suffix}") and
89
- p.uri node.attr("contributor-uri#{suffix}")
92
+ person.uri node.attr("contributor-uri#{suffix}")
90
93
  end
91
94
 
92
95
  def personal_author1(node, xml, suffix)
@@ -100,8 +103,8 @@ module Asciidoctor
100
103
  end
101
104
  end
102
105
 
103
- def person_name(node, xml, suffix, p)
104
- p.name do |n|
106
+ def person_name(node, _xml, suffix, person)
107
+ person.name do |n|
105
108
  if node.attr("fullname#{suffix}")
106
109
  n.completename node.attr("fullname#{suffix}")
107
110
  else
@@ -112,21 +115,43 @@ module Asciidoctor
112
115
  end
113
116
  end
114
117
 
115
- def person_affiliation(node, xml, suffix, p)
116
- node.attr("affiliation#{suffix}") and p.affiliation do |a|
118
+ def person_affiliation(node, _xml, suffix, person)
119
+ node.attr("affiliation#{suffix}") and person.affiliation do |a|
117
120
  a.organization do |o|
118
- o.name node.attr("affiliation#{suffix}")
119
- a = node.attr("affiliation_subdiv#{suffix}")
120
- abbr = node.attr("affiliation_abbrev#{suffix}") and o.abbreviation abbr
121
- csv_split(node.attr("affiliation_subdiv#{suffix}"))&.each do |s|
122
- o.subdivision s
123
- end
124
- node.attr("address#{suffix}") and o.address do |ad|
125
- ad.formattedAddress do |f|
126
- f << node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>")
127
- end
121
+ person_organization(node, suffix, o)
122
+ end
123
+ end
124
+ end
125
+
126
+ def person_organization(node, suffix, xml)
127
+ xml.name node.attr("affiliation#{suffix}")
128
+ abbr = node.attr("affiliation_abbrev#{suffix}") and
129
+ xml.abbreviation abbr
130
+ csv_split(node.attr("affiliation_subdiv#{suffix}"))&.each do |s|
131
+ xml.subdivision s
132
+ end
133
+ person_address(node, suffix, xml)
134
+ end
135
+
136
+ def person_address(node, suffix, xml)
137
+ if node.attr("address#{suffix}")
138
+ xml.address do |ad|
139
+ ad.formattedAddress do |f|
140
+ f << node.attr("address#{suffix}").gsub(/ \+\n/, "<br/>")
128
141
  end
129
142
  end
143
+ elsif node.attr("country#{suffix}") || node.attr("city#{suffix}")
144
+ person_address_components(node, suffix, xml)
145
+ end
146
+ end
147
+
148
+ def person_address_components(node, suffix, xml)
149
+ xml.address do |ad|
150
+ s = node.attr("street#{suffix}") and ad.street s
151
+ s = node.attr("city#{suffix}") and ad.city s
152
+ s = node.attr("state#{suffix}") and ad.state s
153
+ s = node.attr("country#{suffix}") and ad.country s
154
+ s = node.attr("postcode#{suffix}") and ad.postcode s
130
155
  end
131
156
  end
132
157
 
@@ -135,7 +160,7 @@ module Asciidoctor
135
160
  end
136
161
 
137
162
  def org_abbrev
138
- { }
163
+ {}
139
164
  end
140
165
 
141
166
  def metadata_publisher(node, xml)