metanorma-generic 1.7.0 → 1.8.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: dbd87f79baeb66107643bd3c6e9377853f72f3b19d17615aced5737609ea31e4
4
- data.tar.gz: a1e014a6a7076b4f39c37bcb35d67fecb221ff0494ba38ce88482affb8aef854
3
+ metadata.gz: 23224f24cfc57e364e8801c09101c879f2baeb63efa09ffd5548e767c3c8d7e1
4
+ data.tar.gz: 6c826f42fec91c198a5d1e716fd959885167d81b6eb9ec3e193b2eef38ee3281
5
5
  SHA512:
6
- metadata.gz: b26374f517b2c486fd6780a66f05357689990026dab52e88c8f8b9a1aec881653a4f23f915bf5e6944c83ae8fe943046ae42047382c3968a5b1cca11204f5a53
7
- data.tar.gz: 35502f72cf8aa2f3f19848d4fe9326994f8af544531e71da3dabf61215329c164404cfd5d7fab6e72da66f43ae851272ceaf6a1d9fbf6a72fdf15552d6dcd4e6
6
+ metadata.gz: '09ff518c6b136171db3126d7d90a0db928d8a8bc306c3480d8ef360e425cb4af79cf6953be910aa0bfd7719e67feac950c6c00aa2a0d7eb3b9ed71f188402ea9'
7
+ data.tar.gz: adfb3a83e8e6d98f1b854e7fb9b05271c46fbb72b58a0d71e428b8614016a1b1b7b5a75d0304172ce517d6d2df095bab1f180b47bc6dfbae1a0a606115618e52
@@ -0,0 +1,62 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ name: rake
4
+
5
+ on:
6
+ push:
7
+ branches: [ master, main ]
8
+ tags: [ v* ]
9
+ pull_request:
10
+
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: [ '2.6', '2.5', '2.4' ]
20
+ os: [ ubuntu-latest, windows-latest, macos-latest ]
21
+ experimental: [ false ]
22
+ include:
23
+ - ruby: '2.7'
24
+ os: 'ubuntu-latest'
25
+ experimental: true
26
+ - ruby: '2.7'
27
+ os: 'windows-latest'
28
+ experimental: true
29
+ - ruby: '2.7'
30
+ os: 'macos-latest'
31
+ experimental: true
32
+ steps:
33
+ - uses: actions/checkout@master
34
+
35
+ - uses: ruby/setup-ruby@v1
36
+ with:
37
+ ruby-version: ${{ matrix.ruby }}
38
+
39
+ - uses: actions/cache@v2
40
+ with:
41
+ path: vendor/bundle
42
+ key: bundle-${{ matrix.os }}-${{ matrix.ruby }}-${{ hashFiles('**/*.gemspec') }}
43
+ restore-keys: bundle-${{ matrix.os }}-${{ matrix.ruby }}
44
+
45
+ - run: bundle config set path 'vendor/bundle'
46
+
47
+ - run: bundle install --jobs 4 --retry 3
48
+
49
+ - run: bundle exec rake
50
+
51
+ tests-passed:
52
+ needs: rake
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - name: Trigger tests passed event
56
+ uses: Sibz/github-status-action@v1
57
+ with:
58
+ authToken: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
59
+ context: 'tests-passed-successfully'
60
+ description: 'Tests passed successfully'
61
+ state: 'success'
62
+ sha: ${{ github.event.pull_request.head.sha || github.sha }}
@@ -3,9 +3,7 @@
3
3
  Formerly known as metanorma-acme
4
4
 
5
5
  image:https://img.shields.io/gem/v/metanorma-generic.svg["Gem Version", link="https://rubygems.org/gems/metanorma-generic"]
6
- image:https://github.com/metanorma/metanorma-generic/workflows/macos/badge.svg["Build Status (macOS)", link="https://github.com/metanorma/metanorma-generic/actions?workflow=macos"]
7
- image:https://github.com/metanorma/metanorma-generic/workflows/ubuntu/badge.svg["Build Status (ubuntu)", link="https://github.com/metanorma/metanorma-generic/actions?workflow=ubuntu"]
8
- image:https://github.com/metanorma/metanorma-generic/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/metanorma/metanorma-generic/actions?workflow=windows"]
6
+ image:https://github.com/metanorma/metanorma-generic/workflows/rake/badge.svg["Build Status", link="https://github.com/metanorma/metanorma-generic/actions?workflow=rake"]
9
7
  image:https://codeclimate.com/github/metanorma/metanorma-acme/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/metanorma-acme"]
10
8
  image:https://img.shields.io/github/issues-pr-raw/metanorma/metanorma-generic.svg["Pull Requests", link="https://github.com/metanorma/metanorma-generic/pulls"]
