metanorma-iso 1.7.2 → 1.7.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69530242f8dcfcd209289f65397818d2d73e69920a2588b1bfa4c30b712ada50
4
- data.tar.gz: 72261437fe21d308b4c01e4ba3ce7f9fe15a5c3a35dce4828dc7b04e2c941df4
3
+ metadata.gz: 04b55e3ca534c69d32ca0f9379574e2ea64af41abdcfcd723532917cce1dbb11
4
+ data.tar.gz: 9a4910e86d2792bf82e863ed1d57cd0bd492667acc2eef5eaf0d7443b99fd730
5
5
  SHA512:
6
- metadata.gz: 8a01d3c261513bddc48ce11f6b331ab025939d41e234a02e6e63cd39ef15c865af2a7f086768a38cbbecbec8aac76fabbb1ea5febcb3f4fb0852aab58ba7b794
7
- data.tar.gz: d83d323c7e9ca83dc5afaead3e837da9bc952074a4f913f5eb28dce637d98ffce6f4e6206b96ff8ef3a05a585b8a75c2de215fae8a36dfae325c1b632a0cb68a
6
+ metadata.gz: cee47fc2106cf2573bb9c5d1198c230c0b9c1e350a8c12b5c1764eb683e058579619cbcb26c33a8cd4f838ccaccc7282ba1e990777d672c5b0b1269f0f950ce7
7
+ data.tar.gz: 4515aa0402dddc620a72837044e3c47a8864a2503109a57846037f96041f7a88d9c4dca652c7392b9ce1ab45d158922316d565b32b8c35a6dc2695b108da46c7
@@ -16,17 +16,17 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.6', '2.5', '2.4' ]
19
+ ruby: [ '2.7', '2.6', '2.5', '2.4' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  include:
23
- - ruby: '2.7'
23
+ - ruby: '3.0'
24
24
  os: 'ubuntu-latest'
25
25
  experimental: true
26
- - ruby: '2.7'
26
+ - ruby: '3.0'
27
27
  os: 'windows-latest'
28
28
  experimental: true
29
- - ruby: '2.7'
29
+ - ruby: '3.0'
30
30
  os: 'macos-latest'
31
31
  experimental: true
32
32
  steps:
@@ -35,49 +35,19 @@ jobs:
35
35
  - uses: ruby/setup-ruby@v1
36
36
  with:
37
37
  ruby-version: ${{ matrix.ruby }}
38
+ bundler-cache: true
38
39
 
39
- - if: matrix.os == 'macos-latest'
40
- run: brew install autoconf automake libtool
41
-
42
- - uses: actions/cache@v2
43
- with:
44
- path: vendor/bundle
45
- key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
46
- restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
47
-
48
- - run: bundle config set path 'vendor/bundle'
49
-
50
- - run: bundle install --jobs 4 --retry 3
51
-
52
- - name: install plantuml ubuntu
53
- if: matrix.os == 'ubuntu-latest'
54
- uses: nick-invision/retry@v1
55
- with:
56
- polling_interval_seconds: 5
57
- timeout_minutes: 5
58
- max_attempts: 3
59
- command: >
60
- sudo apt-get update -y && sudo bash -c
61
- "curl -L https://github.com/metanorma/plantuml-install/raw/master/ubuntu.sh | bash"
62
-
63
- - if: matrix.os == 'macos-latest'
64
- run: brew install plantuml
65
-
66
- - if: matrix.os == 'windows-latest'
67
- run: cinst -y plantuml
40
+ - uses: metanorma/metanorma-build-scripts/plantuml-setup-action@master
68
41
 
69
42
  - run: bundle exec rake
70
43
 
71
44
  tests-passed:
72
45
  needs: rake
73
46
  runs-on: ubuntu-latest
74
- continue-on-error: true
75
47
  steps:
76
- - name: Trigger tests passed event
77
- uses: Sibz/github-status-action@v1
48
+ - uses: peter-evans/repository-dispatch@v1
78
49
  with:
79
- authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
80
- context: 'tests-passed-successfully'
81
- description: 'Tests passed successfully'
82
- state: 'success'
83
- sha: ${{ github.event.pull_request.head.sha || github.sha }}
50
+ token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
51
+ repository: ${{ github.repository }}
52
+ event-type: notify
53
+ client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
@@ -102,7 +102,7 @@
102
102
  </attribute>
103
103
  </optional>
104
104
  <oneOrMore>
105
- <ref name="li"/>
105
+ <ref name="ul_li"/>
106
106
  </oneOrMore>
107
107
  <zeroOrMore>
108
108
  <ref name="note"/>
@@ -1716,4 +1716,26 @@
1716
1716
  </zeroOrMore>
1717
1717
  </element>
1718
1718
  </define>
1719
+ <define name="ul_li">
1720
+ <element name="li">
1721
+ <optional>
1722
+ <attribute name="id">
1723
+ <data type="ID"/>
1724
+ </attribute>
1725
+ </optional>
1726
+ <optional>
1727
+ <attribute name="uncheckedcheckbox">
1728
+ <data type="boolean"/>
1729
+ </attribute>
1730
+ </optional>
1731
+ <optional>
1732
+ <attribute name="checkedcheckbox">
1733
+ <data type="boolean"/>
1734
+ </attribute>
1735
+ </optional>
1736
+ <oneOrMore>
1737
+ <ref name="BasicBlock"/>
1738
+ </oneOrMore>
1739
+ </element>
1740
+ </define>
1719
1741
  </grammar>
@@ -79,19 +79,6 @@
79
79
  </choice>
80
80
  </element>
81
81
  </define>
82
- <define name="ul">
83
- <element name="ul">
84
- <attribute name="id">
85
- <data type="ID"/>
86
- </attribute>
87
- <oneOrMore>
88
- <ref name="ul_li"/>
89
- </oneOrMore>
90
- <zeroOrMore>
91
- <ref name="note"/>
92
- </zeroOrMore>
93
- </element>
94
- </define>
95
82
  <define name="sections">
96
83
  <element name="sections">
97
84
  <zeroOrMore>
@@ -192,17 +179,6 @@
192
179
  </zeroOrMore>
193
180
  </element>
194
181
  </define>
195
- <define name="definition">
196
- <element name="definition">
197
- <oneOrMore>
198
- <choice>
199
- <ref name="paragraph"/>
200
- <ref name="figure"/>
201
- <ref name="formula"/>
202
- </choice>
203
- </oneOrMore>
204
- </element>
205
- </define>
206
182
  <define name="annex">
207
183
  <element name="annex">
208
184
  <optional>
@@ -333,6 +309,11 @@
333
309
  <optional>
334
310
  <attribute name="script"/>
335
311
  </optional>
312
+ <optional>
313
+ <attribute name="inline-header">
314
+ <data type="boolean"/>
315
+ </attribute>
316
+ </optional>
336
317
  <optional>
337
318
  <attribute name="obligation">
338
319
  <choice>
@@ -341,6 +322,12 @@
341
322
  </choice>
342
323
  </attribute>
343
324
  </optional>
325
+ <optional>
326
+ <attribute name="number"/>
327
+ </optional>
328
+ <optional>
329
+ <attribute name="type"/>
330
+ </optional>
344
331
  <optional>
345
332
  <ref name="section-title"/>
346
333
  </optional>
@@ -358,57 +345,6 @@
358
345
  </oneOrMore>
359
346
  </choice>
360
347
  </define>
361
- <define name="table">
362
- <element name="table">
363
- <attribute name="id">
364
- <data type="ID"/>
365
- </attribute>
366
- <optional>
367
- <attribute name="width"/>
368
- </optional>
369
- <optional>
370
- <attribute name="unnumbered">
371
- <data type="boolean"/>
372
- </attribute>
373
- </optional>
374
- <optional>
375
- <attribute name="number"/>
376
- </optional>
377
- <optional>
378
- <attribute name="subsequence"/>
379
- </optional>
380
- <optional>
381
- <attribute name="alt"/>
382
- </optional>
383
- <optional>
384
- <attribute name="summary"/>
385
- </optional>
386
- <optional>
387
- <attribute name="uri">
388
- <data type="anyURI"/>
389
- </attribute>
390
- </optional>
391
- <optional>
392
- <ref name="colgroup"/>
393
- </optional>
394
- <optional>
395
- <ref name="tname"/>
396
- </optional>
397
- <optional>
398
- <ref name="thead"/>
399
- </optional>
400
- <ref name="tbody"/>
401
- <optional>
402
- <ref name="tfoot"/>
403
- </optional>
404
- <zeroOrMore>
405
- <ref name="table-note"/>
406
- </zeroOrMore>
407
- <optional>
408
- <ref name="dl"/>
409
- </optional>
410
- </element>
411
- </define>
412
348
  </include>
413
349
  <!-- end overrides -->
414
350
  <!--
@@ -533,28 +469,6 @@
533
469
  <ref name="Clause-Section"/>
534
470
  </element>
535
471
  </define>
536
- <define name="ul_li">
537
- <element name="li">
538
- <optional>
539
- <attribute name="id">
540
- <data type="ID"/>
541
- </attribute>
542
- </optional>
543
- <optional>
544
- <attribute name="uncheckedcheckbox">
545
- <data type="boolean"/>
546
- </attribute>
547
- </optional>
548
- <optional>
549
- <attribute name="checkedcheckbox">
550
- <data type="boolean"/>
551
- </attribute>
552
- </optional>
553
- <oneOrMore>
554
- <ref name="BasicBlock"/>
555
- </oneOrMore>
556
- </element>
557
- </define>
558
472
  <define name="stagename">
559
473
  <element name="stagename">
560
474
  <text/>
@@ -209,6 +209,7 @@ module Asciidoctor
209
209
  def image_name_validate(xmldoc)
210
210
  prefix = image_name_prefix(xmldoc) or return
211
211
  xmldoc.xpath("//image").each do |i|
212
+ next if i["src"].start_with?("data:")
212
213
  if /^ISO_\d+_/.match(File.basename(i["src"]))
213
214
  elsif /^(SL)?#{prefix}fig/.match(File.basename(i["src"]))
214
215
  image_name_validate1(i, prefix)
@@ -152,6 +152,17 @@ module IsoDoc
152
152
  name and name.children.each { |n| parse(n, div) }
153
153
  end
154
154
  end
155
+
156
+ def middle(isoxml, out)
157
+ super
158
+ indexsect isoxml, out
159
+ end
160
+
161
+ def indexsect(isoxml, out)
162
+ isoxml.xpath(ns("//indexsect")).each do |i|
163
+ clause_parse(i, out)
164
+ end
165
+ end
155
166
  end
156
167
  end
157
168
  end
@@ -14,3 +14,7 @@ price_based_on: Price based on % pages
14
14
  under_preparation: Under preparation. (Stage at the time of publication %).
15
15
  table_of_contents: Contents
16
16
  date: Date
17
+ index: Index
18
+ see: see
19
+ see_also: see also
20
+
@@ -13,3 +13,7 @@ reference_number: Numéro de référence
13
13
  price_based_on: Prix basé sur % pages
14
14
  under_preparation: En cours d'élaboration. (Stade au moment de la publication %).
15
15
  date: Date
16
+ index: Index
17
+ see: voir
18
+ see_also: voir aussi
19
+
@@ -11,3 +11,7 @@ reference_number: 参考编号
11
11
  price_based_on: 价格基于%页
12
12
  under_preparation: 制定中(出版时最新状态为%)
13
13
  date: 日期
14
+ index: 索引
15
+ see: 见
16
+ see_also: 另见
17
+
@@ -0,0 +1,139 @@
1
+ module IsoDoc
2
+ module Iso
3
+ class PresentationXMLConvert < IsoDoc::PresentationXMLConvert
4
+ def add_id
5
+ %(id="_#{UUIDTools::UUID.random_create}")
6
+ end
7
+
8
+ def index(docxml)
9
+ unless docxml.at(ns("//index"))
10
+ docxml.xpath(ns("//indexsect")).each { |i| i.remove }
11
+ return
12
+ end
13
+ i = docxml.at(ns("//indexsect")) ||
14
+ docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}</title></indexsect>").first
15
+ index = sort_indexterms(docxml.xpath(ns("//index")), docxml.xpath(ns("//index-xref[@also = 'false']")),
16
+ docxml.xpath(ns("//index-xref[@also = 'true']")))
17
+ index1(docxml, i, index)
18
+ end
19
+
20
+ def index1(docxml, i, index)
21
+ c = i.add_child("<ul></ul>").first
22
+ index.keys.sort.each do |k|
23
+ #c = i.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
24
+ words = index[k].keys.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
25
+ words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
26
+ #c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
27
+ c.add_child index_entries(words, index[k], w)
28
+ end
29
+ end
30
+ @xrefs.bookmark_anchor_names(docxml.xpath(ns(@xrefs.sections_xpath)))
31
+ end
32
+
33
+ def sortable(s)
34
+ HTMLEntities.new.decode(Nokogiri::XML.fragment(s).text)
35
+ end
36
+
37
+ def index_entries_opt
38
+ { xref_lbl: ", ", see_lbl: ", #{see_lbl}", also_lbl: ", #{also_lbl}" }
39
+ end
40
+
41
+ def index_entries(words, index, primary)
42
+ ret = index_entries_head(words[primary], index.dig(words[primary], nil, nil), index_entries_opt)
43
+ words2 = index[words[primary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
44
+ unless words2.empty?
45
+ ret += "<ul>"
46
+ words2.keys.localize(@lang.to_sym).sort.to_a.each do |w|
47
+ ret += index_entries2(words2, index[words[primary]], w)
48
+ end
49
+ ret += "</ul>"
50
+ end
51
+ ret + "</li>"
52
+ end
53
+
54
+ def index_entries2(words, index, secondary)
55
+ ret = index_entries_head(words[secondary], index.dig(words[secondary], nil), index_entries_opt)
56
+ words3 = index[words[secondary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
57
+ unless words3.empty?
58
+ ret += "<ul>"
59
+ words3.keys.localize(@lang.to_sym).sort.to_a.each do |w|
60
+ ret += (index_entries_head(words3[w], index[words[secondary]][words3[w]], index_entries_opt) + "</li>")
61
+ end
62
+ ret += "</ul>"
63
+ end
64
+ ret + "</li>"
65
+ end
66
+
67
+ def index_entries_head(head, entries, opt)
68
+ ret = "<li>#{head}"
69
+ xref = entries&.dig(:xref)&.join(", ")
70
+ see_sort = entries&.dig(:see)&.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
71
+ see = see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map { |k| see_sort[k] }&.join(", ")
72
+ also_sort = entries&.dig(:also)&.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
73
+ also = also_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map { |k| also_sort[k] }&.join(", ")
74
+ ret += "#{opt[:xref_lbl]} #{xref}" if xref
75
+ ret += "#{opt[:see_lbl]} #{see}" if see
76
+ ret += "#{opt[:also_lbl]} #{also}" if also
77
+ ret
78
+ end
79
+
80
+ def see_lbl
81
+ @lang == "en" ? @i18n.see : "<em>#{@i18n.see}</em>"
82
+ end
83
+
84
+ def also_lbl
85
+ @lang == "en" ? @i18n.see_also : "<em>#{@i18n.see_also}</em>"
86
+ end
87
+
88
+ def sort_indexterms(terms, see, also)
89
+ index = extract_indexterms(terms)
90
+ index = extract_indexsee(index, see, :see)
91
+ index = extract_indexsee(index, also, :also)
92
+ index.keys.sort.each_with_object({}) do |k, v|
93
+ v[sortable(k)[0].upcase.transliterate] ||= {}
94
+ v[sortable(k)[0].upcase.transliterate][k] = index[k]
95
+ end
96
+ end
97
+
98
+ def extract_indexsee(v, terms, label)
99
+ terms.each_with_object(v) do |t, v|
100
+ term = t&.at(ns("./primary"))&.children&.to_xml
101
+ term2 = t&.at(ns("./secondary"))&.children&.to_xml
102
+ term3 = t&.at(ns("./tertiary"))&.children&.to_xml
103
+ v[term] ||= {}
104
+ v[term][term2] ||= {}
105
+ v[term][term2][term3] ||= {}
106
+ v[term][term2][term3][label] ||= []
107
+ v[term][term2][term3][label] << t&.at(ns("./target"))&.children&.to_xml
108
+ t.remove
109
+ end
110
+ end
111
+
112
+ def xml_encode_attr(s)
113
+ HTMLEntities.new.encode(s, :basic, :hexadecimal).gsub(/\&#x([^;]+);/) { |x| "&#x#{$1.upcase};" }
114
+ end
115
+
116
+ # attributes are decoded into UTF-8, elements in extract_indexsee are still in entities
117
+ def extract_indexterms(terms)
118
+ terms.each_with_object({}) do |t, v|
119
+ term = t&.at(ns("./primary"))&.children&.to_xml
120
+ term2 = t&.at(ns("./secondary"))&.children&.to_xml
121
+ term3 = t&.at(ns("./tertiary"))&.children&.to_xml
122
+ index2bookmark(t)
123
+ v[term] ||= {}
124
+ v[term][term2] ||= {}
125
+ v[term][term2][term3] ||= {}
126
+ v[term][term2][term3][:xref] ||= []
127
+ to = t["to"] ? "to='#{t['to']}' " : ""
128
+ v[term][term2][term3][:xref] << "<xref target='#{t['id']}' #{to}pagenumber='true'/>"
129
+ end
130
+ end
131
+
132
+ def index2bookmark(t)
133
+ t.name = "bookmark"
134
+ t.children.each { |x| x.remove }
135
+ t["id"] = "_#{UUIDTools::UUID.random_create}"
136
+ end
137
+ end
138
+ end
139
+ end