metanorma-gb 1.3.25 → 1.3.26

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,8 @@ module IsoDoc
12
12
  h = options[:headerfont] || "Arial"
13
13
  m = options[:monospacefont] || "Courier"
14
14
  t = options[:titlefont] || "Arial"
15
- "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n$titlefont: #{t};\n"
15
+ "$bodyfont: #{b};\n$headerfont: #{h};\n$monospacefont: #{m};\n"\
16
+ "$titlefont: #{t};\n"
16
17
  end
17
18
 
18
19
  def metadata_init(lang, script, labels)
@@ -45,7 +46,8 @@ module IsoDoc
45
46
  YAML.load_file(File.join(File.dirname(__FILE__),
46
47
  "i18n-zh-Hans.yaml"))
47
48
  else
48
- YAML.load_file(File.join(File.dirname(__FILE__), "i18n-zh-Hans.yaml"))
49
+ YAML.load_file(File.join(File.dirname(__FILE__),
50
+ "i18n-zh-Hans.yaml"))
49
51
  end
50
52
  @labels = @labels.merge(y)
51
53
  end
@@ -100,12 +102,16 @@ module IsoDoc
100
102
  end
101
103
 
102
104
  def note_parse(node, out)
105
+ note_parse1(node, out, note_label(node) + ":")
106
+ end
107
+
108
+ def note_parse1(node, out, label)
103
109
  @note = true
104
110
  out.table **attr_code(id: node["id"], class: "Note") do |t|
105
111
  t.tr do |tr|
106
112
  @libdir = File.dirname(__FILE__)
107
113
  tr.td **EXAMPLE_TBL_ATTR do |td|
108
- td << l10n(note_label(node) + ":")
114
+ td << l10n(label)
109
115
  end
110
116
  tr.td **{ style: "vertical-align:top;", class: "Note" } do |td|
111
117
  node.children.each { |n| parse(n, td) }
@@ -116,18 +122,7 @@ module IsoDoc
116
122
  end
117
123
 
118
124
  def termnote_parse(node, out)
119
- @note = true
120
- out.table **attr_code(id: node["id"], class: "Note") do |t|
121
- t.tr do |tr|
122
- tr.td **EXAMPLE_TBL_ATTR do |td|
123
- td << l10n("#{anchor(node['id'], :label)}:")
124
- end
125
- tr.td **{ style: "vertical-align:top;", class: "Note" } do |td|
126
- node.children.each { |n| parse(n, td) }
127
- end
128
- end
129
- end
130
- @note = false
125
+ note_parse1(node, out, "#{anchor(node['id'], :label)}:")
131
126
  end
132
127
 
133
128
  def middle(isoxml, out)
@@ -168,15 +163,17 @@ module IsoDoc
168
163
  def termref_render(x)
169
164
  x.sub!(%r{\s*\[MODIFICATION\]\s*$}m, l10n(", #{@modified_lbl}"))
170
165
  parts = x.split(%r{(\s*\[MODIFICATION\]|,)}m)
171
- parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 && parts[1] == "," &&
172
- !/^\s*#{@modified_lbl}/.match(parts[2])
166
+ parts[1] = l10n(", #{@source_lbl}") if parts.size > 1 &&
167
+ parts[1] == "," && !/^\s*#{@modified_lbl}/.match(parts[2])
173
168
  parts.map do |p|
174
- /\s*\[MODIFICATION\]/.match(p) ? l10n(", #{@modified_lbl} &mdash; ") : p
169
+ /\s*\[MODIFICATION\]/.match(p) ?
170
+ l10n(", #{@modified_lbl} &mdash; ") : p
175
171
  end.join.sub(/\A\s*/m, l10n("[")).sub(/\s*\z/m, l10n("]"))
176
172
  end
177
173
 
178
174
  def termref_resolve(docxml)
179
- docxml.split(%r{(\[TERMREF\]|\[/TERMREF\])}).each_slice(4).
175
+ docxml.gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, l10n("; ")).
176
+ split(%r{(\[TERMREF\]|\[/TERMREF\])}).each_slice(4).
180
177
  map do |a|
181
178
  a.size < 3 ? a[0] : a[0] + termref_render(a[2])
182
179
  end.join
@@ -251,11 +248,8 @@ module IsoDoc
251
248
 
252
249
  def example_parse(node, out)
253
250
  out.div **{ id: node["id"], class: "example" } do |div|