11
9
  image:https://img.shields.io/github/commits-since/metanorma/metanorma-generic/latest.svg["Commits since latest",link="https://github.com/metanorma/metanorma-generic/releases"]
@@ -596,6 +596,7 @@
596
596
  <ref name="bookmark"/>
597
597
  <ref name="image"/>
598
598
  <ref name="index"/>
599
+ <ref name="index-xref"/>
599
600
  </choice>
600
601
  </define>
601
602
  <define name="PureTextElement">
@@ -728,15 +729,61 @@
728
729
  </define>
729
730
  <define name="index">
730
731
  <element name="index">
731
- <attribute name="primary"/>
732
+ <attribute name="to">
733
+ <data type="IDREF"/>
734
+ </attribute>
735
+ <element name="primary">
736
+ <oneOrMore>
737
+ <ref name="PureTextElement"/>
738
+ </oneOrMore>
739
+ </element>
732
740
  <optional>
733
- <attribute name="secondary"/>
741
+ <element name="secondary">
742
+ <oneOrMore>
743
+ <ref name="PureTextElement"/>
744
+ </oneOrMore>
745
+ </element>
734
746
  </optional>
735
747
  <optional>
736
- <attribute name="tertiary"/>
748
+ <element name="tertiary">
749
+ <oneOrMore>
750
+ <ref name="PureTextElement"/>
751
+ </oneOrMore>
752
+ </element>
737
753
  </optional>
738
754
  </element>
739
755
  </define>
756
+ <define name="index-xref">
757
+ <element name="index-xref">
758
+ <attribute name="also">
759
+ <data type="boolean"/>
760
+ </attribute>
761
+ <element name="primary">
762
+ <oneOrMore>
763
+ <ref name="PureTextElement"/>
764
+ </oneOrMore>
765
+ </element>
766
+ <optional>
767
+ <element name="secondary">
768
+ <oneOrMore>
769
+ <ref name="PureTextElement"/>
770
+ </oneOrMore>
771
+ </element>
772
+ </optional>
773
+ <optional>
774
+ <element name="tertiary">
775
+ <oneOrMore>
776
+ <ref name="PureTextElement"/>
777
+ </oneOrMore>
778
+ </element>
779
+ </optional>
780
+ <element name="target">
781
+ <oneOrMore>
782
+ <ref name="PureTextElement"/>
783
+ </oneOrMore>
784
+ </element>
785
+ </element>
786
+ </define>
740
787
  <!-- bare ID element, used for referencing arbitrary spans of text -->
741
788
  <define name="bookmark">
742
789
  <element name="bookmark">
@@ -1,13 +1,10 @@
1
1
  require "asciidoctor"
2
2
  require "asciidoctor/standoc/converter"
3
3
  require "fileutils"
4
+ require_relative "front"
4
5
 
5
6
  module Asciidoctor
6
7
  module Generic
7
-
8
- # A {Converter} implementation that generates RSD output, and a document
9
- # schema encapsulation of the document for validation
10
- #
11
8
  class Converter < Standoc::Converter
12
9
  XML_ROOT_TAG = "generic-standard".freeze
13
10
  XML_NAMESPACE = "https://www.metanorma.org/ns/generic".freeze
@@ -24,53 +21,11 @@ module Asciidoctor
24
21
 
25
22
  def baselocation(loc)
26
23
  return nil if loc.nil?
24
+ return loc
27
25
  File.expand_path(File.join(File.dirname(
28
26
  self.class::_file || __FILE__), "..", "..", "..", loc))
29
27
  end
30
28
 
31
- def default_publisher
32
- configuration.organization_name_long
33
- end
34
-
35
- def org_abbrev
36
- if !configuration.organization_name_long.empty? &&
37
- !configuration.organization_name_short.empty? &&
38
- configuration.organization_name_long !=
39
- configuration.organization_name_short
40
- { configuration.organization_name_long =>
41
- configuration.organization_name_short }
42
- else
43
- super
44
- end
45
- end
46
-
47
- def relaton_relations
48
- Array(configuration.relations) || []
49
- end
50
-
51
- def metadata_committee(node, xml)
52
- return unless node.attr("committee")
53
- xml.editorialgroup do |a|
54
- a.committee node.attr("committee"),
55
- **attr_code(type: node.attr("committee-type"))
56
- i = 2
57
- while node.attr("committee_#{i}") do
58
- a.committee node.attr("committee_#{i}"),
59
- **attr_code(type: node.attr("committee-type_#{i}"))
60
- i += 1
61
- end
62
- end
63
- end
64
-
65
- def metadata_status(node, xml)
66
- xml.status do |s|
67
- s.stage ( node.attr("status") || node.attr("docstage") ||
68
- configuration.default_stage || "published" )
69
- x = node.attr("substage") and s.substage x
70
- x = node.attr("iteration") and s.iteration x
71
- end
72
- end
73
-
74
29
  def docidentifier_cleanup(xmldoc)
