metanorma-generic 1.6.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,12 +4,6 @@ require "fileutils"
4
4
  module IsoDoc
5
5
  module Generic
6
6
  module BaseConvert
7
- def baselocation(loc)
8
- return nil if loc.nil?
9
- File.expand_path(File.join(
10
- File.dirname(self.class::_file || __FILE__), "..", "..", "..", loc))
11
- end
12
-
13
7
  def cleanup(docxml)
14
8
  super
15
9
  term_cleanup(docxml)
@@ -636,7 +636,7 @@ div.WordSection2
636
636
 
637
637
  div.WordSection3
638
638
  {page:WordSection3;}
639
- table.MsoISOTable
639
+ table.MsoISOTable, table.MsoISOTableBig
640
640
  {mso-style-name:"Table ISO";
641
641
  mso-tstyle-rowband-size:0;
642
642
  mso-tstyle-colband-size:0;
@@ -656,15 +656,15 @@ table.MsoISOTable
656
656
  mso-border-insidev:.75pt solid windowtext;
657
657
  font-size:10.0pt;
658
658
  font-family:$bodyfont;}
659
- table.MsoISOTable th
659
+ table.MsoISOTable th, table.MsoISOTableBig th
660
660
  {border:solid windowtext 1pt;
661
661
  mso-border-alt:solid windowtext 1pt;
662
662
  padding:0cm 2.85pt 0cm 2.85pt;}
663
- table.MsoISOTable td
663
+ table.MsoISOTable td, table.MsoISOTableBig td
664
664
  {border:solid windowtext 1pt;
665
665
  mso-border-alt:solid windowtext 1pt;
666
666
  padding:0cm 2.85pt 0cm 2.85pt;}
667
- table.MsoISOTable p
667
+ table.MsoISOTable p, table.MsoISOTableBig p
668
668
  {font-size:10.0pt; }
669
669
  table.MsoTableGrid
670
670
  {mso-style-name:"Table Grid";
@@ -750,6 +750,20 @@ div.example p.MsoListParagraph {
750
750
 
751
751
  div.Note p.MsoListParagraph {
752
752
  font-size: 10.0pt;
753
+ margin-left: 1.0cm;
754
+ }
755
+
756
+ div.Note span.stem {
757
+ font-size: 10.0pt; }
758
+
759
+ div.Note p.Sourcecode, div.Note pre.Sourcecode {
760
+ font-size: 8.0pt;
761
+ margin-left: 1.0cm;
762
+ }
763
+
764
+ div.Note table.dl {
765
+ font-size: 10.0pt;
766
+ margin-left: 1.0cm;
753
767
  }
754
768
 
755
769
  span.note_label, span.example_label, td.example_label, td.note_label
@@ -24,31 +24,38 @@ module IsoDoc
24
24
 
25
25
  def default_fonts(options)
26
26
  {
27
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif'
28
- : configuration.html_bodyfont || '"Overpass",sans-serif'),
29
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
30
- configuration.html_headerfont || '"Overpass",sans-serif'),
27
+ bodyfont: (
28
+ options[:script] == "Hans" ? '"SimSun",serif' :
29
+ configuration.html_bodyfont || '"Overpass",sans-serif'
30
+ ),
31
+ headerfont: (
32
+ options[:script] == "Hans" ? '"SimHei",sans-serif' :
33
+ configuration.html_headerfont || '"Overpass",sans-serif'
34
+ ),
31
35
  monospacefont: configuration.html_monospacefont || '"Space Mono",monospace'
32
- }
36
+ }.transform_values { |v| v&.empty? ? nil : v }
33
37
  end
34
38
 
35
39
  def default_file_locations(_options)
36
40
  {
37
41
  htmlstylesheet: baselocation(configuration.htmlstylesheet) ||
38
- html_doc_path("htmlstyle.scss"),
42
+ html_doc_path("htmlstyle.scss"),
39
43
  htmlcoverpage: baselocation(configuration.htmlcoverpage) ||
40
- html_doc_path("html_generic_titlepage.html"),
44
+ html_doc_path("html_generic_titlepage.html"),
41
45
  htmlintropage: baselocation(configuration.htmlintropage) ||
42
- html_doc_path("html_generic_intro.html"),
46
+ html_doc_path("html_generic_intro.html"),
43
47
  scripts: baselocation(configuration.scripts) ||
44
- html_doc_path("scripts.html"),
45
- i18nyaml: baselocation(configuration.i18nyaml)
46
- }
48
+ html_doc_path("scripts.html"),
49
+ i18nyaml: (configuration.i18nyaml.is_a?(String) ?
50
+ baselocation(configuration.i18nyaml) : nil)
51
+ }.transform_values { |v| v&.empty? ? nil : v }
47
52
  end
48
53
 
