metanorma-generic 1.11.2 → 2.0.2

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: 97de85e9d88318cf3718865280ca5e855bce23377442c9316d0dc9923227e63e
4
- data.tar.gz: a46b6d97a7be1e38c57092d8789451d5a7851f2f0e617ab88dfe3ec16e6615ac
3
+ metadata.gz: d917b7736b2474be18e0e1bf33121960a9def2252ea774fd7345445d98007c97
4
+ data.tar.gz: 7c5bf9c5252db61bbfec76fee01d349471e4c95cb954b89cfe2b5f02c2cf5d13
5
5
  SHA512:
6
- metadata.gz: 5e80f83a0195978fe797dede990db71f346540d7e11b5ee4b5f54bda2d2790127aaa7e665b77d906048334d9195bd4cb7b698259c64b331c0af0d0f55f5c7f74
7
- data.tar.gz: 4cd866cb0d250759e77d89ef7b91a3ceb380e79f6e04e9ef74d0d0b76c94cfb15f09ad206b2a184540ade1fee7cc10163898389eb17caddc5f120321329f4316
6
+ metadata.gz: 16f4d2e9d84688e8dfb8dfbba1db2491069f4d57812955085551afa196f8337dda5425f6ed997210b95367d013395f4f0dfff7a964462f75152f2ee02a6a9a0c
7
+ data.tar.gz: 1848c4e94683a4b3c1436e995eac69a1ea4f6e08c9536a775808a3c2cb43f814b533820b7ed3c11fb8bf0063444f55a87a30ebd2f0ad335ef44089cd9b1c448e
@@ -9,35 +9,7 @@ on:
9
9
  pull_request:
10
10
 
11
11
  jobs:
12
- rake:
13
- name: Test on Ruby ${{ matrix.ruby }} ${{ matrix.os }}
14
- runs-on: ${{ matrix.os }}
15
- continue-on-error: ${{ matrix.experimental }}
16
- strategy:
17
- fail-fast: false
18
- matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
- os: [ ubuntu-latest, windows-latest, macos-latest ]
21
- experimental: [ false ]
22
- steps:
23
- - uses: actions/checkout@v2
24
- with:
25
- submodules: true
26
-
27
- - uses: ruby/setup-ruby@v1
28
- with:
29
- ruby-version: ${{ matrix.ruby }}
30
- bundler-cache: true
31
-
32
- - run: bundle exec rake
33
-
34
- tests-passed:
35
- needs: rake
36
- runs-on: ubuntu-latest
37
- steps:
38
- - uses: peter-evans/repository-dispatch@v1
39
- with:
40
- token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
41
- repository: ${{ github.repository }}
42
- event-type: tests-passed
43
- client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
12
+ notify:
13
+ uses: metanorma/metanorma-build-scripts/.github/workflows/mn-processor-rake.yml@main
14
+ secrets:
15
+ pat_token: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
data/.gitignore CHANGED
@@ -1,3 +1,13 @@
1
1
  .DS_Store
2
2
 
3
3
  .rubocop-https--*
4
+
5
+ /.rspec_status
6
+ /Gemfile.devel
7
+ /Gemfile.lock
8
+ /coverage/
9
+ /test.doc
10
+ /test.err
11
+ /test.html
12
+ /test.pdf
13
+ /test.presentation.xml
data/README.adoc CHANGED
@@ -31,7 +31,7 @@ Metanorma::Generic.configure do |config|
31
31
  config.document_namespace = 'https://open.ribose.com/standards/mine'
32
32
  config.xml_root_tag = 'mine-standard'
33
33
  config.logo_path = '/metanorma-mine/lib/isodoc/mine/html/logo.jpg'
34
- config.validate_rng_file = '/metanorma-mine/lib/asciidoctor/mine/mine.rng'
34
+ config.validate_rng_file = '/metanorma-mine/lib/metanorma/mine/mine.rng'
35
35
  config.htmlcoverpage = '/metanorma-mine/lib/isodoc/mine/html/html_mine_titlepage.html'
36
36
  config.htmlintropage = '/metanorma-mine/lib/isodoc/mine/html/html_mine_intro.html'
37
37
  config.htmlstylesheet = '/metanorma-mine/lib/isodoc/mine/html/htmlstyle.scss'
@@ -1,183 +1,3 @@
1
- require "asciidoctor"
2
- require "asciidoctor/standoc/converter"
3
- require "fileutils"
4
- require_relative "front"
1
+ require "asciidoctor/generic/deprecated"
2
+ require "metanorma/generic/converter"
5
3
 