75
30
  template = configuration.docid_template ||
76
31
  "{{ organization_name_short }} {{ docnumeric }}"
@@ -79,30 +34,16 @@ module Asciidoctor
79
34
  id.empty? and docid.remove or docid.children = id
80
35
  end
81
36
 
82
- def metadata_id(node, xml)
83
- xml.docidentifier **{ type:
84
- configuration.organization_name_short } do |i|
85
- i << "DUMMY"
86
- end
87
- xml.docnumber { |i| i << node.attr("docnumber") }
88
- end
89
-
90
- def metadata_ext(node, ext)
91
- super
92
- Array(configuration.metadata_extensions).each do |e|
93
- a = node.attr(e) and ext.send e, a
94
- end
95
- end
96
-
97
37
  def doctype(node)
98
38
  d = super
99
- configuration.doctypes or return d == "article" ? "standard" : d
100
- default = configuration.default_doctype || Array(configuration.doctypes).dig(0) ||
101
- "standard"
102
- unless Array(configuration.doctypes).include? d
39
+ configuration.doctypes or return d == "article" ?
40
+ (configuration.default_doctype || "standard") : d
41
+ type = configuration.default_doctype ||
42
+ configuration.doctypes.keys.dig(0) || "standard"
43
+ unless configuration.doctypes.keys.include? d
103
44
  @log.add("Document Attributes", nil,
104
- "#{d} is not a legal document type: reverting to '#{default}'")
105
- d = default
45
+ "#{d} is not a legal document type: reverting to '#{type}'")
46
+ d = type
106
47
  end
107
48
  d
108
49
  end
@@ -113,13 +54,13 @@ module Asciidoctor
113
54
  end
114
55
 
115
56
  def sectiontype_streamline(ret)
116
- if configuration.termsdefs_titles.map(&:downcase).include? (ret)
57
+ if configuration&.termsdefs_titles&.map(&:downcase)&.include? (ret)
117
58
  "terms and definitions"
118
- elsif configuration.symbols_titles.map(&:downcase).include? (ret)
59
+ elsif configuration&.symbols_titles&.map(&:downcase)&.include? (ret)
119
60
  "symbols and abbreviated terms"
120
- elsif configuration.normref_titles.map(&:downcase).include? (ret)
61
+ elsif configuration&.normref_titles&.map(&:downcase)&.include? (ret)
121
62
  "normative references"
122
- elsif configuration.bibliography_titles.map(&:downcase).include? (ret)
63
+ elsif configuration&.bibliography_titles&.map(&:downcase)&.include? (ret)
123
64
  "bibliography"
124
65
  else
125
66
  ret
@@ -135,9 +76,9 @@ module Asciidoctor
135
76
  File.open(@filename + ".xml", "w:UTF-8") { |f| f.write(ret) }
136
77
  presentation_xml_converter(node)&.convert(@filename + ".xml")
137
78
  html_converter(node)&.convert(@filename + ".presentation.xml",
138
- nil, false, "#{@filename}.html")
79
+ nil, false, "#{@filename}.html")
139
80
  doc_converter(node)&.convert(@filename + ".presentation.xml",
140
- nil, false, "#{@filename}.doc")
81
+ nil, false, "#{@filename}.doc")
141
82
  pdf_converter(node)&.convert(@filename + ".presentation.xml",
142
83
  nil, false, "#{@filename}.pdf")
143
84
 
@@ -221,6 +162,18 @@ module Asciidoctor
221
162
  f.is_a? Hash and f[@lang] and return baselocation(f[@lang])
222
163
  super
223
164
  end
165
+
166
+ def cleanup(xmldoc)
167
+ super
168
+ empty_metadata_cleanup(xmldoc)
169
+ xmldoc
170
+ end
171
+
172
+ def empty_metadata_cleanup(xmldoc)
173
+ xmldoc.xpath("//bibdata/ext//*").each do |x|
174
+ x.remove if x.children.empty?
175
+ end
176
+ end
224
177
  end
225
178
  end
226
179
  end
@@ -0,0 +1,108 @@
1
+ module Asciidoctor
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
@@ -24,6 +24,14 @@
24
24
  <start>
25
25
  <ref name="standard-document"/>
26
26
  </start>
27
+ <define name="doctype">
28
+ <element name="doctype">
29
+ <optional>
30
+ <attribute name="abbreviation"/>
31
+ </optional>
32
+ <ref name="DocumentType"/>
33
+ </element>
34
+ </define>
27
35
  <define name="hyperlink">
