metanorma-generic 1.11.1 → 2.0.1

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: 68780e456b59524a58f5943a2f611eb77eb8609d71d67d0fd03493845bd77a26
4
- data.tar.gz: d80def3233b10b107eae9159b981755486555782962d5ab48ef8dfbd5f476e53
3
+ metadata.gz: 5fa88f0baa395e56b19c26fbeb278c4b4424368d23c20282d1d41e1c2b0adfff
4
+ data.tar.gz: c0ca25b62c407cd76125ecba1a97e48557b4f90adf31eb34841ba1dee94a3657
5
5
  SHA512:
6
- metadata.gz: 2e583a0c09780c638708932e53c6d625f291650ad66cbc0c15aad3eb8fce7f1bc728e6503b7b2c7c531558da48fd305c4575541255f501cfd68a391ab775fd17
7
- data.tar.gz: 0c937c51fc767624d6c05d2d74e409a8128b4c45d57da929bed48cf301be47b5897ecff6632219bb1532b785cce3cf707686568f42e9b6c2651ea65db27cd6a5
6
+ metadata.gz: 2ab1796a867d326954a8e42668b77bf7b26febe4bc658d44a2f8ddab232c18834911cca7b4b7225bddffbe429d553aea5484fdb50db35f6f0adbcc9758d3e4ca
7
+ data.tar.gz: 9658b9faf8d7c0d70b65c8d0458534809acf4744401ec9ff899512dd3db04a94706fa25c983befe7aa633aca525a5f2ab3589426ba0b9fd48c497ba5d3f71c64
@@ -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,11 @@ 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
+ }
40
+
36
41
  nav {
37
42
  @include sidebarNav(#f7f7f7, 323px, 45px);
38
43
  }
@@ -66,7 +71,7 @@ nav {
66
71
  margin-top: 1em;
67
72
  }
68
73
 
69
- ul#toc-list {
74
+ ul#toc-list, ul#toc-list > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
70
75
  padding:0;
71
76
  margin:0;
72
77
  }