6
- module Asciidoctor
7
- module Generic
8
- class Converter < Standoc::Converter
9
- XML_ROOT_TAG = "generic-standard".freeze
10
- XML_NAMESPACE = "https://www.metanorma.org/ns/generic".freeze
11
-
12
- register_for "generic"
13
-
14
- def xml_root_tag
15
- configuration.xml_root_tag || XML_ROOT_TAG
16
- end
17
-
18
- def xml_namespace
19
- configuration.document_namespace || XML_NAMESPACE
20
- end
21
-
22
- def baselocation(loc)
23
- return nil if loc.nil?
24
-
25
- return loc
26
- File.expand_path(File.join(File.dirname(
27
- self.class::_file || __FILE__,
28
- ), "..", "..", "..", loc))
29
- end
30
-
31
- def docidentifier_cleanup(xmldoc)
32
- template = configuration.docid_template ||
33
- "{{ organization_name_short }} {{ docnumeric }}"
34
- docid = xmldoc.at("//bibdata/docidentifier")
35
- id = boilerplate_isodoc(xmldoc).populate_template(template, nil)
36
- id.empty? and docid.remove or docid.children = id
37
- end
38
-
39
- def doctype(node)
40
- d = super
41
- configuration.doctypes or return d == "article" ?
42
- (configuration.default_doctype || "standard") : d
43
- type = configuration.default_doctype ||
44
- configuration.doctypes.keys.dig(0) || "standard"
45
- unless configuration.doctypes.keys.include? d
46
- @log.add("Document Attributes", nil,
47
- "#{d} is not a legal document type: reverting to '#{type}'")
48
- d = type
49
- end
50
- d
51
- end
52
-
53
- def read_config_file(path_to_config_file)
54
- Metanorma::Generic.configuration
55
- .set_default_values_from_yaml_file(path_to_config_file)
56
- end
57
-
58
- def sectiontype_streamline(ret)
59
- if configuration&.termsdefs_titles&.map(&:downcase)&.include? ret
60
- "terms and definitions"
61
- elsif configuration&.symbols_titles&.map(&:downcase)&.include? ret
62
- "symbols and abbreviated terms"
63
- elsif configuration&.normref_titles&.map(&:downcase)&.include? ret
64
- "normative references"
65
- elsif configuration&.bibliography_titles&.map(&:downcase)&.include? ret
66
- "bibliography"
67
- else
68
- ret
69
- end
70
- end
71
-
72
- def document(node)
73
- read_config_file(node.attr("customize")) if node.attr("customize")
74
- super
75
- end
76
-
77
- def outputs(node, ret)
78
- File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
79
- presentation_xml_converter(node)&.convert("#{@filename}.xml")
80
- html_converter(node)&.convert("#{@filename}.presentation.xml",
81
- nil, false, "#{@filename}.html")
82
- doc_converter(node)&.convert("#{@filename}.presentation.xml",
83
- nil, false, "#{@filename}.doc")
84
- pdf_converter(node)&.convert("#{@filename}.presentation.xml",
85
- nil, false, "#{@filename}.pdf")
86
- end
87
-
88
- def validate(doc)
89
- content_validate(doc)
90
- schema_validate(formattedstr_strip(doc.dup),
91
- baselocation(configuration.validate_rng_file) ||
92
- File.join(File.dirname(__FILE__), "generic.rng"))
93
- end
94
-
95
- def content_validate(doc)
96
- super
97
- bibdata_validate(doc.root)
98
- end
99
-
100
- def bibdata_validate(doc)
101
- stage_validate(doc)
102
- committee_validate(doc)
103
- end
104
-
105
- def stage_validate(xmldoc)
106
- stages = configuration&.stage_abbreviations&.keys || return
107
- stages.empty? and return
108
- stage = xmldoc&.at("//bibdata/status/stage")&.text
109
- stages.include? stage or
110
- @log.add("Document Attributes", nil,
111
- "#{stage} is not a recognised status")
112
- end
113
-
114
- def committee_validate(xmldoc)
115
- committees = Array(configuration&.committees) || return
116
- committees.empty? and return
117
- xmldoc.xpath("//bibdata/ext/editorialgroup/committee").each do |c|
118
- committees.include? c.text or
119
- @log.add("Document Attributes", nil,
120
- "#{c.text} is not a recognised committee")
121
- end
122
- end
123
-
124
- def sections_cleanup(xml)
125
- super
126
- xml.xpath("//*[@inline-header]").each do |h|
127
- h.delete("inline-header")
128
- end
129
- end
130
-
131
- def blank_method(*args); end
132
-
133
- def html_converter(node)
134
- IsoDoc::Generic::HtmlConvert.new(html_extract_attributes(node))
135
- end
136
-
137
- def presentation_xml_converter(node)
138
- IsoDoc::Generic::PresentationXMLConvert
139
- .new(html_extract_attributes(node))
140
- end
141
-
142
- alias_method :pdf_converter, :html_converter
143
- alias_method :style, :blank_method
144
- alias_method :title_validate, :blank_method
145
-
146
- def doc_converter(node)
147
- IsoDoc::Generic::WordConvert.new(doc_extract_attributes(node))
148
- end
149
-
150
- def configuration
151
- Metanorma::Generic.configuration
152
- end
153
-
154
- def boilerplate_isodoc(xmldoc)
155
- conv = super
156
- Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
157
- conv.meta.set(a, configuration.send(a))
158
- end
159
- conv
160
- end
161
-
162
- def boilerplate_file(xmldoc)
163
- f = configuration.boilerplate
164
- f.nil? and return super
165
- f.is_a? String and return baselocation(f)
166
- f.is_a? Hash and f[@lang] and return baselocation(f[@lang])
167
- super
168
- end
169
-
170
- def cleanup(xmldoc)
171
- super
172
- empty_metadata_cleanup(xmldoc)
173
- xmldoc
174
- end
175
-
176
- def empty_metadata_cleanup(xmldoc)
177
- xmldoc.xpath("//bibdata/ext//*").each do |x|
178
- x.remove if x.children.empty?
179
- end
180
- end
181
- end
182
- end
183
- end
@@ -0,0 +1,5 @@
1
+ warn "Please replace your references to Asciidoctor::Generic with Metanorma::Generic and your instances of require 'asciidoctor/generic' with require 'metanorma/generic'"
2
+
3
+ exit 127 if ENV['METANORMA_DEPRECATION_FAIL']
4
+
5
+ Asciidoctor::Generic = Metanorma::Generic unless defined? Asciidoctor::Generic
@@ -1,108 +1,3 @@
1
- module Asciidoctor
2
- module Generic
3
- class Converter < Standoc::Converter
4
- def default_publisher
5
- configuration.organization_name_long
6
- end
1
+ require "asciidoctor/generic/deprecated"
2
+ require "metanorma/generic/front"
7
3
 