28
36
  <element name="link">
29
37
  <attribute name="target">
@@ -42,12 +50,18 @@
42
50
  </define>
43
51
  <define name="xref">
44
52
  <element name="xref">
45
- <!-- attribute target { xsd:IDREF }, -->
46
53
  <attribute name="target">
47
54
  <data type="string">
48
55
  <param name="pattern">\i\c*|\c+#\c+</param>
49
56
  </data>
50
57
  </attribute>
58
+ <optional>
59
+ <attribute name="to">
60
+ <data type="string">
61
+ <param name="pattern">\i\c*|\c+#\c+</param>
62
+ </data>
63
+ </attribute>
64
+ </optional>
51
65
  <optional>
52
66
  <attribute name="type">
53
67
  <ref name="ReferenceFormat"/>
@@ -142,6 +156,11 @@
142
156
  <data type="boolean"/>
143
157
  </attribute>
144
158
  </optional>
159
+ <optional>
160
+ <attribute name="key">
161
+ <data type="boolean"/>
162
+ </attribute>
163
+ </optional>
145
164
  <oneOrMore>
146
165
  <ref name="dt"/>
147
166
  <ref name="dd"/>
@@ -234,6 +253,9 @@
234
253
  <data type="boolean"/>
235
254
  </attribute>
236
255
  </optional>
256
+ <optional>
257
+ <ref name="colgroup"/>
258
+ </optional>
237
259
  <optional>
238
260
  <ref name="tname"/>
239
261
  </optional>
@@ -752,6 +774,18 @@
752
774
  </define>
753
775
  </include>
754
776
  <!-- end overrides -->
777
+ <define name="colgroup">
778
+ <element name="colgroup">
779
+ <oneOrMore>
780
+ <ref name="col"/>
781
+ </oneOrMore>
782
+ </element>
783
+ </define>
784
+ <define name="col">
785
+ <element name="col">
786
+ <attribute name="width"/>
787
+ </element>
788
+ </define>
755
789
  <define name="TextElement" combine="choice">
756
790
  <ref name="concept"/>
757
791
  </define>
@@ -1165,49 +1199,7 @@
1165
1199
  </define>
1166
1200
  <define name="annex">
1167
1201
  <element name="annex">
1168
- <optional>
1169
- <attribute name="id">
1170
- <data type="ID"/>
1171
- </attribute>
1172
- </optional>
1173
- <optional>
1174
- <attribute name="language"/>
1175
- </optional>
1176
- <optional>
1177
- <attribute name="script"/>
1178
- </optional>
1179
- <optional>
1180
- <attribute name="inline-header">
1181
- <data type="boolean"/>
1182
- </attribute>
1183
- </optional>
1184
- <attribute name="obligation">
1185
- <choice>
1186
- <value>normative</value>
1187
- <value>informative</value>
1188
- </choice>
1189
- </attribute>
1190
- <optional>
1191
- <ref name="section-title"/>
1192
- </optional>
1193
- <group>
1194
- <group>
1195
- <zeroOrMore>
1196
- <ref name="BasicBlock"/>
1197
- </zeroOrMore>
1198
- <zeroOrMore>
1199
- <ref name="note"/>
1200
- </zeroOrMore>
1201
- </group>
1202
- <zeroOrMore>
1203
- <choice>
1204
- <ref name="annex-subsection"/>
1205
- <ref name="terms"/>
1206
- <ref name="definitions"/>
1207
- <ref name="references"/>
1208
- </choice>
1209
- </zeroOrMore>
1210
- </group>
1202
+ <ref name="Annex-Section"/>
1211
1203
  </element>
1212
1204
  </define>
1213
1205
  <define name="terms">
@@ -4,14 +4,6 @@ require "fileutils"
4
4
  module IsoDoc
5
5
  module Generic
6
6
  module BaseConvert
7
- =begin
8
- def baselocation(loc)
9
- return nil if loc.nil?
10
- File.expand_path(File.join(
11
- File.dirname(self.class::_file || __FILE__), "..", "..", "..", loc))
12
- end
13
- =end
14
-
15
7
  def cleanup(docxml)
16
8
  super
17
9
  term_cleanup(docxml)
@@ -32,8 +32,12 @@ module IsoDoc
32
32
  options[:script] == "Hans" ? '"SimHei",sans-serif' :
33
33
  configuration.html_headerfont || '"Overpass",sans-serif'
34
34
  ),
