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 +4 -4
- data/VERSION +1 -1
- data/data/webgen/passive_sources/templates/tikz.template +1 -2
- data/lib/webgen/bundle/built-in/info.yaml +14 -0
- data/lib/webgen/bundle/built-in/init.rb +1 -0
- data/lib/webgen/content_processor/tikz.rb +16 -11
- data/lib/webgen/version.rb +1 -1
- data/test/webgen/content_processor/test_tikz.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82b8cbcc822f838af50c33be08022cdb694bbf72e4b0a8b16119bc1170169ead
|
4
|
+
data.tar.gz: c35bc89fec452d38cc7294f3544662fbaa18e0364320242ed57a92b5151467d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b11a5924bf44d4cec50cf6b658527644a661f4ea8a35cf2adbf25025325467acbe568b3533489455f9b132799532be8594d906e81cfd0ff2e0ce17ba62832b6
|
7
|
+
data.tar.gz: 3933fbbf9f71811d3e658ebe04dce9f583a3a6cca01139ba209476e38761fd30380d8741e960311e571f27467c086310a2f3dfbccb309d094570fef5d44aa472
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.5.
|
1
|
+
1.5.2
|
@@ -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("
|
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
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
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
|
data/lib/webgen/version.rb
CHANGED
@@ -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) -- (
|
23
|
-
Timeout.timeout(0.2) { call('\tikz \draw (0,0) -- (
|
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) -- (
|
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.
|
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-
|
11
|
+
date: 2018-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|