8
- def org_abbrev
9
- if !configuration.organization_name_long.empty? &&
10
- !configuration.organization_name_short.empty? &&
11
- configuration.organization_name_long !=
12
- configuration.organization_name_short
13
- { configuration.organization_name_long =>
14
- configuration.organization_name_short }
15
- else
16
- super
17
- end
18
- end
19
-
20
- def relaton_relations
21
- Array(configuration.relations) || []
22
- end
23
-
24
- def metadata_committee(node, xml)
25
- return unless node.attr("committee")
26
- xml.editorialgroup do |a|
27
- a.committee node.attr("committee"),
28
- **attr_code(type: node.attr("committee-type"))
29
- i = 2
30
- while node.attr("committee_#{i}") do
31
- a.committee node.attr("committee_#{i}"),
32
- **attr_code(type: node.attr("committee-type_#{i}"))
33
- i += 1
34
- end
35
- end
36
- end
37
-
38
- def metadata_status(node, xml)
39
- xml.status do |s|
40
- s.stage ( node.attr("status") || node.attr("docstage") ||
41
- configuration.default_stage || "published" )
42
- x = node.attr("substage") and s.substage x
43
- x = node.attr("iteration") and s.iteration x
44
- end
45
- end
46
-
47
- def metadata_id(node, xml)
48
- xml.docidentifier **{ type:
49
- configuration.organization_name_short } do |i|
50
- i << "DUMMY"
51
- end
52
- xml.docnumber { |i| i << node.attr("docnumber") }
53
- end
54
-
55
- def metadata_ext(node, ext)
56
- super
57
- if configuration.metadata_extensions.is_a? Hash
58
- metadata_ext_hash(node, ext, configuration.metadata_extensions)
59
- else
60
- Array(configuration.metadata_extensions).each do |e|
61
- a = node.attr(e) and ext.send e, a
62
- end
63
- end
64
- end
65
-
66
- def metadata_doctype(node, xml)
67
- d = doctype(node)
68
- xml.doctype d, attr_code(abbreviation: configuration&.doctypes&.dig(d))
69
- end
70
-
71
- EXT_STRUCT = %w(_output _attribute _list).freeze
72
-
73
- def metadata_ext_hash(node, ext, hash)
74
- hash.each do |k, v|
75
- next if EXT_STRUCT.include?(k) || !v&.is_a?(Hash) && !node.attr(k)
76
- if v&.is_a?(Hash) && v["_list"]
77
- csv_split(node.attr(k), ",").each do |val|
78
- metadata_ext_hash1(k, val, ext, v, node)
79
- end
80
- else
81
- metadata_ext_hash1(k, node.attr(k), ext, v, node)
82
- end
83
- end
84
- end
85
-
86
- def metadata_ext_hash1(key, value, ext, hash, node)
87
- return if hash&.is_a?(Hash) && hash["_attribute"]
88
- is_hash = hash&.is_a?(Hash) &&
89
- !hash.keys.reject { |n| EXT_STRUCT.include?(n) }.empty?
90
- return if !is_hash && (value.nil? || value.empty?)
91
- name = hash&.is_a?(Hash) ? (hash["_output"] || key) : key
92
- ext.send name, **attr_code(metadata_ext_attrs(hash, node)) do |e|
93
- is_hash ? metadata_ext_hash(node, e, hash) : (e << value)
94
- end
95
- end
96
-
97
- def metadata_ext_attrs(hash, node)
98
- return {} unless hash.is_a?(Hash)
99
- ret = {}
100
- hash.each do |k, v|
101
- next unless v.is_a?(Hash) && v["_attribute"]
102
- ret[(v["_output"] || k).to_sym] = node.attr(k)
103
- end
104
- ret
105
- end
106
- end
107
- end
108
- end
@@ -1,7 +1,3 @@
1
- require "asciidoctor/generic/converter"
1
+ require "asciidoctor/generic/deprecated"
2
+ require "metanorma/generic"
2
3
 
3
- module Asciidoctor
4
- module Generic
5
-
6
- end
7
- end
@@ -16,7 +16,7 @@ body {
16
16
 
17
17
  main {margin: 0 3em 0 6em;}
18
18
 
19
- #toc {
19
+ #toc, #toc > ul :is(.h1, .h2, .h3, .h4, .h5, .h6) {
20
20
  @include toc(#485094, #1661AD, #485094);
21
21
  @include sidebarToc();
22
22
  .toc-active a {
@@ -33,6 +33,12 @@ main {margin: 0 3em 0 6em;}
33
33
  }
34
34
  }
35
35
 
36
+ #toc > ul :is(.h1, .h2, .h3, .h4, .h5, .h6) {
37
+ margin-top: 0;
38
+ margin-bottom: 0;
39
+ font-size: 100%;
40
+ }
41
+
36
42
  nav {
37
43
  @include sidebarNav(#f7f7f7, 323px, 45px);
38
44
  }
@@ -66,7 +72,7 @@ nav {
66
72
  margin-top: 1em;
67
73
  }
68
74
 
69
- ul#toc-list {
75
+ ul#toc-list, ul#toc-list > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
70
76
  padding:0;
71
77
  margin:0;
72
78
  }