35
- monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
36
- }
35
+ monospacefont: configuration.html_monospacefont || '"Space Mono",monospace',
36
+ normalfontsize: configuration.html_normalfontsize,
37
+ smallerfontsize: configuration.html_smallerfontsize,
38
+ footnotefontsize: configuration.html_footnotefontsize,
39
+ monospacefontsize: configuration.html_monospacefontsize,
40
+ }.transform_values { |v| v&.empty? ? nil : v }
37
41
  end
38
42
 
39
43
  def default_file_locations(_options)
@@ -48,15 +52,9 @@ module IsoDoc
48
52
  html_doc_path("scripts.html"),
49
53
  i18nyaml: (configuration.i18nyaml.is_a?(String) ?
50
54
  baselocation(configuration.i18nyaml) : nil)
51
- }
55
+ }.transform_values { |v| v&.empty? ? nil : v }
52
56
  end
53
57
 
54
- =begin
55
- def configuration
56
- Metanorma::Generic.configuration
57
- end
58
- =end
59
-
60
58
  def googlefonts
61
59
  return unless configuration.webfont
62
60
  Array(configuration.webfont).map do |x|
@@ -1,7 +1,30 @@
1
1
  require "isodoc"
2
+ require "nokogiri"
2
3
  require_relative "init"
3
4
  require_relative "utils"
4
5
 
6
+ class Nokogiri::XML::Node
7
+ TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
8
+ def to_hash
9
+ ret = {kind:TYPENAMES[node_type],name:name}.tap do |h|
10
+ h.merge! text:text&.strip
11
+ a = attribute_nodes.map(&:to_hash)
12
+ if element? && !a.empty?
13
+ h.merge! attr: a.inject({}) { |m, v| m[v[:name]] = v[:text]; m }
14
+ end
15
+ c = children.map(&:to_hash)
16
+ if element? && !(c&.size == 1 && c[0][:kind] == "text")
17
+ h.merge! kids: c.delete_if { |n| n[:kind] == "text" && n[:text].empty? }
18
+ end
19
+ end
20
+ ret
21
+ end
22
+ end
23
+
24
+ class Nokogiri::XML::Document
25
+ def to_hash; root.to_hash; end
26
+ end
27
+
5
28
  module IsoDoc
6
29
  module Generic
7
30
 
@@ -24,20 +47,6 @@ module IsoDoc
24
47
  k._file = caller_locations.first.absolute_path
25
48
  end
26
49
 
27
- =begin
28
- def baselocation(loc)
29
- return nil if loc.nil?
30
- File.expand_path(File.join(File.dirname(
31
- self.class.respond_to?(:_file) ? (self.class::_file || __FILE__) :
32
- __FILE__),
33
- "..", "..", "..", loc))
34
- end
35
-
36
- def configuration
37
- Metanorma::Generic.configuration
38
- end
39
- =end
40
-
41
50
  def author(isoxml, _out)
42
51
  super
43
52
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
@@ -54,11 +63,36 @@ module IsoDoc
54
63
  !(Array(stages).map { |m| m.downcase }.include? status.downcase)
55
64
  end
56
65
 
57
- def ext(isoxml, out)
58
- Array(configuration.metadata_extensions).each do |e|
59
- b = isoxml&.at(ns("//bibdata/ext/#{e}"))&.text or next
60
- set(e.to_sym, b)
66
+ def doctype(isoxml, _out)
67
+ super
68
+ b = isoxml&.at(ns("//bibdata/ext/doctype#{currlang}")) ||
69
+ isoxml&.at(ns("//bibdata/ext/doctype#{NOLANG}")) || return
70
+ a = b["abbreviation"] and set(:doctype_abbr, a)
71
+ end
72
+
73
+ def xmlhash2hash(h)
74
+ ret = {}
75
+ return ret if h.nil? || h[:kind] != "element"
76
+ h[:attr].nil? or h[:attr].each { |k, v| ret["#{h[:name]}_#{k}"] = v }
77
+ ret[h[:name]] = h[:kids] ? xmlhash2hash_kids(h) : h[:text]
78
+ ret
79
+ end
80
+
81
+ def xmlhash2hash_kids(h)
82
+ c = {}
83
+ h[:kids].each do |n|
84
+ xmlhash2hash(n).each do |k1, v1|
85
+ c[k1] = c[k1].nil? ? v1 :
86
+ c[k1].is_a?(Array) ? c[k1] << v1 :
87
+ [c[k1], v1]
88
+ end
61
89
  end
90
+ c
91
+ end
92
+
93
+ def ext(isoxml, out)
94
+ b = isoxml&.at(ns("//bibdata/ext")) or return
95
+ set(:metadata_extensions, xmlhash2hash(b.to_hash)["ext"])
62
96
  end
63
97
 
64
98
  include Utils
@@ -27,7 +27,7 @@ module IsoDoc
27
27
  headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
