metanorma-gb 1.4.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,4 @@
1
+ require_relative "init"
1
2
  require_relative "base_convert"
2
3
  require "isodoc"
3
4
 
@@ -27,6 +28,16 @@ module IsoDoc
27
28
  }
28
29
  end
29
30
 
31
+ def fonts_options
32
+ default_font_options = default_fonts(options)
33
+ {
34
+ bodyfont: options[:bodyfont] || default_font_options[:bodyfont],
35
+ headerfont: options[:headerfont] || default_font_options[:headerfont],
36
+ monospacefont: options[:monospacefont] || default_font_options[:monospacefont],
37
+ titlefont: options[:titlefont] || default_font_options[:titlefont]
38
+ }
39
+ end
40
+
30
41
  def default_file_locations(options)
31
42
  {
32
43
  htmlstylesheet: options[:compliant] ? html_doc_path("htmlcompliantstyle.scss") : html_doc_path("htmlstyle.scss"),
@@ -37,31 +48,23 @@ module IsoDoc
37
48
  end
38
49
 
39
50
  def populate_template(docxml, format)
40
- meta = @meta.get.merge(@labels)
51
+ meta = @meta.get.merge(@i18n.get).merge(@meta.fonts_options || {})
41
52
  logo = @common.format_logo(meta[:gbprefix], meta[:gbscope], format, @localdir)
42
53
  logofile = @meta.standard_logo(meta[:gbprefix])
43
54
  meta[:standard_agency_formatted] =
44
55
  @common.format_agency(meta[:standard_agency], format, @localdir)
45
56
  meta[:standard_logo] = logo
46
-
47
57
  template = Liquid::Template.parse(docxml)
48
58
  template.render(meta.map { |k, v| [k.to_s, v] }.to_h)
49
-
50
- #template = liquid(docxml)
51
- #template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h).
52
- #gsub('<', '<').gsub('>', '>').gsub('&', '&')
53
59
  end
54
60
 
55
- def annex_name(annex, name, div)
56
- div.h1 **{ class: "Annex" } do |t|
57
- t << "#{@xrefs.anchor(annex['id'], :label)}<br/><br/>"
58
- t.b do |b|
59
- name&.children&.each { |c2| parse(c2, b) }
60
- end
61
- end
61
+ def insert_tab(out, n)
62
+ tab = "&#x3000;"
63
+ [1..n].each { out << tab }
62
64
  end
63
65
 
64
66
  include BaseConvert
67
+ include Init
65
68
  end
66
69
  end
67
70
  end
@@ -0,0 +1,16 @@
1
+ module IsoDoc
2
+ module Gb
3
+ class I18n < IsoDoc::Iso::I18n
4
+ def load_yaml1(lang, script)
5
+ y = if lang == "en"
6
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-en.yaml"))
7
+ elsif lang == "zh" && script == "Hans"
8
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
9
+ else
10
+ YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
11
+ end
12
+ super.merge(y)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ require "isodoc"
2
+ require_relative "metadata"
3
+ require_relative "xref"
4
+ require_relative "i18n"
5
+
6
+ module IsoDoc
7
+ module Gb
8
+ module Init
9
+ def metadata_init(lang, script, labels)
10
+ unless ["en", "zh"].include? lang
11
+ lang = "zh"
12
+ script = "Hans"
13
+ end
14
+ @meta = Metadata.new(lang, script, labels)
15
+ @meta.set(:standardclassimg, @standardclassimg)
16
+ @common&.meta = @meta
17
+ end
18
+
19
+ def xref_init(lang, script, klass, labels, options)
20
+ @xrefs = Xref.new(lang, script, HtmlConvert.new(language: lang, script: script), labels, options)
21
+ end
22
+
23
+ def i18n_init(lang, script, i18nyaml = nil)
24
+ @i18n = I18n.new(lang, script, i18nyaml || @i18nyaml)
25
+ end
26
+ end
27
+ end
28
+ end
29
+
@@ -8,7 +8,7 @@ module IsoDoc
8
8
  # A {Converter} implementation that generates GB output, and a document
9
9
  # schema encapsulation of the document for validation
10
10
  class Metadata < IsoDoc::Iso::Metadata
11
- def initialize(lang, script, labels)
11
+ def initialize(lang, script, i18n)
12
12
  super
13
13
  set(:docmaintitlezh, "")
14
14
  set(:docsubtitlezh, "XXXX")
@@ -1,9 +1,25 @@
1
- require_relative "base_convert"
1
+ require_relative "init"
2
2
  require "isodoc"
3
3
 
4
4
  module IsoDoc
5
5
  module Gb
6
6
  class PresentationXMLConvert < IsoDoc::Iso::PresentationXMLConvert
7
+ def example1(f)
8
+ n = @xrefs.get[f["id"]]
9
+ lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example :
10
+ l10n("#{@i18n.example} #{n[:label]}")
11
+ prefix_name(f, "&nbsp;&mdash; ", l10n(lbl + ":"), "name")
12
+ end
13
+
14
+ def annex1(f)
15
+ lbl = @xrefs.anchor(f['id'], :label)
16
+ if t = f.at(ns("./title"))
17
+ t.children = "#{t.children.to_xml}"
18
+ end
19
+ prefix_name(f, "<br/><br/>", lbl, "title")
20
+ end
21
+
22
+ include Init
7
23
  end
8
24
  end
9
25
  end
@@ -1,4 +1,5 @@
1
1
  require_relative "base_convert"
2
+ require_relative "init"
2
3
  require "isodoc"
3
4
 
4
5
  module IsoDoc
@@ -24,11 +25,21 @@ module IsoDoc
24
25
  monospacefont: '"Courier New",monospace',
25
26
  titlefont: (scope == "national" ? (script != "Hans" ? '"Cambria",serif' : '"SimSun",serif' ) :
26
27
  (script == "Hans" ? '"SimHei",sans-serif' : '"Calibri",sans-serif' ))
27
- }
28
- end
28
+ }
29
+ end
30
+
31
+ def fonts_options
32
+ default_font_options = default_fonts(options)
33
+ {
34
+ bodyfont: options[:bodyfont] || default_font_options[:bodyfont],
35
+ headerfont: options[:headerfont] || default_font_options[:headerfont],
36
+ monospacefont: options[:monospacefont] || default_font_options[:monospacefont],
37
+ titlefont: options[:titlefont] || default_font_options[:titlefont]
38
+ }
39
+ end
29
40
 