@@ -186,7 +192,7 @@ p.document-stage {
186
192
  3.1 Titles
187
193
  */
188
194
 
189
- h1,h2,h3,h4,h5,h6 {
195
+ h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 {
190
196
  font-family: $headerfont;
191
197
  color: #1661AD;
192
198
  font-weight: 300;
@@ -194,23 +200,23 @@ h1,h2,h3,h4,h5,h6 {
194
200
  margin-bottom: 0.3em;
195
201
  }
196
202
 
197
- h1 {
203
+ h1,.h1 {
198
204
  font-size: 1.6em;
199
205
  text-transform: uppercase;
200
206
  margin-top: 2em;
201
207
  }
202
208
 
203
- h1#content {
209
+ h1#content, .h1#content {
204
210
  margin-top: 2em;
205
211
  }
206
212
 
207
- h2 {
213
+ h2,.h2 {
208
214
  margin-top: 1.3em;
209
215
  font-size: 1.3em;
210
216
  font-weight: 400;
211
217
  }
212
218
 
213
- h3 {
219
+ h3,.h3 {
214
220
  margin-top: 1.1em;
215
221
  font-size: 1.1em;
216
222
  font-weight: 100;
@@ -640,7 +646,7 @@ To top button
640
646
  page-break-after: always;
641
647
  }
642
648
 
643
- h1, h2, h3, h4 {
649
+ h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
644
650
  page-break-after: avoid;
645
651
  margin-top: 1.2em;
646
652
  }
@@ -675,21 +681,21 @@ To top button
675
681
  padding-left: 0;
676
682
  }
677
683
 
678
- h1.content {
684
+ h1.content, .h1.content {
679
685
  margin-top: 2em;
680
686
  line-height: 2.5em;
681
687
  }
682
688
 
683
- h1 {
689
+ h1,.h1 {
684
690
  font-size: 1.5em;
685
691
  line-height: 1.5;
686
692
  }
687
693
 
688
- h2 {
694
+ h2,.h2 {
689
695
  font-size: 1.2em
690
696
  }
691
697
 
692
- h3 {
698
+ h3,.h3 {
693
699
  font-size: 1em;
694
700
  }
695
701
 
@@ -338,7 +338,7 @@ div.figure, p.figure
338
338
  {text-align: center;}
339
339
 
340
340
 
341
- h1
341
+ h1,.h1
342
342
  {mso-style-priority:1;
343
343
  mso-style-unhide:no;
344
344
  mso-style-qformat:yes;
@@ -352,8 +352,6 @@ h1
352
352
  line-height:13.5pt;
353
353
  mso-pagination:widow-orphan;
354
354
  page-break-after:avoid;
355
- mso-outline-level:1;
356
- mso-list:l1 level1 lfo6;
357
355
  mso-hyphenate:none;
358
356
  tab-stops:20.0pt list 21.6pt left 28.0pt;
359
357
  font-size:13.0pt;
@@ -365,6 +363,10 @@ h1
365
363
  mso-ansi-language:EN-GB;
366
364
  mso-fareast-language:JA;
367
365
  mso-bidi-font-weight:normal;}
366
+ h1 {
367
+ mso-outline-level:1;
368
+ mso-list:l1 level1 lfo6;
369
+ }
368
370
  h1.Annex
369
371
  {mso-style-priority:1;
370
372
  mso-style-unhide:no;
@@ -421,7 +423,7 @@ h1.Annex
421
423
  mso-ansi-language:EN-GB;
422
424
  mso-fareast-language:JA;
423
425
  mso-bidi-font-weight:normal;}
424
- h2
426
+ h2, .h2
425
427
  {mso-style-priority:2;
426
428
  mso-style-unhide:no;
427
429
  mso-style-qformat:yes;
@@ -436,8 +438,6 @@ h2
436
438
  line-height:12.5pt;
437
439
  mso-pagination:widow-orphan;
438
440
  page-break-after:avoid;
439
- mso-outline-level:2;
440
- mso-list:l1 level2 lfo6;
441
441
  mso-hyphenate:none;
442
442
  tab-stops:27.0pt 35.0pt;
443
443
  font-size:12.0pt;
@@ -448,7 +448,11 @@ h2
448
448
  mso-ansi-language:EN-GB;
449
449
  mso-fareast-language:JA;
450
450
  mso-bidi-font-weight:normal;}
451
- h3
451
+ h2 {
452
+ mso-outline-level:2;
453
+ mso-list:l1 level2 lfo6;
454
+ }
455
+ h3, .h3
452
456
  {mso-style-priority:3;
453
457
  mso-style-unhide:no;
454
458
  mso-style-qformat:yes;
@@ -463,8 +467,6 @@ h3
463
467
  line-height:12.0pt;
464
468
  mso-pagination:widow-orphan;
465
469
  page-break-after:avoid;
466
- mso-outline-level:3;
467
- mso-list:l1 level3 lfo6;
468
470
  mso-hyphenate:none;
469
471
  tab-stops:list 36.0pt left 44.0pt;
470
472
  font-size:11.0pt;
@@ -474,7 +476,11 @@ h3
474
476
  mso-ansi-language:EN-GB;
475
477
  mso-fareast-language:JA;
476
478
  mso-bidi-font-weight:normal;}
477
- h4
479
+ h3 {
480
+ mso-outline-level:3;
481
+ mso-list:l1 level3 lfo6;
482
+ }
483
+ h4, .h4
478
484
  {mso-style-priority:4;
479
485
  mso-style-unhide:no;
480
486
  mso-style-qformat:yes;
@@ -489,8 +495,6 @@ h4
489
495
  line-height:12.0pt;
490
496
  mso-pagination:widow-orphan;
491
497
  page-break-after:avoid;
492
- mso-outline-level:4;
493
- mso-list:l1 level4 lfo6;
494
498
  mso-hyphenate:none;
495
499
  tab-stops:51.05pt 57.0pt 68.0pt;
496
500
  font-size:11.0pt;
@@ -500,7 +504,11 @@ h4
500
504
  mso-ansi-language:EN-GB;
501
505
  mso-fareast-language:JA;
502
506
  mso-bidi-font-weight:normal;}
503
- h5
507
+ h4 {
508
+ mso-outline-level:4;
509
+ mso-list:l1 level4 lfo6;
510
+ }
511
+ h5, .h5
504
512
  {mso-style-priority:5;
505
513
  mso-style-unhide:no;
506
514
  mso-style-qformat:yes;
@@ -515,8 +523,6 @@ h5
515
523
  line-height:12.0pt;
516
524
  mso-pagination:widow-orphan;
517
525
  page-break-after:avoid;
518
- mso-outline-level:5;
519
- mso-list:l1 level5 lfo6;
520
526
  mso-hyphenate:none;
521
527
  tab-stops:51.05pt list 54.0pt;
522
528
  font-size:11.0pt;
@@ -526,7 +532,11 @@ h5
526
532
  mso-ansi-language:EN-GB;
527
533
  mso-fareast-language:JA;
528
534
  mso-bidi-font-weight:normal;}
529
- h6
535
+ h5 {
536
+ mso-outline-level:5;
537
+ mso-list:l1 level5 lfo6;
538
+ }
539
+ h6, .h6
530
540
  {mso-style-priority:6;
531
541
  mso-style-unhide:no;
532
542
  mso-style-qformat:yes;
@@ -541,8 +551,6 @@ h6
541
551
  line-height:12.0pt;
542
552
  mso-pagination:widow-orphan;
543
553
  page-break-after:avoid;
544
- mso-outline-level:6;
545
- mso-list:l1 level6 lfo6;
546
554
  mso-hyphenate:none;
547
555
  tab-stops:51.05pt list 72.0pt;
548
556
  font-size:11.0pt;
@@ -552,6 +560,10 @@ h6
552
560
  mso-ansi-language:EN-GB;
553
561
  mso-fareast-language:JA;
554
562
  mso-bidi-font-weight:normal;}
563
+ h6 {
564
+ mso-outline-level:6;
565
+ mso-list:l1 level6 lfo6;
566
+ }
555
567
  p.MsoToc1, li.MsoToc1, div.MsoToc1
556
568
  {mso-style-priority:39;
557
569
  mso-style-unhide:no;
File without changes
@@ -401,9 +401,9 @@
401
401
  <choice>
402
402
  <!-- iso191606 TODO -->
403
403
  <group>
404
- <oneOrMore>
404
+ <zeroOrMore>
405
405
  <ref name="street"/>
406
- </oneOrMore>
406
+ </zeroOrMore>
407
407
  <ref name="city"/>
408
408
  <optional>
409
409
  <ref name="state"/>
@@ -0,0 +1,183 @@
1
+ require "asciidoctor"
2
+ require "metanorma/standoc/converter"
3
+ require "fileutils"
4
+ require_relative "front"
5
+
6
+ module Metanorma
7
+ module Generic
8
+ class Converter < Standoc::Converter
9
+ XML_ROOT_TAG = "generic-standard".freeze
10
+ XML_NAMESPACE = "https://www.metanorma.org/ns/generic".freeze
11
+
12
+ register_for "generic"
13
+
14
+ def xml_root_tag
15
+ configuration.xml_root_tag || XML_ROOT_TAG
16
+ end
17
+
18
+ def xml_namespace
19
+ configuration.document_namespace || XML_NAMESPACE
20
+ end
21
+
22
+ def baselocation(loc)
23
+ return nil if loc.nil?
24
+
25
+ return loc
26
+ File.expand_path(File.join(File.dirname(
27
+ self.class::_file || __FILE__,
28
+ ), "..", "..", "..", loc))
29
+ end
30
+
31
+ def docidentifier_cleanup(xmldoc)
32
+ template = configuration.docid_template ||
33
+ "{{ organization_name_short }} {{ docnumeric }}"
34
+ docid = xmldoc.at("//bibdata/docidentifier")
35
+ id = boilerplate_isodoc(xmldoc).populate_template(template, nil)
36
+ id.empty? and docid.remove or docid.children = id
37
+ end
38
+
39
+ def doctype(node)
40
+ d = super
41
+ configuration.doctypes or return d == "article" ?
42
+ (configuration.default_doctype || "standard") : d
43
+ type = configuration.default_doctype ||
44
+ configuration.doctypes.keys.dig(0) || "standard"
45
+ unless configuration.doctypes.keys.include? d
46
+ @log.add("Document Attributes", nil,
47
+ "#{d} is not a legal document type: reverting to '#{type}'")
48
+ d = type
49
+ end
50
+ d
51
+ end
52
+
53
+ def read_config_file(path_to_config_file)
54
+ Metanorma::Generic.configuration
55
+ .set_default_values_from_yaml_file(path_to_config_file)
56
+ end
57
+
58
+ def sectiontype_streamline(ret)
59
+ if configuration&.termsdefs_titles&.map(&:downcase)&.include? ret
60
+ "terms and definitions"
61
+ elsif configuration&.symbols_titles&.map(&:downcase)&.include? ret
62
+ "symbols and abbreviated terms"
63
+ elsif configuration&.normref_titles&.map(&:downcase)&.include? ret
64
+ "normative references"
65
+ elsif configuration&.bibliography_titles&.map(&:downcase)&.include? ret
66
+ "bibliography"
67
+ else
68
+ ret
69
+ end
70
+ end
71
+
72
+ def document(node)
73
+ read_config_file(node.attr("customize")) if node.attr("customize")
74
+ super
75
+ end
76
+
77
+ def outputs(node, ret)
78
+ File.open("#{@filename}.xml", "w:UTF-8") { |f| f.write(ret) }
79
+ presentation_xml_converter(node)&.convert("#{@filename}.xml")
80
+ html_converter(node)&.convert("#{@filename}.presentation.xml",
81
+ nil, false, "#{@filename}.html")
82
+ doc_converter(node)&.convert("#{@filename}.presentation.xml",
83
+ nil, false, "#{@filename}.doc")
84
+ pdf_converter(node)&.convert("#{@filename}.presentation.xml",
85
+ nil, false, "#{@filename}.pdf")
86
+ end
87
+
88
+ def validate(doc)
89
+ content_validate(doc)
90
+ schema_validate(formattedstr_strip(doc.dup),
91
+ baselocation(configuration.validate_rng_file) ||
92
+ File.join(File.dirname(__FILE__), "generic.rng"))
93
+ end
94
+
95
+ def content_validate(doc)
96
+ super
97
+ bibdata_validate(doc.root)
98
+ end
99
+
100
+ def bibdata_validate(doc)
101
+ stage_validate(doc)
102
+ committee_validate(doc)
103
+ end
104
+
105
+ def stage_validate(xmldoc)
106
+ stages = configuration&.stage_abbreviations&.keys || return
107
+ stages.empty? and return
108
+ stage = xmldoc&.at("//bibdata/status/stage")&.text
109
+ stages.include? stage or
110
+ @log.add("Document Attributes", nil,
111
+ "#{stage} is not a recognised status")
112
+ end
113
+
114
+ def committee_validate(xmldoc)
115
+ committees = Array(configuration&.committees) || return
116
+ committees.empty? and return
117
+ xmldoc.xpath("//bibdata/ext/editorialgroup/committee").each do |c|
118
+ committees.include? c.text or
119
+ @log.add("Document Attributes", nil,
120
+ "#{c.text} is not a recognised committee")
121
+ end
122
+ end
123
+
124
+ def sections_cleanup(xml)
125
+ super
126
+ xml.xpath("//*[@inline-header]").each do |h|
127
+ h.delete("inline-header")
128
+ end
129
+ end
130
+
131
+ def blank_method(*args); end
132
+
133
+ def html_converter(node)
134
+ IsoDoc::Generic::HtmlConvert.new(html_extract_attributes(node))
135
+ end
136
+
137
+ def presentation_xml_converter(node)
138
+ IsoDoc::Generic::PresentationXMLConvert
139
+ .new(html_extract_attributes(node))
140
+ end
141
+
142
+ alias_method :pdf_converter, :html_converter
143
+ alias_method :style, :blank_method
144
+ alias_method :title_validate, :blank_method
145
+
146
+ def doc_converter(node)
147
+ IsoDoc::Generic::WordConvert.new(doc_extract_attributes(node))
148
+ end
149
+
150
+ def configuration
151
+ Metanorma::Generic.configuration
152
+ end
153
+
154
+ def boilerplate_isodoc(xmldoc)
155
+ conv = super
156
+ Metanorma::Generic::Configuration::CONFIG_ATTRS.each do |a|
157
+ conv.meta.set(a, configuration.send(a))
158
+ end
159
+ conv
160
+ end
161
+
162
+ def boilerplate_file(xmldoc)
163
+ f = configuration.boilerplate
164
+ f.nil? and return super
165
+ f.is_a? String and return baselocation(f)
166
+ f.is_a? Hash and f[@lang] and return baselocation(f[@lang])
167
+ super
168
+ end
169
+
170
+ def cleanup(xmldoc)
171
+ super
172
+ empty_metadata_cleanup(xmldoc)
173
+ xmldoc
174
+ end
175
+
176
+ def empty_metadata_cleanup(xmldoc)
177
+ xmldoc.xpath("//bibdata/ext//*").each do |x|
178
+ x.remove if x.children.empty?
179
+ end
180
+ end
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,108 @@
1
+ module Metanorma
2
+ module Generic
3
+ class Converter < Standoc::Converter
4
+ def default_publisher
5
+ configuration.organization_name_long
6
+ end
7
+
8
+ def org_abbrev
9
+ if !configuration.organization_name_long.empty? &&
10
+ !configuration.organization_name_short.empty? &&
11
+ configuration.organization_name_long !=
12
+ configuration.organization_name_short
13
+ { configuration.organization_name_long =>
14
+ configuration.organization_name_short }
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def relaton_relations
21
+ Array(configuration.relations) || []
22
+ end
23
+
24
+ def metadata_committee(node, xml)
25
+ return unless node.attr("committee")
26
+ xml.editorialgroup do |a|
27
+ a.committee node.attr("committee"),
28
+ **attr_code(type: node.attr("committee-type"))
29
+ i = 2
30
+ while node.attr("committee_#{i}") do
31
+ a.committee node.attr("committee_#{i}"),
32
+ **attr_code(type: node.attr("committee-type_#{i}"))
33
+ i += 1
34
+ end
35
+ end
36
+ end
37
+
38
+ def metadata_status(node, xml)
39
+ xml.status do |s|
40
+ s.stage ( node.attr("status") || node.attr("docstage") ||
41
+ configuration.default_stage || "published" )
42
+ x = node.attr("substage") and s.substage x
43
+ x = node.attr("iteration") and s.iteration x
44
+ end
45
+ end
46
+
47
+ def metadata_id(node, xml)
48
+ xml.docidentifier **{ type:
49
+ configuration.organization_name_short } do |i|
50
+ i << "DUMMY"
51
+ end
52
+ xml.docnumber { |i| i << node.attr("docnumber") }
53
+ end
54
+
55
+ def metadata_ext(node, ext)
56
+ super
57
+ if configuration.metadata_extensions.is_a? Hash
58
+ metadata_ext_hash(node, ext, configuration.metadata_extensions)
59
+ else
60
+ Array(configuration.metadata_extensions).each do |e|
61
+ a = node.attr(e) and ext.send e, a
62
+ end
63
+ end
64
+ end
65
+
66
+ def metadata_doctype(node, xml)
67
+ d = doctype(node)
68
+ xml.doctype d, attr_code(abbreviation: configuration&.doctypes&.dig(d))
69
+ end
70
+
71
+ EXT_STRUCT = %w(_output _attribute _list).freeze
72
+
73
+ def metadata_ext_hash(node, ext, hash)
74
+ hash.each do |k, v|
75
+ next if EXT_STRUCT.include?(k) || !v&.is_a?(Hash) && !node.attr(k)
76
+ if v&.is_a?(Hash) && v["_list"]
77
+ csv_split(node.attr(k), ",").each do |val|
78
+ metadata_ext_hash1(k, val, ext, v, node)
79
+ end
80
+ else
81
+ metadata_ext_hash1(k, node.attr(k), ext, v, node)
82
+ end
83
+ end
84
+ end
85
+
86
+ def metadata_ext_hash1(key, value, ext, hash, node)
87
+ return if hash&.is_a?(Hash) && hash["_attribute"]
88
+ is_hash = hash&.is_a?(Hash) &&
89
+ !hash.keys.reject { |n| EXT_STRUCT.include?(n) }.empty?
90
+ return if !is_hash && (value.nil? || value.empty?)
91
+ name = hash&.is_a?(Hash) ? (hash["_output"] || key) : key
92
+ ext.send name, **attr_code(metadata_ext_attrs(hash, node)) do |e|
93
+ is_hash ? metadata_ext_hash(node, e, hash) : (e << value)
94
+ end
95
+ end
96
+
97
+ def metadata_ext_attrs(hash, node)
98
+ return {} unless hash.is_a?(Hash)
99
+ ret = {}
100
+ hash.each do |k, v|
101
+ next unless v.is_a?(Hash) && v["_attribute"]
102
+ ret[(v["_output"] || k).to_sym] = node.attr(k)
103
+ end
104
+ ret
105
+ end
106
+ end
107
+ end
108
+ end
File without changes
@@ -32,6 +32,56 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="index">
36
+ <element name="index">
37
+ <optional>
38
+ <attribute name="to">
39
+ <data type="IDREF"/>
40
+ </attribute>
41
+ </optional>
42
+ <element name="primary">
43
+ <oneOrMore>
44
+ <choice>
45
+ <ref name="PureTextElement"/>
46
+ <ref name="stem"/>
47
+ </choice>
48
+ </oneOrMore>
49
+ </element>
50
+ <optional>
51
+ <element name="secondary">
52
+ <oneOrMore>
53
+ <choice>
54
+ <ref name="PureTextElement"/>
55
+ <ref name="stem"/>
56
+ </choice>
57
+ </oneOrMore>
58
+ </element>
59
+ </optional>
60
+ <optional>
61
+ <element name="tertiary">
62
+ <oneOrMore>
63
+ <choice>
64
+ <ref name="PureTextElement"/>
65
+ <ref name="stem"/>
66
+ </choice>
67
+ </oneOrMore>
68
+ </element>
69
+ </optional>
70
+ </element>
71
+ </define>
72
+ <define name="bibitem">
73
+ <element name="bibitem">
74
+ <attribute name="id">
75
+ <data type="ID"/>
76
+ </attribute>
77
+ <optional>
78
+ <attribute name="hidden">
79
+ <data type="boolean"/>
80
+ </attribute>
81
+ </optional>
82
+ <ref name="BibliographicItem"/>
83
+ </element>
84
+ </define>
35
85
  <define name="section-title">
36
86
  <element name="title">
37
87
  <zeroOrMore>
@@ -690,6 +740,7 @@
690
740
  <ref name="terms"/>
691
741
  <ref name="term-clause"/>
692
742
  <ref name="definitions"/>
743
+ <ref name="floating-title"/>
693
744
  </choice>
694
745
  </oneOrMore>
695
746
  </element>
@@ -1013,6 +1064,26 @@
1013
1064
  </zeroOrMore>
1014
1065
  </element>
1015
1066
  </define>
1067
+ <define name="sub">
1068
+ <element name="sub">
1069
+ <zeroOrMore>
1070
+ <choice>
1071
+ <ref name="PureTextElement"/>
1072
+ <ref name="stem"/>
1073
+ </choice>
1074
+ </zeroOrMore>
1075
+ </element>
1076
+ </define>
1077
+ <define name="sup">
1078
+ <element name="sup">
1079
+ <zeroOrMore>
1080
+ <choice>
1081
+ <ref name="PureTextElement"/>
1082
+ <ref name="stem"/>
1083
+ </choice>
1084
+ </zeroOrMore>
1085
+ </element>
1086
+ </define>
1016
1087
  <define name="pagebreak">
1017
1088
  <element name="pagebreak">
1018
1089
  <optional>
@@ -1680,6 +1751,7 @@
1680
1751
  <ref name="clause-subsection"/>
1681
1752
  <ref name="terms"/>
1682
1753
  <ref name="definitions"/>
1754
+ <ref name="floating-title"/>
1683
1755
  </choice>
1684
1756
  </oneOrMore>
1685
1757
  </choice>
@@ -1722,6 +1794,7 @@
1722
1794
  <ref name="terms"/>
1723
1795
  <ref name="definitions"/>
1724
1796
  <ref name="references"/>
1797
+ <ref name="floating-title"/>
1725
1798
  </choice>
1726
1799
  </zeroOrMore>
1727
1800
  </group>
@@ -1973,7 +2046,11 @@
1973
2046
  </optional>
1974
2047
  <element name="name">
1975
2048
  <zeroOrMore>
1976
- <ref name="PureTextElement"/>
2049
+ <choice>
2050
+ <ref name="PureTextElement"/>
2051
+ <ref name="stem"/>
2052
+ <ref name="index"/>
2053
+ </choice>
1977
2054
  </zeroOrMore>
1978
2055
  </element>
1979
2056
  <optional>
@@ -1987,7 +2064,7 @@
1987
2064
  </element>
1988
2065
  </optional>
1989
2066
  <optional>
1990
- <element name="grammar-info">
2067
+ <element name="grammar">
1991
2068
  <ref name="Grammar"/>
1992
2069
  </element>
1993
2070
  </optional>
@@ -2196,7 +2273,18 @@
2196
2273
  <ref name="MultilingualRenderingType"/>
2197
2274
  </attribute>
2198
2275
  </optional>
2199
- <ref name="paragraph"/>
2276
+ <oneOrMore>
2277
+ <choice>
2278
+ <ref name="formula"/>
2279
+ <ref name="ul"/>
2280
+ <ref name="ol"/>
2281
+ <ref name="dl"/>
2282
+ <ref name="quote"/>
2283
+ <ref name="sourcecode"/>
2284
+ <ref name="paragraph"/>
2285
+ <ref name="figure"/>
2286
+ </choice>
2287
+ </oneOrMore>
2200
2288
  </element>
2201
2289
  </define>
2202
2290
  <define name="termsource">
@@ -2530,4 +2618,17 @@
2530
2618
  </oneOrMore>
2531
2619
  </element>
2532
2620
  </define>
2621
+ <define name="floating-title">
2622
+ <element name="floating-title">
2623
+ <attribute name="id">
2624
+ <data type="ID"/>
2625
+ </attribute>
2626
+ <attribute name="depth">
2627
+ <data type="int"/>
2628
+ </attribute>
2629
+ <zeroOrMore>
2630
+ <ref name="TextElement"/>
2631
+ </zeroOrMore>
2632
+ </element>
2633
+ </define>
2533
2634
  </grammar>
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.11.2".freeze
3
+ VERSION = "2.0.2".freeze
4
4
  end
5
5
  end
@@ -3,6 +3,7 @@ require "metanorma/generic/version"
3
3
  require "forwardable"
4
4
  require "yaml"
5
5
 
6
+
6
7
  module Metanorma
7
8
  module Generic # rubocop:disable Style/MutableConstant
8
9
  ORGANIZATION_NAME_SHORT = "Acme"
@@ -1,6 +1,6 @@
1
1
  require "metanorma/generic"
2
2
  require "asciidoctor"
3
- require "asciidoctor/generic"
3
+ require "metanorma/generic/converter"
4
4
  require "isodoc/generic"
5
5
 
6
6
  if defined? Metanorma
@@ -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-standoc", "~> 1.11.0"
30
+ spec.add_dependency "metanorma-standoc", "~> 2.0.0"
31
31
  spec.add_dependency "ruby-jing"
32
32
 
33
33
  spec.add_development_dependency "debug"
@@ -7,7 +7,7 @@ logo_path: /metanorma-mine/lib/isodoc/mine/html/logo.jpg
7
7
  logo_paths:
8
8
  - /metanorma-mine/lib/isodoc/mine/html/logo1.jpg
9
9
  - /metanorma-mine/lib/isodoc/mine/html/logo2.jpg
10
- validate_rng_file: /metanorma-mine/lib/asciidoctor/mine/mine.rng
10
+ validate_rng_file: /metanorma-mine/lib/metanorma/mine/mine.rng
11
11
  htmlcoverpage: /metanorma-mine/lib/isodoc/mine/html/html_mine_titlepage.html
12
12
  htmlintropage: /metanorma-mine/lib/isodoc/mine/html/html_mine_intro.html
13
13
  htmlstylesheet: /metanorma-mine/lib/isodoc/mine/html/htmlstyle.scss
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-generic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.2
4
+ version: 2.0.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: 2021-12-13 00:00:00.000000000 Z
11
+ date: 2022-01-22 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: 1.11.0
33
+ version: 2.0.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: 1.11.0
40
+ version: 2.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-jing
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -213,14 +213,9 @@ files:
213
213
  - bin/rspec
214
214
  - bin/setup
215
215
  - lib/asciidoctor/generic.rb
216
- - lib/asciidoctor/generic/basicdoc.rng
217
- - lib/asciidoctor/generic/biblio.rng
218
216
  - lib/asciidoctor/generic/converter.rb
217
+ - lib/asciidoctor/generic/deprecated.rb
219
218
  - lib/asciidoctor/generic/front.rb
220
- - lib/asciidoctor/generic/generic.rng
221
- - lib/asciidoctor/generic/isodoc.rng
222
- - lib/asciidoctor/generic/reqt.rng
223
- - lib/asciidoctor/generic/rsd.rng
224
219
  - lib/isodoc/generic.rb
225
220
  - lib/isodoc/generic/base_convert.rb
226
221
  - lib/isodoc/generic/html/generic.scss
@@ -243,8 +238,16 @@ files:
243
238
  - lib/isodoc/generic/xref.rb
244
239
  - lib/metanorma-generic.rb
245
240
  - lib/metanorma/generic.rb
241
+ - lib/metanorma/generic/basicdoc.rng
242
+ - lib/metanorma/generic/biblio.rng
243
+ - lib/metanorma/generic/converter.rb
246
244
  - lib/metanorma/generic/fonts_manifest.yaml
245
+ - lib/metanorma/generic/front.rb
246
+ - lib/metanorma/generic/generic.rng
247
+ - lib/metanorma/generic/isodoc.rng
247
248
  - lib/metanorma/generic/processor.rb
249
+ - lib/metanorma/generic/reqt.rng
250
+ - lib/metanorma/generic/rsd.rng
248
251
  - lib/metanorma/generic/version.rb
249
252
  - metanorma-generic.gemspec
250
253
  - metanorma.yml.example