28
28
  configuration.html_headerfont || '"Overpass",sans-serif'),
29
29
  monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
30
- }
30
+ }.transform_values { |v| v&.empty? ? nil : v }
31
31
  end
32
32
 
33
33
  def default_file_locations(_options)
@@ -40,7 +40,7 @@ module IsoDoc
40
40
  html_doc_path("html_generic_intro.html"),
41
41
  scripts_pdf: baselocation(configuration.scripts_pdf) ||
42
42
  html_doc_path("scripts.pdf.html")
43
- }
43
+ }.transform_values { |v| v&.empty? ? nil : v }
44
44
  end
45
45
 
46
46
  def googlefonts
@@ -9,8 +9,10 @@ module IsoDoc
9
9
  File.join(File.dirname(__FILE__), loc)
10
10
  end
11
11
 
12
- def baselocation(loc)
12
+ def baselocation(loc)
13
13
  return nil if loc.nil?
14
+ return "" if loc.empty?
15
+ return loc
14
16
  f = defined?(self.class::_file) ? (self.class::_file || __FILE__) :
15
17
  __FILE__
16
18
  File.expand_path(File.join(
@@ -31,8 +31,12 @@ module IsoDoc
31
31
  options[:script] == "Hans" ? '"SimHei",sans-serif' :
32
32
  configuration.word_headerfont || '"Arial",sans-serif'
33
33
  ),
34
- monospacefont: configuration.word_monospacefont || '"Courier New",monospace'
35
- }
34
+ monospacefont: configuration.word_monospacefont || '"Courier New",monospace',
35
+ normalfontsize: configuration.word_normalfontsize,
36
+ smallerfontsize: configuration.word_smallerfontsize,
37
+ footnotefontsize: configuration.word_footnotefontsize,
38
+ monospacefontsize: configuration.word_monospacefontsize,
39
+ }.transform_values { |v| v&.empty? ? nil : v }
36
40
  end
37
41
 
38
42
  def default_file_locations(options)
@@ -51,15 +55,9 @@ module IsoDoc
51
55
  baselocation(configuration.i18nyaml) : nil),
52
56
  ulstyle: "l3",
53
57
  olstyle: "l2",
54
- }
58
+ }.transform_values { |v| v&.empty? ? nil : v }
55
59
  end
56
60
 
57
- =begin
58
- def configuration
59
- Metanorma::Generic.configuration
60
- end
61
- =end
62
-
63
61
  include BaseConvert
64
62
  include Init
65
63
  end
@@ -31,6 +31,10 @@ module Metanorma
31
31
  html_bodyfont
32
32
  html_headerfont
33
33
  html_monospacefont
34
+ html_normalfontsize
35
+ html_monospacefontsize
36
+ html_smallerfontsize
37
+ html_footnotefontsize
34
38
  metadata_extensions
35
39
  metanorma_name
36
40
  normref_titles
@@ -51,9 +55,33 @@ module Metanorma
51
55
  word_bodyfont
52
56
  word_headerfont
53
57
  word_monospacefont
58
+ word_normalfontsize
59
+ word_monospacefontsize
60
+ word_smallerfontsize
61
+ word_footnotefontsize
54
62
  xml_root_tag
55
63
  ].freeze
56
64
 
65
+ def filepath_attrs
66
+ return %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
+ ]
83
+ end
84
+
57
85
  attr_accessor(*CONFIG_ATTRS)
58
86
 
59
87
  class << self
@@ -84,13 +112,47 @@ module Metanorma
84
112
  end
85
113
 
86
114
  def set_default_values_from_yaml_file(config_file)
115
+ root_path = File.dirname(self.class::_file || __FILE__)
87
116
  default_config_options = YAML.load(File.read(config_file))
117
+ if default_config_options["doctypes"]&.is_a? Array
118
+ default_config_options["doctypes"] = default_config_options["doctypes"].
119
+ each_with_object({}) { |k, m| m[k] = nil }
120
+ end
88
121
  CONFIG_ATTRS.each do |attr_name|
89
- instance_variable_set("@#{attr_name}", default_config_options[attr_name.to_s])
122
+ value = default_config_options[attr_name.to_s]
123
+ if value && filepath_attrs.include?(attr_name)
124
+ value = absolute_path(value, root_path)
125
+ end
126
+
127
+ instance_variable_set("@#{attr_name}", value)
128
+ end
129
+ end
130
+
131
+ def blank?(v)
132
+ v.nil? || v.respond_to?(:empty?) && v.empty?
133
+ end
134
+
135
+ def absolute_path(value, root_path)
136
+ if value.is_a? Hash then absolute_path1(value, root_path)
137
+ elsif value.is_a? Array
138
+ value.reject { |a| blank?(a) }.each_with_object([]) do |v1, g|
139
+ g << absolute_path(v1, root_path)
140
+ end
141
+ elsif value.is_a?(String) && !value.empty?
142
+ File.join(root_path, "..", "..", value)
143
+ else
144
+ value
145
+ end
146
+ end
147
+
148
+ def absolute_path1(h, pref)
149
+ h.reject { |k, v| blank?(v) }.each_with_object({}) do |(k, v), g|
150
+ g[k] = absolute_path(v, pref)
90
151
  end