30
41
  def default_file_locations(options)
31
- {
42
+ {
32
43
  wordstylesheet: html_doc_path("wordstyle.scss"),
33
44
  standardstylesheet: html_doc_path("gb.scss"),
34
45
  header: html_doc_path("header.html"),
@@ -37,10 +48,10 @@ module IsoDoc
37
48
  ulstyle: "l7",
38
49
  olstyle: "l10",
39
50
  }
40
- end
51
+ end
41
52
 
42
53
  ENDLINE = <<~END.freeze
43
- <v:line
54
+ <v:line
44
55
  alt="" style='position:absolute;left:0;text-align:left;z-index:251662848;
45
56
  mso-wrap-edited:f;mso-width-percent:0;mso-height-percent:0;
46
57
  mso-width-percent:0;mso-height-percent:0'
@@ -61,17 +72,17 @@ module IsoDoc
61
72
  out.table **attr_code(id: node["id"], class: "example") do |t|
62
73
  t.tr do |tr|
63
74
  tr.td **EXAMPLE_TBL_ATTR do |td|
64
- td << l10n(example_label(node) + ":")
75
+ node.at(ns("./name")).children.each { |n| parse(n, td) }
65
76
  end
66
77
  tr.td **{ valign: "top", class: "example" } do |td|
67
- node.children.each { |n| parse(n, td) }
78
+ node.children.each { |n| parse(n, td) unless n.name == "name" }
68
79
  end
69
80
  end
70
81
  end
71
82
  end
72
83
 
73
84
  def populate_template(docxml, format)
74
- meta = @meta.get.merge(@labels)
85
+ meta = @meta.get.merge(@i18n.get).merge(@meta.fonts_options || {})
75
86
  logo = @common.format_logo(meta[:gbprefix], meta[:gbscope], format, @localdir)
76
87
  logofile = @meta.standard_logo(meta[:gbprefix])
77
88
  meta[:standard_agency_formatted] =
@@ -82,13 +93,6 @@ module IsoDoc
82
93
  gsub('&lt;', '&#x3c;').gsub('&gt;', '&#x3e;').gsub('&amp;', '&#x26;')
83
94
  end
84
95
 
85
- def annex_name(annex, name, div)
86
- div.h1 **{ class: "Annex" } do |t|
87
- t << "#{@xrefs.anchor(annex['id'], :label)}<br/><br/>"
88
- name&.children&.each { |c2| parse(c2, t) }
89
- end
90
- end
91
-
92
96
  def make_body(xml, docxml)
93
97
  body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
94
98
  xml.body **body_attr do |body|
@@ -116,6 +120,7 @@ module IsoDoc
116
120
  end
117
121
 
118
122
  include BaseConvert
123
+ include Init
119
124
  end
120
125
  end
121
126
  end
@@ -0,0 +1,6 @@
1
+ module IsoDoc
2
+ module Gb
3
+ class Xref < IsoDoc::Xref
4
+ end
5
+ end
6
+ end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Gb
3
- VERSION = "1.4.1"
3
+ VERSION = "1.5.2"
4
4
  end
5
5
  end
@@ -29,13 +29,14 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
  spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
31
31
 
32
- spec.add_dependency "metanorma-iso", "~> 1.4.0"
33
- spec.add_dependency "isodoc", "~> 1.1.0"
32
+ spec.add_dependency "metanorma-iso", "~> 1.5.0"
33
+ spec.add_dependency "isodoc", "~> 1.2.0"
34
34
  spec.add_dependency "twitter_cldr", "~> 4.4.4"
35
35
  spec.add_dependency "gb-agencies", "~> 0.0.4"
36
36
  spec.add_dependency "htmlentities", "~> 4.3.4"
37
37
 
38
38
  spec.add_development_dependency "byebug", "~> 9.1"
39
+ spec.add_development_dependency "sassc", "2.4.0"
39
40
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
40
41
  spec.add_development_dependency "guard", "~> 2.14"
41
42
  spec.add_development_dependency "guard-rspec", "~> 4.7"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-gb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.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: 2020-07-10 00:00:00.000000000 Z
11
+ date: 2020-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.0
19
+ version: 1.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.0
26
+ version: 1.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: isodoc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.0
33
+ version: 1.2.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.1.0
40
+ version: 1.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: twitter_cldr
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '9.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sassc
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.4.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 2.4.0
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: equivalent-xml
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -253,6 +267,7 @@ files:
253
267
  - lib/asciidoctor/gb/basicdoc.rng
254
268
  - lib/asciidoctor/gb/biblio.rng
255
269
  - lib/asciidoctor/gb/boilerplate.xml
270
+ - lib/asciidoctor/gb/cleanup.rb
256
271
  - lib/asciidoctor/gb/converter.rb
257
272
  - lib/asciidoctor/gb/front.rb
258
273
  - lib/asciidoctor/gb/front_id.rb
@@ -266,6 +281,7 @@ files:
266
281
  - lib/isodoc/gb/cleanup.rb
267
282
  - lib/isodoc/gb/common.rb
268
283
  - lib/isodoc/gb/gb.recommendation.xsl
284
+ - lib/isodoc/gb/html/_coverpage.css
269
285
  - lib/isodoc/gb/html/_coverpage.scss
270
286
  - lib/isodoc/gb/html/blank.png
271
287
  - lib/isodoc/gb/html/footer.png
@@ -290,25 +306,32 @@ files:
290
306
  - lib/isodoc/gb/html/gb-logos/gb-standard-zb.gif
291
307
  - lib/isodoc/gb/html/gb-logos/gb-standard-zb.png
292
308
  - lib/isodoc/gb/html/gb-logos/gb-standard-zb.svg
309
+ - lib/isodoc/gb/html/gb.css
293
310
  - lib/isodoc/gb/html/gb.scss
294
311
  - lib/isodoc/gb/html/header.html
295
312
  - lib/isodoc/gb/html/html_compliant_gb_titlepage.html
296
313
  - lib/isodoc/gb/html/html_gb_intro.html
297
314
  - lib/isodoc/gb/html/html_gb_titlepage.html
315
+ - lib/isodoc/gb/html/htmlcompliantstyle.css
298
316
  - lib/isodoc/gb/html/htmlcompliantstyle.scss
317
+ - lib/isodoc/gb/html/htmlstyle.css
299
318
  - lib/isodoc/gb/html/htmlstyle.scss
300
319
  - lib/isodoc/gb/html/logo.png
301
320
  - lib/isodoc/gb/html/scripts.html
302
321
  - lib/isodoc/gb/html/word_gb_intro.html
303
322
  - lib/isodoc/gb/html/word_gb_titlepage.html
323
+ - lib/isodoc/gb/html/wordstyle.css
304
324
  - lib/isodoc/gb/html/wordstyle.scss
305
325
  - lib/isodoc/gb/html_convert.rb
306
326
  - lib/isodoc/gb/i18n-en.yaml
307
327
  - lib/isodoc/gb/i18n-zh-Hans.yaml
328
+ - lib/isodoc/gb/i18n.rb
329
+ - lib/isodoc/gb/init.rb
308
330
  - lib/isodoc/gb/metadata.rb
309
331
  - lib/isodoc/gb/pdf_convert.rb
310
332
  - lib/isodoc/gb/presentation_xml_convert.rb
311
333
  - lib/isodoc/gb/word_convert.rb
334
+ - lib/isodoc/gb/xref.rb
312
335
  - lib/metanorma-gb.rb
313
336
  - lib/metanorma/gb.rb
314
337
  - lib/metanorma/gb/processor.rb