webgen 1.5.1 → 1.5.2

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: d6fbb6e93b9b2cbae04fb5c395d3c51684742e33a7ae84902a9bb0c8a37067b6
4
- data.tar.gz: b7631a0e10684ba0d7898ee5ec3cb7a3dbd15f7b47116b220917efb19372a066
3
+ metadata.gz: 82b8cbcc822f838af50c33be08022cdb694bbf72e4b0a8b16119bc1170169ead
4
+ data.tar.gz: c35bc89fec452d38cc7294f3544662fbaa18e0364320242ed57a92b5151467d5
5
5
  SHA512:
6
- metadata.gz: 24818e0987424cbf2aa8ddd3cca0c74428bcd82d10b56837c879750d4bcb08e9bc45486970fe5b8aa442c3249ca9c2a62f9428626d55ea0c78deb3f86784bf0a
7
- data.tar.gz: 169fea7fc799e2575b99cd3b9c2b8f1080cb7546f7cf28c784b0663994b1640ad4d1c1d2788ae925525bcdffc43df56cdc7faa00327117111a53b13665fb6ee9
6
+ metadata.gz: 3b11a5924bf44d4cec50cf6b658527644a661f4ea8a35cf2adbf25025325467acbe568b3533489455f9b132799532be8594d906e81cfd0ff2e0ce17ba62832b6
7
+ data.tar.gz: 3933fbbf9f71811d3e658ebe04dce9f583a3a6cca01139ba209476e38761fd30380d8741e960311e571f27467c086310a2f3dfbccb309d094570fef5d44aa472
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.1
1
+ 1.5.2
@@ -1,7 +1,6 @@
1
1
  --- name:content pipeline:erb
2
2
  \nonstopmode
3
- \documentclass{standalone}
4
- \usepackage{tikz}
3
+ \documentclass[tikz]{standalone}
5
4
 
6
5
  <% if context['content_processor.tikz.libraries'] %>
7
6
  \usetikzlibrary{<%= context['content_processor.tikz.libraries'].join(',') %>}
@@ -404,6 +404,20 @@ options:
404
404
  \tikz \draw (0,0) -- (0,2) -- (2,2);
405
405
  {tikz}
406
406
 
407
+ content_processor.tikz.engine:
408
+ summary: |
409
+ Specifies which LaTeX engine should be used. Default is pdflatex, but you may want to use
410
+ xelatex or lualatex if needed.
411
+ syntax: |
412
+ `pdflatex` or `lualatex` or `xelatex`
413
+ example:
414
+ config: |
415
+ content_processor.tikz.engine: lualatex
416
+ tag: |
417
+ {tikz:: {path: tikz.png, content_processor.tikz.engine: xelatex}}
418
+ \tikz \draw (0,0) -- (0,2) -- (2,2);
419
+ {tikz}
420
+
407
421
  content_processor.xmllint.options:
408
422
  summary: |
409
423
  Options passed to the `xmllint` command.
@@ -112,6 +112,7 @@ option('content_processor.tikz.resolution', '72 72',) do |val|
112
112
  end
113
113
  option('content_processor.tikz.transparent', false, &true_or_false)
114
114
  option('content_processor.tikz.template', '/templates/tikz.template', &is_string)
115
+ option('content_processor.tikz.engine', 'pdflatex', &is_string)
115
116
 
116
117
  content_processor.register('Xmllint')
117
118
  option('content_processor.xmllint.options', "--catalogs --noout --valid", &is_string)
@@ -7,7 +7,6 @@ require 'webgen/content_processor'
7
7
  require 'webgen/utils/external_command'
8
8
 
9
9
  Webgen::Utils::ExternalCommand.ensure_available!('pdflatex', '-v')
10
- Webgen::Utils::ExternalCommand.ensure_available!('pdfcrop', '--version')
11
10
  Webgen::Utils::ExternalCommand.ensure_available!('gs', '-v')
12
11
  Webgen::Utils::ExternalCommand.ensure_available!('convert', '-version')
13
12
  Webgen::Utils::ExternalCommand.ensure_available!('identify', '-version')
@@ -31,7 +30,7 @@ module Webgen
31
30
  def self.prepare_options(context)
32
31
  %w[content_processor.tikz.resolution content_processor.tikz.transparent
33
32
  content_processor.tikz.libraries content_processor.tikz.opts
34
- content_processor.tikz.template].each do |opt|
33
+ content_processor.tikz.template content_processor.tikz.engine].each do |opt|
35
34
  context[opt] = context.content_node[opt] || context.website.config[opt]
36
35
  end
37
36
  context['data'] = context.content
@@ -66,29 +65,35 @@ module Webgen
66
65
  def self.compile(context, cwd, tex_file, basename, ext)
67
66
  render_res, output_res = context['content_processor.tikz.resolution'].split(' ')