91
152
  end
92
153
  end
93
154
 
155
+
94
156
  class << self
95
157
  extend Forwardable
96
158
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ Source Sans Pro:
3
+ Overpass:
4
+ Space Mono:
5
+ Arial:
@@ -2,21 +2,6 @@ require "metanorma/processor"
2
2
 
3
3
  module Metanorma
4
4
  module Generic
5
- def self.fonts_used
6
- {
7
- html: [
8
- configuration.html_bodyfont || "Overpass", configuration.html_headerfont || "Overpass",
9
- configuration.html_monospacefont || "Space Mono"
10
- ].uniq,
11
- doc: [
12
- configuration.word_bodyfont || "Overpass", configuration.word_headerfont || "Overpass",
13
- configuration.word_monospacefont || "Space Mono"].uniq,
14
- pdf: [
15
- configuration.word_bodyfont || "Overpass", configuration.word_headerfont || "Overpass",
16
- configuration.word_monospacefont || "Space Mono"].uniq,
17
- }
18
- end
19
-
20
5
  class Processor < Metanorma::Processor
21
6
  def configuration
22
7
  Metanorma::Generic.configuration
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.7.0"
3
+ VERSION = "1.8.1"
4
4
  end
5
5
  end
@@ -28,8 +28,8 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency "htmlentities", "~> 4.3.4"
30
30
  spec.add_dependency "ruby-jing"
31
- spec.add_dependency "metanorma-standoc", "~> 1.6.0"
32
- spec.add_dependency "isodoc", "~> 1.2.0"
31
+ spec.add_dependency "metanorma-standoc", "~> 1.7.0"
32
+ spec.add_dependency "isodoc", "~> 1.4.0"
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
35
35
  spec.add_development_dependency "sassc", "2.4.0"
@@ -14,6 +14,10 @@ htmlstylesheet: /metanorma-mine/lib/isodoc/mine/html/htmlstyle.scss
14
14
  html_bodyfont: '"Source Sans Pro",sans-serif'
15
15
  html_headerfont: '"Source Sans Pro",sans-serif'
16
16
  html_monospacefont: '"Source Code Pro",monospace'
17
+ html_normalfontsize: "1.0em"
18
+ html_monospacefontsize: "0.8em"
19
+ html_smallerfontsize: "0.9em"
20
+ html_footnotefontsize: "0.8em"
17
21
  scripts: /metanorma-mine/lib/isodoc/mine/html/scripts.html
18
22
  scripts_pdf: /metanorma-mine/lib/isodoc/mine/html/scripts.prd.html
19
23
  standardstylesheet: /metanorma-mine/lib/isodoc/mine/html/
@@ -24,6 +28,10 @@ wordstylesheet: /metanorma-mine/lib/isodoc/mine/html/wordstyle.scss
24
28
  word_bodyfont: '"Source Sans Pro","Arial",sans-serif'
25
29
  word_headerfont: '"Source Sans Pro","Arial",sans-serif'
26
30
  word_monospacefont: '"Source Code Pro",monospace'
31
+ word_normalfontsize: "12.0pt"
32
+ word_monospacefontsize: "11.0pt"
33
+ word_smallerfontsize: "10.0pt"
34
+ word_footnotefontsize: "9.0pt"
27
35
  docid_template: "{{ organization_name_short }} {{ docnumeric }}"
28
36
  metadata_extensions:
29
37
  - security
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.7.0
4
+ version: 1.8.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: 2020-09-26 00:00:00.000000000 Z
11
+ date: 2020-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.6.0
47
+ version: 1.7.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.6.0
54
+ version: 1.7.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isodoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.0
61
+ version: 1.4.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.0
68
+ version: 1.4.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: byebug
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -216,9 +216,7 @@ executables: []
216
216
  extensions: []
217
217
  extra_rdoc_files: []
218
218
  files:
219
- - ".github/workflows/macos.yml"
220
- - ".github/workflows/ubuntu.yml"
221
- - ".github/workflows/windows.yml"
219
+ - ".github/workflows/rake.yml"
222
220
  - ".gitignore"
223
221
  - ".hound.yml"
