jekyll-latex-pdf 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +17 -9
- data/data/kramdown/apa6.latex +2 -1
- data/data/kramdown/jekyll-latex-pdf.latex +1 -0
- data/lib/jekyll/latex/pdf/defaults.rb +4 -0
- data/lib/jekyll/latex/pdf/latex.rb +5 -0
- data/lib/jekyll/latex/pdf/tikz.rb +4 -2
- data/lib/jekyll/latex/pdf/tikz/{tikz-html.rb → html.rb} +40 -6
- data/lib/jekyll/latex/pdf/tikz/{tikz-latex.rb → latex.rb} +3 -1
- data/lib/jekyll/latex/pdf/tikz/libraries.rb +27 -0
- data/lib/jekyll/latex/pdf/tikz/utils.rb +27 -0
- data/lib/jekyll/latex/pdf/utilities.rb +1 -1
- data/lib/jekyll/latex/pdf/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb414493da4d0f568ad70493dc8bd4aa1b2b88b7
|
4
|
+
data.tar.gz: 290cdc7166bd3af0a4b3a763810520e7ea2e2e71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bbf080ba02afc431613d576a3ea25706ba5ad772d5b4c8ea6ae69cd998cdfd138005daed24bc822b7664eaeb3b18d3287fd3f0b2254147dca65cdd5191ccedd
|
7
|
+
data.tar.gz: c287947cffb62facfc8e9e2d1661a181a94c741c37dc94f17b6f458486913187445ad81868200dbb97ac6730e1fa2fc4cdf151957e567d8bad9f42e43efd0539
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -79,15 +79,16 @@ All this variables can also be adjusted in the yaml header of your post.
|
|
79
79
|
|
80
80
|
Variables to customize are:
|
81
81
|
|
82
|
-
| Variable | Description
|
83
|
-
|
84
|
-
| `pdf_engine` | Defaults to `lualatex` and can be changed to pdflatex, xelatex, ...
|
85
|
-
| `bib_engine` | Defaults to `biber` and is used when `jekyll-scholar` is present.
|
86
|
-
| `template` | Defaults to `jekyll-latex-pdf`
|
87
|
-
| `template_path` | Is where we look for your own templates. Defaults to `_latex`.
|
88
|
-
| `date_as_note` | Is `false` by default. See apa6
|
89
|
-
| `tikz_path` | Defaults to `assets/tikz_svg`. See tikz section.
|
90
|
-
| `latex_cache_dir` | Path where we hold the latex files. Default: `.latex_cache`
|
82
|
+
| Variable | Description |
|
83
|
+
|:------------------|:----------------------------------------------------------------------------------|
|
84
|
+
| `pdf_engine` | Defaults to `lualatex` and can be changed to pdflatex, xelatex, ... |
|
85
|
+
| `bib_engine` | Defaults to `biber` and is used when `jekyll-scholar` is present. |
|
86
|
+
| `template` | Defaults to `jekyll-latex-pdf` |
|
87
|
+
| `template_path` | Is where we look for your own templates. Defaults to `_latex`. |
|
88
|
+
| `date_as_note` | Is `false` by default. See apa6 |
|
89
|
+
| `tikz_path` | Defaults to `assets/tikz_svg`. See tikz section. |
|
90
|
+
| `latex_cache_dir` | Path where we hold the latex files. Default: `.latex_cache` |
|
91
|
+
| `tikz_md5` | Default: `false`. Use md5 digest in filename to force browser reload on changes. |
|
91
92
|
|
92
93
|
Just set up a ticket on
|
93
94
|
(issues)[https://gitlab.com/grauschnabel/jekyll-latex-pdf/issues] to add feature
|
@@ -176,6 +177,13 @@ be converted to svg and png then. This svg is included as object. For latex,
|
|
176
177
|
the tikz code will go directly into the source file and will be rendered during
|
177
178
|
the rendering process.
|
178
179
|
|
180
|
+
You can also use tikzlibraries by using for example:
|
181
|
+
|
182
|
+
```
|
183
|
+
{% tikz filename libraries: arrows snakes %}
|
184
|
+
...
|
185
|
+
```
|
186
|
+
|
179
187
|
You can adjust the `tikz_path` if you want to store the svg and png files
|
180
188
|
somewhere else. The svg file will be used in your page by default, but if the
|
181
189
|
browser cannot render it, the png file will be used.
|
data/data/kramdown/apa6.latex
CHANGED
@@ -29,6 +29,10 @@ module Jekyll
|
|
29
29
|
|
30
30
|
# Directory where the latex files will be keept.
|
31
31
|
"latex_cache_path" => ".latex-cache",
|
32
|
+
|
33
|
+
# Using md5 sum for tikz svg and png files. Useful if you edit your
|
34
|
+
# files and want the browser to reload the object.
|
35
|
+
"tikz_md5" => false,
|
32
36
|
}
|
33
37
|
class << self
|
34
38
|
|
@@ -76,9 +76,14 @@ module Jekyll
|
|
76
76
|
@kramdowndata.add(note: "\\printdate{#{@kramdowndata.data[:date_str]}}")
|
77
77
|
end
|
78
78
|
|
79
|
+
def prepare_tikz
|
80
|
+
@kramdowndata.add(tikzlibraries: Tikz::TikzLibraries.render)
|
81
|
+
end
|
82
|
+
|
79
83
|
def prepare
|
80
84
|
prepare_abstract
|
81
85
|
prepare_date_as_note if @site.config["pdf"]["date_as_note"]
|
86
|
+
prepare_tikz
|
82
87
|
prepare_latex
|
83
88
|
|
84
89
|
basename = File.basename(@name, ".*")
|
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "jekyll/latex/pdf/tikz/
|
4
|
-
require "jekyll/latex/pdf/tikz/
|
3
|
+
require "jekyll/latex/pdf/tikz/libraries"
|
4
|
+
require "jekyll/latex/pdf/tikz/utils"
|
5
|
+
require "jekyll/latex/pdf/tikz/html"
|
6
|
+
require "jekyll/latex/pdf/tikz/latex"
|
@@ -31,16 +31,23 @@ module Jekyll
|
|
31
31
|
class TikzHtml < Liquid::Block
|
32
32
|
|
33
33
|
include Utilities
|
34
|
+
include TikzUtils
|
34
35
|
|
35
36
|
attr_reader :config, :site
|
36
37
|
|
37
38
|
def initialize(tag_name, markup, tokens)
|
38
39
|
super
|
39
|
-
|
40
|
+
parse_markup(markup)
|
40
41
|
|
41
42
|
@header = <<-'END'
|
42
43
|
\documentclass{standalone}
|
43
44
|
\usepackage{tikz}
|
45
|
+
END
|
46
|
+
|
47
|
+
# @header += "\\usetikzlibrary{#{@params['library']}}\n" if @params.key?("library")
|
48
|
+
@header += TikzLibraries.render
|
49
|
+
|
50
|
+
@header += <<-'END'
|
44
51
|
\begin{document}
|
45
52
|
\begin{tikzpicture}
|
46
53
|
END
|
@@ -57,22 +64,49 @@ module Jekyll
|
|
57
64
|
set_context_to context
|
58
65
|
|
59
66
|
tikz_code = @header + super + @footer
|
67
|
+
md5, old_md5 = false, false
|
60
68
|
|
61
69
|
tmp_directory = File.join(Dir.pwd,
|
62
70
|
@site.config["pdf"]["latex_cache_path"],
|
63
71
|
"tikz",
|
64
72
|
File.basename(context["page"]["url"], ".*"))
|
65
|
-
tex_path = File.join(tmp_directory, "#{@file_name}.tex")
|
66
|
-
pdf_path = File.join(tmp_directory, "#{@file_name}.pdf")
|
67
73
|
FileUtils.mkdir_p tmp_directory
|
68
74
|
|
69
75
|
dest_directory = File.join(Dir.pwd, @site.config["pdf"]["tikz_path"], File.basename(context["page"]["url"], ".*"))
|
76
|
+
FileUtils.mkdir_p dest_directory
|
77
|
+
|
78
|
+
# use new filename if content has changed.
|
79
|
+
if @site.config["pdf"]["tikz_md5"]
|
80
|
+
# add it to file name.
|
81
|
+
md5 = Digest::MD5.hexdigest(tikz_code).to_s
|
82
|
+
|
83
|
+
md5_filename = File.join(tmp_directory, "md5.txt")
|
84
|
+
|
85
|
+
old_md5 = File.open(md5_filename, 'r').read if File.exist? md5_filename
|
86
|
+
old_filename = @file_name + "_#{old_md5}"
|
87
|
+
|
88
|
+
unless old_md5.eql? md5
|
89
|
+
FileUtils.rm_rf(Dir.glob(File.join(tmp_directory, "*")))
|
90
|
+
svg_path = File.join(dest_directory, "#{old_filename}.svg")
|
91
|
+
png_path = File.join(dest_directory, "#{old_filename}.png")
|
92
|
+
FileUtils.rm(svg_path) if File.exist? svg_path
|
93
|
+
FileUtils.rm(png_path) if File.exist? png_path
|
94
|
+
end
|
95
|
+
|
96
|
+
@file_name += "_#{md5}"
|
97
|
+
|
98
|
+
File.open(md5_filename, 'w') {|file| file.write(md5.to_s) }
|
99
|
+
end
|
100
|
+
|
101
|
+
tex_path = File.join(tmp_directory, "#{@file_name}.tex")
|
102
|
+
pdf_path = File.join(tmp_directory, "#{@file_name}.pdf")
|
103
|
+
|
70
104
|
svg_path = File.join(dest_directory, "#{@file_name}.svg")
|
71
105
|
png_path = File.join(dest_directory, "#{@file_name}.png")
|
72
|
-
FileUtils.mkdir_p dest_directory
|
73
106
|
|
74
107
|
# if the file doesn't exist or the tikz code is not the same with the file, then compile the file
|
75
|
-
if !File.exist?(tex_path) || !tikz_same?(tex_path, tikz_code) ||
|
108
|
+
if !File.exist?(tex_path) || !tikz_same?(tex_path, tikz_code) ||
|
109
|
+
!File.exist?(svg_path) || !File.exist?(png_path)
|
76
110
|
File.open(tex_path, 'w') {|file| file.write(tikz_code.to_s) }
|
77
111
|
cmds = [[@site.config["pdf"]["pdf_engine"],
|
78
112
|
"--interaction=batchmode",
|
@@ -90,7 +124,7 @@ module Jekyll
|
|
90
124
|
File.basename(context["page"]["url"], ".*"),
|
91
125
|
"#{@file_name}.png")
|
92
126
|
"\n<object data=\"/#{web_svg_path}\" type=\"image/svg+xml\">" \
|
93
|
-
"<img src=\"/#{web_png_path}\"
|
127
|
+
"<img src=\"/#{web_png_path}\" />" \
|
94
128
|
"</object>\n"
|
95
129
|
end
|
96
130
|
|
@@ -7,10 +7,12 @@ module Jekyll
|
|
7
7
|
class TikzPdf < Liquid::Block
|
8
8
|
|
9
9
|
include Utilities
|
10
|
+
include TikzUtils
|
10
11
|
|
11
12
|
def initialize(tag_name, markup, tokens)
|
12
13
|
super
|
13
|
-
|
14
|
+
|
15
|
+
parse_markup(markup)
|
14
16
|
|
15
17
|
@header = <<~'END'
|
16
18
|
\begin{tikzpicture}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Latex
|
5
|
+
module Pdf
|
6
|
+
module Tikz
|
7
|
+
class TikzLibraries
|
8
|
+
|
9
|
+
def self.add_lib(lib)
|
10
|
+
@@libs ||= []
|
11
|
+
@@libs << lib unless libs.include?(lib)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.libs
|
15
|
+
@@libs ||= []
|
16
|
+
@@libs.sort
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.render
|
20
|
+
libs.empty? ? "" : "\\usetikzlibrary{#{libs.join(',')}}\n"
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Latex
|
5
|
+
module Pdf
|
6
|
+
module Tikz
|
7
|
+
module TikzUtils
|
8
|
+
def parse_markup(markup)
|
9
|
+
h = markup.split " "
|
10
|
+
|
11
|
+
@file_name = h.shift
|
12
|
+
# @params ||= {}
|
13
|
+
|
14
|
+
k = ""
|
15
|
+
h.each do |v|
|
16
|
+
if v.end_with? ":"
|
17
|
+
k = v[0..-2]
|
18
|
+
next
|
19
|
+
end
|
20
|
+
TikzLibraries.add_lib(v) if "library" == k
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-latex-pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Kaffanke
|
@@ -172,8 +172,10 @@ files:
|
|
172
172
|
- lib/jekyll/latex/pdf/scholar/bibliography.rb
|
173
173
|
- lib/jekyll/latex/pdf/scholar/cite.rb
|
174
174
|
- lib/jekyll/latex/pdf/tikz.rb
|
175
|
-
- lib/jekyll/latex/pdf/tikz/
|
176
|
-
- lib/jekyll/latex/pdf/tikz/
|
175
|
+
- lib/jekyll/latex/pdf/tikz/html.rb
|
176
|
+
- lib/jekyll/latex/pdf/tikz/latex.rb
|
177
|
+
- lib/jekyll/latex/pdf/tikz/libraries.rb
|
178
|
+
- lib/jekyll/latex/pdf/tikz/utils.rb
|
177
179
|
- lib/jekyll/latex/pdf/utilities.rb
|
178
180
|
- lib/jekyll/latex/pdf/version.rb
|
179
181
|
homepage: https://gitlab.com/grauschnabel/jekyll-latex-pdf
|