68
67
 
68
+ engine = context['content_processor.tikz.engine']
69
69
  File.write(tex_file, context.content)
70
- execute("pdflatex -shell-escape -interaction=nonstopmode -halt-on-error #{basename}.tex", cwd, context) do |_status, stdout, stderr|
70
+ execute("#{engine} -shell-escape -interaction=nonstopmode -halt-on-error #{basename}.tex", cwd, context) do |_status, stdout, stderr|
71
71
  errors = (stdout+stderr).scan(/^!(.*\n.*)/).join("\n")
72
- raise Webgen::RenderError.new("Error while parsing TikZ picture commands with PDFLaTeX: #{errors}",
72
+ raise Webgen::RenderError.new("Error while parsing TikZ picture commands with #{engine}: #{errors}",
73
73
  'content_processor.tikz', context.dest_node, context.ref_node)
74
74
  end
75
75
 
76
- execute("pdfcrop #{basename}.pdf #{basename}.pdf", cwd, context)
77
-
78
76
  if context['content_processor.tikz.transparent'] && ext =~ /\.png/i
79
77
  cmd = "gs -dSAFER -dBATCH -dNOPAUSE -r#{render_res} -sDEVICE=pngalpha -dGraphicsAlphaBits=4 " +
80
78
  "-dTextAlphaBits=4 -sOutputFile=#{basename}#{ext} #{basename}.pdf"
79
+ elsif ext =~ /\.svg/i
80
+ # some installations of ghostscript (`gs`) also have a svg output device, but pdf2svg
81
+ # is a safer bet.
82
+ cmd = "pdf2svg #{basename}.pdf #{basename}.svg"
81
83
  else
82
84
  cmd = "convert -density #{render_res} #{basename}.pdf #{basename}#{ext}"
83
85
  end
84
86
  execute(cmd, cwd, context)
85
87
 
86
- if render_res != output_res
87
- _status, stdout, _stderr = execute("identify #{basename}#{ext}", cwd, context)
88
- width, height = stdout.scan(/\s\d+x\d+\s/).first.strip.split('x').collect do |s|
89
- s.to_f * output_res.to_f / render_res.to_f
88
+ # resizing doesn't really make sense on a vector graphic.
89
+ unless ext =~ /\.svg/i
90
+ if render_res != output_res
91
+ _status, stdout, _stderr = execute("identify #{basename}#{ext}", cwd, context)
92
+ width, height = stdout.scan(/\s\d+x\d+\s/).first.strip.split('x').collect do |s|
93
+ s.to_f * output_res.to_f / render_res.to_f
94
+ end
95
+ execute("convert -resize #{width}x#{height} #{basename}#{ext} #{basename}#{ext}", cwd, context)
90
96
  end
91
- execute("convert -resize #{width}x#{height} #{basename}#{ext} #{basename}#{ext}", cwd, context)
92
97
  end
93
98
  end
94
99
  private_class_method :compile
@@ -3,6 +3,6 @@
3
3
  module Webgen
4
4
 
5
5
  # The version of webgen.
6
- VERSION = '1.5.1'
6
+ VERSION = '1.5.2'
7
7
 
8
8
  end
@@ -19,13 +19,13 @@ class TestContentProcessorTikz < Minitest::Test
19
19
 
20
20
  @context.node.define_singleton_method(:[]) {|_ignored| nil}
21
21
 
22
- call('\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false)
23
- Timeout.timeout(0.2) { call('\tikz \draw (0,0) -- (0,1);', 'test.png', [], '', '72 72', false) } # test cache
22
+ call('\tikz \draw (0,0) -- (1,1);', 'test.png', [], '', '72 72', false)
23
+ Timeout.timeout(0.2) { call('\tikz \draw (0,0) -- (1,1);', 'test.png', [], '', '72 72', false) } # test cache
24
24
  refute_nil(@context.content)
25
25
 
26
26
  assert_raises(Webgen::RenderError) { call('\tikz \asdfasdfasf', 'test.png', [], '', '72 72', false) }
27
27
 
28
- call('\tikz \draw (0,0) -- (0,1);', '/images/test.gif', ['arrows'], '->', '72 72', true)
28
+ call('\tikz \draw (0,0) -- (1,1);', '/images/test.gif', ['arrows'], '->', '72 72', true)
29
29
  refute_nil(@context.content)
30
30
  end
31
31
 
@@ -44,7 +44,7 @@ class TestContentProcessorTikz < Minitest::Test
44
44
  end
45
45
 
46
46
  def teardown
47
- FileUtils.rm_rf(@website.directory) if @website
47
+ #FileUtils.rm_rf(@website.directory) if @website
48
48
  end
49
49
 
50
50
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-06 00:00:00.000000000 Z
11
+ date: 2018-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cmdparse