224
222
  - ".rubocop.ribose.yml"
@@ -236,6 +234,7 @@ files:
236
234
  - lib/asciidoctor/generic/basicdoc.rng
237
235
  - lib/asciidoctor/generic/biblio.rng
238
236
  - lib/asciidoctor/generic/converter.rb
237
+ - lib/asciidoctor/generic/front.rb
239
238
  - lib/asciidoctor/generic/generic.rng
240
239
  - lib/asciidoctor/generic/isodoc.rng
241
240
  - lib/asciidoctor/generic/reqt.rng
@@ -263,6 +262,7 @@ files:
263
262
  - lib/isodoc/generic/xref.rb
264
263
  - lib/metanorma-generic.rb
265
264
  - lib/metanorma/generic.rb
265
+ - lib/metanorma/generic/fonts_manifest.yaml
266
266
  - lib/metanorma/generic/processor.rb
267
267
  - lib/metanorma/generic/version.rb
268
268
  - metanorma-generic.gemspec
@@ -1,38 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: macos
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/ubuntu.yml
11
- - .github/workflows/windows.yml
12
-
13
- jobs:
14
- test-macos:
15
- name: Test on Ruby ${{ matrix.ruby }} macOS
16
- runs-on: macos-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- run: |
34
- sudo gem install bundler --force
35
- bundle install --jobs 4 --retry 3
36
- - name: Run specs
37
- run: |
38
- bundle exec rake
@@ -1,56 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: ubuntu
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- tags:
9
- - '*'
10
- pull_request:
11
- paths-ignore:
12
- - .github/workflows/macos.yml
13
- - .github/workflows/windows.yml
14
-
15
- jobs:
16
- test-linux:
17
- name: Test on Ruby ${{ matrix.ruby }} Ubuntu
18
- runs-on: ubuntu-latest
19
- continue-on-error: ${{ matrix.experimental }}
20
- strategy:
21
- fail-fast: false
22
- matrix:
23
- ruby: [ '2.6', '2.5', '2.4' ]
24
- experimental: [false]
25
- include:
26
- - ruby: '2.7'
27
- experimental: true
28
- steps:
29
- - uses: actions/checkout@master
30
- - name: Use Ruby
31
- uses: actions/setup-ruby@v1
32
- with:
33
- ruby-version: ${{ matrix.ruby }}
34
- - name: Update gems
35
- run: |
36
- gem install bundler
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake
41
- - name: Trigger repositories
42
- if: matrix.ruby == '2.6'
43
- env:
44
- GH_USERNAME: metanorma-ci
45
- GH_ACCESS_TOKEN: ${{ secrets.METANORMA_CI_PAT_TOKEN }}
46
- run: |
47
- curl -LO --retry 3 https://raw.githubusercontent.com/metanorma/metanorma-build-scripts/master/trigger-gh-actions.sh
48
- [[ -f ".github/workflows/dependent_repos.env" ]] && source .github/workflows/dependent_repos.env
49
- CLIENT_PAYLOAD=$(cat <<EOF
50
- "{ "ref": "${GITHUB_REF}", "repo": "${GITHUB_REPOSITORY}" }"
51
- EOF
52
- )
53
- for repo in $REPOS
54
- do
55
- sh trigger-gh-actions.sh $ORGANISATION $repo $GH_USERNAME $GH_ACCESS_TOKEN $GITHUB_REPOSITORY "$CLIENT_PAYLOAD"
56
- done
@@ -1,40 +0,0 @@
1
- # Auto-generated by Cimas: Do not edit it manually!
2
- # See https://github.com/metanorma/cimas
3
- name: windows
4
-
5
- on:
6
- push:
7
- branches: [ master ]
8
- pull_request:
9
- paths-ignore:
10
- - .github/workflows/macos.yml
11
- - .github/workflows/ubuntu.yml
12
-
13
- jobs:
14
- test-windows:
15
- name: Test on Ruby ${{ matrix.ruby }} Windows
16
- runs-on: windows-latest
17
- continue-on-error: ${{ matrix.experimental }}
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- ruby: [ '2.6', '2.5', '2.4' ]
22
- experimental: [false]
23
- include:
24
- - ruby: '2.7'
25
- experimental: true
26
- steps:
27
- - uses: actions/checkout@master
28
- - name: Use Ruby
29
- uses: actions/setup-ruby@v1
30
- with:
31
- ruby-version: ${{ matrix.ruby }}
32
- - name: Update gems
33
- shell: pwsh
34
- run: |
35
- gem install bundler
36
- bundle config --local path vendor/bundle
37
- bundle install --jobs 4 --retry 3
38
- - name: Run specs
39
- run: |
40
- bundle exec rake