254
- if node_begins_with_para(node)
255
- example_p_parse(node, div)
256
- else
257
- example_parse1(node, div)
258
- end
251
+ node_begins_with_para(node) ?
252
+ example_p_parse(node, div) : example_parse1(node, div)
259
253
  end
260
254
  end
261
255
 
@@ -0,0 +1,30 @@
1
+ require "isodoc"
2
+
3
+ module IsoDoc
4
+ module Gb
5
+
6
+ # A {Converter} implementation that generates HTML output, and a document
7
+ # schema encapsulation of the document for validation
8
+ #
9
+ class PdfConvert < IsoDoc::XslfoPdfConvert
10
+ def initialize(options)
11
+ @libdir = File.dirname(__FILE__)
12
+ super
13
+ end
14
+
15
+ def convert(filename, file = nil, debug = false)
16
+ file = File.read(filename, encoding: "utf-8") if file.nil?
17
+ docxml, outname_html, dir = convert_init(file, filename, debug)
18
+ /\.xml$/.match(filename) or
19
+ filename = Tempfile.open([outname_html, ".xml"], encoding: "utf-8") do |f|
20
+ f.write file
21
+ f.path
22
+ end
23
+ FileUtils.rm_rf dir
24
+ ::Metanorma::Output::XslfoPdf.new.convert(
25
+ filename, outname_html + ".pdf", File.join(@libdir, "gb.recommendation.xsl"))
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -4,6 +4,7 @@ require_relative "metanorma/gb/version"
4
4
  require "isodoc/gb/gbconvert"
5
5
  require "isodoc/gb/gbhtmlconvert"
6
6
  require "isodoc/gb/gbwordconvert"
7
+ require "isodoc/gb/pdf_convert"
7
8
 
8
9
  if defined? Metanorma
9
10
  require_relative "metanorma/gb"
@@ -7,6 +7,7 @@ module Metanorma
7
7
  compliant_html: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
8
8
  html: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
9
9
  doc: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
10
+ pdf: ["SimSun", "Cambria", "SimHei", "Calibri", "Courier New"],
10
11
  }
11
12
  end
12
13
 
@@ -22,7 +23,8 @@ module Metanorma
22
23
  super.merge(
23
24
  html: "html",
24
25
  compliant_html: "compliant.html",
25
- doc: "doc"
26
+ doc: "doc",
27
+ pdf: "pdf",
26
28
  )
27
29
  end
28
30
 
@@ -57,6 +59,8 @@ module Metanorma
57
59
  IsoDoc::Gb::HtmlConvert.new(options.merge(compliant: true)).convert(outname, isodoc_node)
58
60
  when :doc
59
61
  IsoDoc::Gb::WordConvert.new(options).convert(outname, isodoc_node)
62
+ when :doc
63
+ IsoDoc::Gb::PdfConvert.new(options).convert(outname, isodoc_node)
60
64
  else
61
65
  super
62
66
  end
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Gb
3
- VERSION = "1.3.25"
3
+ VERSION = "1.3.26"
4
4
  end
5
5
  end
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.3.25
4
+ version: 1.3.26
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-05-29 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: metanorma-iso
@@ -255,12 +255,14 @@ files:
255
255
  - lib/asciidoctor/gb/boilerplate.xml
256
256
  - lib/asciidoctor/gb/converter.rb
257
257
  - lib/asciidoctor/gb/front.rb
258
+ - lib/asciidoctor/gb/front_id.rb
258
259
  - lib/asciidoctor/gb/gbstandard.rng
259
260
  - lib/asciidoctor/gb/isodoc.rng
260
261
  - lib/asciidoctor/gb/isostandard.rng
261
262
  - lib/asciidoctor/gb/reqt.rng
262
263
  - lib/asciidoctor/gb/section_input.rb
263
264
  - lib/asciidoctor/gb/validate.rb
265
+ - lib/isodoc/gb/gb.recommendation.xsl
264
266
  - lib/isodoc/gb/gbbaseconvert.rb
265
267
  - lib/isodoc/gb/gbcleanup.rb
266
268
  - lib/isodoc/gb/gbconvert.rb
@@ -305,6 +307,7 @@ files:
305
307
  - lib/isodoc/gb/i18n-en.yaml
306
308
  - lib/isodoc/gb/i18n-zh-Hans.yaml
307
309
  - lib/isodoc/gb/metadata.rb
310
+ - lib/isodoc/gb/pdf_convert.rb
308
311
  - lib/metanorma-gb.rb
309
312
  - lib/metanorma/gb.rb
310
313
  - lib/metanorma/gb/processor.rb