@@ -186,7 +191,7 @@ p.document-stage {
186
191
  3.1 Titles
187
192
  */
188
193
 
189
- h1,h2,h3,h4,h5,h6 {
194
+ h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6 {
190
195
  font-family: $headerfont;
191
196
  color: #1661AD;
192
197
  font-weight: 300;
@@ -194,23 +199,23 @@ h1,h2,h3,h4,h5,h6 {
194
199
  margin-bottom: 0.3em;
195
200
  }
196
201
 
197
- h1 {
202
+ h1,.h1 {
198
203
  font-size: 1.6em;
199
204
  text-transform: uppercase;
200
205
  margin-top: 2em;
201
206
  }
202
207
 
203
- h1#content {
208
+ h1#content, .h1#content {
204
209
  margin-top: 2em;
205
210
  }
206
211
 
207
- h2 {
212
+ h2,.h2 {
208
213
  margin-top: 1.3em;
209
214
  font-size: 1.3em;
210
215
  font-weight: 400;
211
216
  }
212
217
 
213
- h3 {
218
+ h3,.h3 {
214
219
  margin-top: 1.1em;
215
220
  font-size: 1.1em;
216
221
  font-weight: 100;
@@ -640,7 +645,7 @@ To top button
640
645
  page-break-after: always;
641
646
  }
642
647
 
643
- h1, h2, h3, h4 {
648
+ h1, h2, h3, h4, .h1, .h2, .h3, .h4 {
644
649
  page-break-after: avoid;
645
650
  margin-top: 1.2em;
646
651
  }
@@ -675,21 +680,21 @@ To top button
675
680
  padding-left: 0;
676
681
  }
677
682
 
678
- h1.content {
683
+ h1.content, .h1.content {
679
684
  margin-top: 2em;
680
685
  line-height: 2.5em;
681
686
  }
682
687
 
683
- h1 {
688
+ h1,.h1 {
684
689
  font-size: 1.5em;
685
690
  line-height: 1.5;
686
691
  }
687
692
 
688
- h2 {
693
+ h2,.h2 {
689
694
  font-size: 1.2em
690
695
  }
691
696
 
692
- h3 {
697
+ h3,.h3 {
693
698
  font-size: 1em;
694
699
  }
695
700
 
@@ -16,7 +16,6 @@ $('#toggle').on('click', function(){
16
16
  else {
17
17
  $('nav').show();
18
18
  $('nav').animate({ 'left': '0px' }, 'slow');
19
- $('.container').animate({ 'padding-left': '360px' }, 'slow');
20
19
  }
21
20
  });
22
21
  </script>
@@ -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
File without changes
@@ -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,19 @@
32
32
  <ref name="DocumentType"/>
33
33
  </element>
34
34
  </define>
35
+ <define name="bibitem">
36
+ <element name="bibitem">
37
+ <attribute name="id">
38
+ <data type="ID"/>
39
+ </attribute>
40
+ <optional>
41
+ <attribute name="hidden">
42
+ <data type="boolean"/>
43
+ </attribute>
44
+ </optional>
45
+ <ref name="BibliographicItem"/>
46
+ </element>
47
+ </define>
35
48
  <define name="section-title">
36
49
  <element name="title">
37
50
  <zeroOrMore>
@@ -690,6 +703,7 @@
690
703
  <ref name="terms"/>
691
704
  <ref name="term-clause"/>
692
705
  <ref name="definitions"/>
706
+ <ref name="floating-title"/>
693
707
  </choice>
694
708
  </oneOrMore>
695
709
  </element>
@@ -1680,6 +1694,7 @@
1680
1694
  <ref name="clause-subsection"/>
1681
1695
  <ref name="terms"/>
1682
1696
  <ref name="definitions"/>
1697
+ <ref name="floating-title"/>
1683
1698
  </choice>
1684
1699
  </oneOrMore>
1685
1700
  </choice>
@@ -1722,6 +1737,7 @@
1722
1737
  <ref name="terms"/>
1723
1738
  <ref name="definitions"/>
1724
1739
  <ref name="references"/>
1740
+ <ref name="floating-title"/>
1725
1741
  </choice>
1726
1742
  </zeroOrMore>
1727
1743
  </group>
@@ -1796,6 +1812,20 @@
1796
1812
  <data type="ID"/>
1797
1813
  </attribute>
1798
1814
  </optional>
1815
+ <optional>
1816
+ <attribute name="language"/>
1817
+ </optional>
1818
+ <optional>
1819
+ <attribute name="script"/>
1820
+ </optional>
1821
+ <optional>
1822
+ <attribute name="tag"/>
1823
+ </optional>
1824
+ <optional>
1825
+ <attribute name="multilingual-rendering">
1826
+ <ref name="MultilingualRenderingType"/>
1827
+ </attribute>
1828
+ </optional>
1799
1829
  <oneOrMore>
1800
1830
  <ref name="preferred"/>
1801
1831
  </oneOrMore>
@@ -1959,7 +1989,11 @@
1959
1989
  </optional>
1960
1990
  <element name="name">
1961
1991
  <zeroOrMore>
1962
- <ref name="PureTextElement"/>
1992
+ <choice>
1993
+ <ref name="PureTextElement"/>
1994
+ <ref name="stem"/>
1995
+ <ref name="index"/>
1996
+ </choice>
1963
1997
  </zeroOrMore>
1964
1998
  </element>
1965
1999
  <optional>
@@ -1973,7 +2007,7 @@
1973
2007
  </element>
1974
2008
  </optional>
1975
2009
  <optional>
1976
- <element name="grammar-info">
2010
+ <element name="grammar">
1977
2011
  <ref name="Grammar"/>
1978
2012
  </element>
1979
2013
  </optional>
@@ -2516,4 +2550,17 @@
2516
2550
  </oneOrMore>
2517
2551
  </element>
2518
2552
  </define>
2553
+ <define name="floating-title">
2554
+ <element name="floating-title">
2555
+ <attribute name="id">
2556
+ <data type="ID"/>
2557
+ </attribute>
2558
+ <attribute name="depth">
2559
+ <data type="int"/>
2560
+ </attribute>
2561
+ <zeroOrMore>
2562
+ <ref name="TextElement"/>
2563
+ </zeroOrMore>
2564
+ </element>
2565
+ </define>
2519
2566
  </grammar>
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.11.1".freeze
3
+ VERSION = "2.0.1".freeze
4
4
  end
5
5
  end
@@ -3,8 +3,9 @@ require "metanorma/generic/version"
3
3
  require "forwardable"
4
4
  require "yaml"
5
5
 
6
+
6
7
  module Metanorma
7
- module Generic
8
+ module Generic # rubocop:disable Style/MutableConstant
8
9
  ORGANIZATION_NAME_SHORT = "Acme"
9
10
  ORGANIZATION_NAME_LONG = "Acme Corp."
10
11
  DOCUMENT_NAMESPACE = "https://www.metanorma.org/ns/generic"
@@ -63,23 +64,10 @@ module Metanorma
63
64
  ].freeze
64
65
 
65
66
  def filepath_attrs
66
- %i[
67
- i18nyaml
68
- boilerplate
69
- logo_path
70
- logo_paths
71
- header
72
- htmlcoverpage
73
- htmlintropage
74
- htmlstylesheet
75
- scripts
76
- scripts_pdf
77
- standardstylesheet
78
- validate_rng_file
79
- wordcoverpage
80
- wordintropage
81
- wordstylesheet
82
- ]
67
+ %i[i18nyaml boilerplate logo_path logo_paths header
68
+ htmlcoverpage htmlintropage htmlstylesheet scripts scripts_pdf
69
+ standardstylesheet validate_rng_file wordcoverpage wordintropage
70
+ wordstylesheet]
83
71
  end
84
72
 
85
73
  attr_accessor(*CONFIG_ATTRS)
@@ -88,7 +76,7 @@ module Metanorma
88
76
  attr_accessor :_file
89
77
  end
90
78
 
91
- def self.inherited(klass)
79
+ def self.inherited(klass) # rubocop:disable Lint/MissingSuper
92
80
  klass._file = caller_locations(1..1).first.absolute_path
93
81
  end
94
82
 
@@ -115,7 +103,8 @@ module Metanorma
115
103
 
116
104
  def set_default_values_from_yaml_file(config_file)
117
105
  root_path = File.dirname(self.class::_file || __FILE__)
118
- default_config_options = YAML.load(File.read(config_file))
106
+ default_config_options =
107
+ YAML.safe_load(File.read(config_file, encoding: "UTF-8"))
119
108
  if default_config_options["doctypes"].is_a? Array
120
109
  default_config_options["doctypes"] =
121
110
  default_config_options["doctypes"].each_with_object({}) do |k, m|
@@ -133,7 +122,7 @@ module Metanorma
133
122
  end
134
123
 
135
124
  def blank?(val)
136
- val.nil? || val.respond_to?(:empty?) && val.empty?
125
+ val.nil? || (val.respond_to?(:empty?) && val.empty?)
137
126
  end
138
127
 
139
128
  def absolute_path(value, root_path)
@@ -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.1
4
+ version: 2.0.1
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-11-29 00:00:00.000000000 Z
11
+ date: 2022-01-17 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
@@ -267,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
270
  - !ruby/object:Gem::Version
268
271
  version: '0'
269
272
  requirements: []
270
- rubygems_version: 3.2.22
273
+ rubygems_version: 3.2.32
271
274
  signing_key:
272
275
  specification_version: 4
273
276
  summary: Metanorma template gem for customisation.