54
+ =begin
49
55
  def configuration
50
56
  Metanorma::Generic.configuration
51
57
  end
58
+ =end
52
59
 
53
60
  def googlefonts
54
61
  return unless configuration.webfont
@@ -0,0 +1,26 @@
1
+ require_relative "utils"
2
+
3
+ module IsoDoc
4
+ module Generic
5
+ class I18n < IsoDoc::I18n
6
+ class << self
7
+ attr_accessor :_file
8
+ end
9
+
10
+ def self.inherited( k )
11
+ k._file = caller_locations.first.absolute_path
12
+ end
13
+
14
+ def load_yaml1(lang, script)
15
+ return super unless configuration.i18nyaml
16
+ file = configuration.i18nyaml.is_a?(Hash) ?
17
+ configuration.i18nyaml[lang] : configuration.i18nyaml
18
+ return super if file.nil?
19
+ y = YAML.load_file(baselocation(file))
20
+ super.merge(y)
21
+ end
22
+
23
+ include Utils
24
+ end
25
+ end
26
+ end
@@ -1,6 +1,8 @@
1
1
  require "isodoc"
2
2
  require_relative "metadata"
3
3
  require_relative "xref"
4
+ require_relative "i18n"
5
+ require_relative "utils"
4
6
 
5
7
  module IsoDoc
6
8
  module Generic
@@ -15,12 +17,13 @@ module IsoDoc
15
17
  end
16
18
 
17
19
  def i18n_init(lang, script, i18nyaml = nil)
18
- @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
20
+ f = Metanorma::Generic.configuration.i18nyaml
21
+ f = nil unless f.is_a? String
22
+ @i18n = I18n.new(
23
+ lang, script, i18nyaml || f || @i18nyaml)
19
24
  end
20
25
 
21
- def fileloc(loc)
22
- File.join(File.dirname(__FILE__), loc)
23
- end
26
+ include Utils
24
27
  end
25
28
  end
26
29
  end
@@ -1,4 +1,29 @@
1
1
  require "isodoc"
2
+ require "nokogiri"
3
+ require_relative "init"
4
+ require_relative "utils"
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
2
27
 
3
28
  module IsoDoc
4
29
  module Generic
@@ -22,16 +47,6 @@ module IsoDoc
22
47
  k._file = caller_locations.first.absolute_path
23
48
  end
24
49
 
25
- def baselocation(loc)
26
- return nil if loc.nil?
27
- File.expand_path(File.join(
28
- File.dirname(self.class::_file || __FILE__), "..", "..", "..", loc))
29
- end
30
-
31
- def configuration
32
- Metanorma::Generic.configuration
33
- end
34
-
35
50
  def author(isoxml, _out)
36
51
  super
37
52
  tc = isoxml.at(ns("//bibdata/ext/editorialgroup/committee"))
@@ -48,12 +63,39 @@ module IsoDoc
48
63
  !(Array(stages).map { |m| m.downcase }.include? status.downcase)
49
64
  end
50
65
 
51
- def ext(isoxml, out)
52
- Array(configuration.metadata_extensions).each do |e|
53
- b = isoxml&.at(ns("//bibdata/ext/#{e}"))&.text or next
54
- 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
55
89
  end
90
+ c
56
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"])
96
+ end
97
+
98
+ include Utils
57
99
  end
58
100
  end
59
101
  end
@@ -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
@@ -1,4 +1,5 @@
1
1
  require_relative "init"
2
+ require_relative "metadata"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
@@ -0,0 +1,22 @@
1
+ module IsoDoc
2
+ module Generic
3
+ module Utils
4
+ def configuration
5
+ Metanorma::Generic.configuration
6
+ end
7
+
8
+ def fileloc(loc)
9
+ File.join(File.dirname(__FILE__), loc)
10
+ end
11
+
12
+ def baselocation(loc)
13
+ return nil if loc.nil?
14
+ return "" if loc.empty?
15
+ f = defined?(self.class::_file) ? (self.class::_file || __FILE__) :
16
+ __FILE__
17
+ File.expand_path(File.join(
18
+ File.dirname(f), "..", "..", "..", loc))
19
+ end
20
+ end
21
+ end
22
+ end
@@ -23,34 +23,35 @@ module IsoDoc
23
23
 
24
24
  def default_fonts(options)
25
25
  {
26
- bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' :
27
- configuration.word_bodyfont || '"Arial",sans-serif'),
28
- headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' :
29
- configuration.word_headerfont || '"Arial",sans-serif'),
26
+ bodyfont: (
27
+ options[:script] == "Hans" ? '"SimSun",serif' :
28
+ configuration.word_bodyfont || '"Arial",sans-serif'
29
+ ),
30
+ headerfont: (
31
+ options[:script] == "Hans" ? '"SimHei",sans-serif' :
32
+ configuration.word_headerfont || '"Arial",sans-serif'
33
+ ),
30
34
  monospacefont: configuration.word_monospacefont || '"Courier New",monospace'
31
- }
35
+ }.transform_values { |v| v&.empty? ? nil : v }
32
36
  end
33
37
 
34
38
  def default_file_locations(options)
35
39
  {
36
40
  wordstylesheet: baselocation(configuration.wordstylesheet) ||
37
- html_doc_path("wordstyle.scss"),
41
+ html_doc_path("wordstyle.scss"),
38
42
  standardstylesheet: baselocation(configuration.standardstylesheet) ||
39
- html_doc_path("generic.scss"),
43
+ html_doc_path("generic.scss"),
40
44
  header: baselocation(configuration.header) ||
41
- html_doc_path("header.html"),
45
+ html_doc_path("header.html"),
42
46
  wordcoverpage: baselocation(configuration.wordcoverpage) ||
43
- html_doc_path("word_generic_titlepage.html"),
47
+ html_doc_path("word_generic_titlepage.html"),
44
48
  wordintropage: baselocation(configuration.wordintropage) ||
45
- html_doc_path("word_generic_intro.html"),
46
- i18nyaml: baselocation(configuration.i18nyaml),
47
- ulstyle: "l3",
48
- olstyle: "l2",
49
- }
50
- end
51
-
52
- def configuration
53
- Metanorma::Generic.configuration
49
+ html_doc_path("word_generic_intro.html"),
50
+ i18nyaml: (configuration.i18nyaml.is_a?(String) ?
51
+ baselocation(configuration.i18nyaml) : nil),
52
+ ulstyle: "l3",
53
+ olstyle: "l2",
54
+ }.transform_values { |v| v&.empty? ? nil : v }
54
55
  end
55
56
 
56
57
  include BaseConvert
@@ -15,6 +15,8 @@ module Metanorma
15
15
  organization_name_short
16
16
  organization_name_long
17
17
  bibliography_titles
18
+ boilerplate
19
+ committees
18
20
  document_namespace
19
21
  docid_template
20
22
  doctypes
@@ -33,6 +35,7 @@ module Metanorma
33
35
  metanorma_name
34
36
  normref_titles
35
37
  published_stages
38
+ relations
36
39
  default_stage
37
40
  stage_abbreviations
38
41
  scripts
@@ -82,6 +85,10 @@ module Metanorma
82
85
 
83
86
  def set_default_values_from_yaml_file(config_file)
84
87
  default_config_options = YAML.load(File.read(config_file))
88
+ if default_config_options["doctypes"]&.is_a? Array
89
+ default_config_options["doctypes"] = default_config_options["doctypes"].
90
+ each_with_object({}) { |k, m| m[k] = nil }
91
+ end
85
92
  CONFIG_ATTRS.each do |attr_name|
86
93
  instance_variable_set("@#{attr_name}", default_config_options[attr_name.to_s])
87
94
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Generic
3
- VERSION = "1.6.2"
3
+ VERSION = "1.7.3"
4
4
  end
5
5
  end
@@ -28,7 +28,7 @@ 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.5.0"
31
+ spec.add_dependency "metanorma-standoc", "~> 1.6.0"
32
32
  spec.add_dependency "isodoc", "~> 1.2.0"
33
33
 
34
34
  spec.add_development_dependency "byebug", "~> 9.1"
@@ -29,6 +29,11 @@ metadata_extensions:
29
29
  - security
30
30
  published_stages:
31
31
  - published
32
+ committees:
33
+ - TC 1
34
+ relations:
35
+ - part-of
36
+ - translated-from
32
37
  stage_abbreviations:
33
38
  draft-proposal:
34
39
  draft-development:
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.6.2
4
+ version: 1.7.3
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-08-27 00:00:00.000000000 Z
11
+ date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.5.0
47
+ version: 1.6.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.5.0
54
+ version: 1.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: isodoc
57
57
  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
@@ -253,10 +252,12 @@ files:
253
252
  - lib/isodoc/generic/html/word_generic_titlepage.html
254
253
  - lib/isodoc/generic/html/wordstyle.scss
255
254
  - lib/isodoc/generic/html_convert.rb
255
+ - lib/isodoc/generic/i18n.rb
256
256
  - lib/isodoc/generic/init.rb
257
257
  - lib/isodoc/generic/metadata.rb
258
258
  - lib/isodoc/generic/pdf_convert.rb
259
259
  - lib/isodoc/generic/presentation_xml_convert.rb
260
+ - lib/isodoc/generic/utils.rb
260
261
  - lib/isodoc/generic/word_convert.rb
261
262
  - lib/isodoc/generic/xref.rb
262
263
  - lib/metanorma-generic.rb