jekyll-latex-pdf 0.5.1 → 0.6.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9ff894a61d241f55b32b7537b01595a4defdc7d9
4
- data.tar.gz: d9c51b26b7822cc404d2f906acb0f8550f3eeb75
2
+ SHA256:
3
+ metadata.gz: 86c0f81a40bc3297a452528bb9ccee1cfbcc1e4625ef7b9974b1bccc4aaaae43
4
+ data.tar.gz: e50d08f3449ebaa915e91442c4bad3cda59fc3ab12a1012c8e46027626853319
5
5
  SHA512:
6
- metadata.gz: 90ff22f6542d267d08c18bbfd19dc216af5c5564195c9b743b80c514a9fadfb0456e92189ace912e31433f90e1da75b912e25b1a69eacdc797c95d99ce8c8af2
7
- data.tar.gz: 5bbc99017f8020994c77a8081141d0c90be513acda274f45db994082f7ad7705903cfa45663664b65052a61be5b801126b2e4a2f17485cf12276585dd801ed99
6
+ metadata.gz: 47c9ad3bbbd1a136c847c616b1dd64e7797b975c0bb10f3c2c467634e1e8fac912558ad2c219858becb24e9805572c837171ab219c9c8167c5156e1883ba6697
7
+ data.tar.gz: eca65b1d598845813e1bcee785744b6e114b1e60d8e0d0fb7b16d89a4380b8c1b74917de9e18687872d817b2a429d4325bd893d02d4bb3a7e98335229090bc85
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.4]
4
+ ### Added
5
+ - Make links gray in apa6 pdf.
6
+ - Making links absolute in pdf.
7
+
8
+ ### Bugfix
9
+ - Makeing links work in pdf.
10
+
11
+ ## [0.5.3]
12
+ ### Added
13
+ - Use libraries for tikz pictures.
14
+ - Use md5 in tikz filenames forces reload in browser when changed.
15
+ - Added figref tag which was introducded by me to jekyll-figure
16
+ - No need to rebuild if latex source didn't change.
17
+
3
18
  ## [0.5.1]
4
19
  ### Added
5
20
  - Configurable latex and tikz cache.
data/Gemfile.lock CHANGED
@@ -1,122 +1,128 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll-latex-pdf (0.5.1)
5
- jekyll (~> 3.8.5)
6
- kramdown (~> 1.17)
4
+ jekyll-latex-pdf (0.6.0)
5
+ jekyll (~> 4.2)
6
+ kramdown (~> 2.3)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.6.0)
12
- public_suffix (>= 2.0.2, < 4.0)
13
- ast (2.4.0)
14
- bibtex-ruby (4.4.7)
11
+ addressable (2.8.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.2)
14
+ bibtex-ruby (6.0.0)
15
15
  latex-decode (~> 0.0)
16
- citeproc (1.0.9)
16
+ citeproc (1.0.10)
17
17
  namae (~> 1.0)
18
- citeproc-ruby (1.1.10)
18
+ citeproc-ruby (1.1.14)
19
19
  citeproc (~> 1.0, >= 1.0.9)
20
- csl (~> 1.5)
21
- coderay (1.1.2)
20
+ csl (~> 1.6)
21
+ coderay (1.1.3)
22
22
  colorator (1.1.0)
23
- concurrent-ruby (1.1.5)
24
- csl (1.5.0)
23
+ concurrent-ruby (1.1.9)
24
+ csl (1.6.0)
25
25
  namae (~> 1.0)
26
- csl-styles (1.0.1.9)
26
+ rexml
27
+ csl-styles (1.0.1.11)
27
28
  csl (~> 1.0)
28
- em-websocket (0.5.1)
29
+ em-websocket (0.5.3)
29
30
  eventmachine (>= 0.12.9)
30
- http_parser.rb (~> 0.6.0)
31
+ http_parser.rb (~> 0)
31
32
  eventmachine (1.2.7)
32
- ffi (1.10.0)
33
+ ffi (1.15.4)
33
34
  forwardable-extended (2.6.0)
34
- http_parser.rb (0.6.0)
35
- i18n (0.9.5)
35
+ http_parser.rb (0.8.0)
36
+ i18n (1.8.11)
36
37
  concurrent-ruby (~> 1.0)
37
- jaro_winkler (1.5.2)
38
- jekyll (3.8.5)
38
+ jekyll (4.2.1)
39
39
  addressable (~> 2.4)
40
40
  colorator (~> 1.0)
41
41
  em-websocket (~> 0.5)
42
- i18n (~> 0.7)
43
- jekyll-sass-converter (~> 1.0)
42
+ i18n (~> 1.0)
43
+ jekyll-sass-converter (~> 2.0)
44
44
  jekyll-watch (~> 2.0)
45
- kramdown (~> 1.14)
45
+ kramdown (~> 2.3)
46
+ kramdown-parser-gfm (~> 1.0)
46
47
  liquid (~> 4.0)
47
- mercenary (~> 0.3.3)
48
+ mercenary (~> 0.4.0)
48
49
  pathutil (~> 0.9)
49
- rouge (>= 1.7, < 4)
50
+ rouge (~> 3.0)
50
51
  safe_yaml (~> 1.0)
51
- jekyll-sass-converter (1.5.2)
52
- sass (~> 3.4)
53
- jekyll-scholar (5.14.1)
54
- bibtex-ruby (~> 4.0, >= 4.0.13)
52
+ terminal-table (~> 2.0)
53
+ jekyll-sass-converter (2.1.0)
54
+ sassc (> 2.0.1, < 3.0)
55
+ jekyll-scholar (7.0.0)
56
+ bibtex-ruby (~> 6.0)
55
57
  citeproc-ruby (~> 1.0)
56
58
  csl-styles (~> 1.0)
57
- jekyll (~> 3.0)
59
+ jekyll (~> 4.0)
58
60
  jekyll-watch (2.2.1)
59
61
  listen (~> 3.0)
60
- kramdown (1.17.0)
61
- latex-decode (0.3.1)
62
+ kramdown (2.3.1)
63
+ rexml
64
+ kramdown-parser-gfm (1.1.0)
65
+ kramdown (~> 2.0)
66
+ latex-decode (0.3.2)
62
67
  liquid (4.0.3)
63
- listen (3.1.5)
64
- rb-fsevent (~> 0.9, >= 0.9.4)
65
- rb-inotify (~> 0.9, >= 0.9.7)
66
- ruby_dep (~> 1.2)
67
- mercenary (0.3.6)
68
- method_source (0.8.2)
69
- namae (1.0.1)
70
- parallel (1.17.0)
71
- parser (2.6.2.1)
72
- ast (~> 2.4.0)
68
+ listen (3.7.0)
69
+ rb-fsevent (~> 0.10, >= 0.10.3)
70
+ rb-inotify (~> 0.9, >= 0.9.10)
71
+ mercenary (0.4.0)
72
+ method_source (1.0.0)
73
+ namae (1.1.1)
74
+ parallel (1.21.0)
75
+ parser (3.0.3.0)
76
+ ast (~> 2.4.1)
73
77
  pathutil (0.16.2)
74
78
  forwardable-extended (~> 2.6)
75
- pry (0.11.0)
76
- coderay (~> 1.1.0)
77
- method_source (~> 0.8.1)
78
- pry-doc (0.6.0)
79
- pry (~> 0.9)
80
- yard (~> 0.8)
81
- psych (3.1.0)
82
- public_suffix (3.0.3)
79
+ pry (0.14.1)
80
+ coderay (~> 1.1)
81
+ method_source (~> 1.0)
82
+ pry-doc (1.2.0)
83
+ pry (~> 0.11)
84
+ yard (~> 0.9.11)
85
+ public_suffix (4.0.6)
83
86
  rainbow (3.0.0)
84
- rake (10.5.0)
85
- rb-fsevent (0.10.3)
86
- rb-inotify (0.10.0)
87
+ rake (13.0.6)
88
+ rb-fsevent (0.11.0)
89
+ rb-inotify (0.10.1)
87
90
  ffi (~> 1.0)
88
- rouge (3.3.0)
89
- rubocop (0.67.2)
90
- jaro_winkler (~> 1.5.1)
91
+ regexp_parser (2.1.1)
92
+ rexml (3.2.5)
93
+ rouge (3.26.1)
94
+ rubocop (1.23.0)
91
95
  parallel (~> 1.10)
92
- parser (>= 2.5, != 2.5.1.1)
93
- psych (>= 3.1.0)
96
+ parser (>= 3.0.0.0)
94
97
  rainbow (>= 2.2.2, < 4.0)
98
+ regexp_parser (>= 1.8, < 3.0)
99
+ rexml
100
+ rubocop-ast (>= 1.12.0, < 2.0)
95
101
  ruby-progressbar (~> 1.7)
96
- unicode-display_width (>= 1.4.0, < 1.6)
97
- ruby-progressbar (1.10.0)
98
- ruby_dep (1.5.0)
102
+ unicode-display_width (>= 1.4.0, < 3.0)
103
+ rubocop-ast (1.13.0)
104
+ parser (>= 3.0.1.1)
105
+ ruby-progressbar (1.11.0)
99
106
  safe_yaml (1.0.5)
100
- sass (3.7.4)
101
- sass-listen (~> 4.0.0)
102
- sass-listen (4.0.0)
103
- rb-fsevent (~> 0.9, >= 0.9.4)
104
- rb-inotify (~> 0.9, >= 0.9.7)
105
- unicode-display_width (1.5.0)
106
- yard (0.9.19)
107
+ sassc (2.4.0)
108
+ ffi (~> 1.9)
109
+ terminal-table (2.0.0)
110
+ unicode-display_width (~> 1.1, >= 1.1.1)
111
+ unicode-display_width (1.8.0)
112
+ yard (0.9.26)
107
113
 
108
114
  PLATFORMS
109
- ruby
115
+ x86_64-linux
110
116
 
111
117
  DEPENDENCIES
112
- bundler (~> 1.16)
118
+ bundler (~> 2.2)
113
119
  jekyll-latex-pdf!
114
- jekyll-scholar (~> 5.14.1)
115
- method_source (~> 0.8.2)
116
- pry
117
- pry-doc (~> 0.6.0)
118
- rake (~> 10.0)
119
- rubocop (~> 0.67)
120
+ jekyll-scholar (~> 7.0)
121
+ method_source (~> 1.0)
122
+ pry (~> 0.14)
123
+ pry-doc (~> 1.2.0)
124
+ rake (~> 13)
125
+ rubocop (~> 1.23)
120
126
 
121
127
  BUNDLED WITH
122
- 1.16.1
128
+ 2.2.32
data/README.md CHANGED
@@ -36,6 +36,13 @@ Or install it yourself as:
36
36
  To make it work with jekyll, you need to add `- jekyll-latex-pdf` to the plugins
37
37
  section in your `_config.yml` file of your jekyll site.
38
38
 
39
+ In `_config.yml` you need to add a section for the pdf config:
40
+ `pdf:
41
+ pdf_engine: lualatex
42
+ author: The Default Author
43
+ `
44
+ See below for other options and what the options control.
45
+
39
46
  You need to have Latex installed on your system. Default is to use `lualatex`
40
47
  and `biber` which depends on your system how to install. Look for texlive and
41
48
  biblatex to see how it works.
@@ -44,8 +51,8 @@ If you want to use the `tikz` environment you additionally need to install
44
51
  `pdf2svg` and `graphicsmagick`.
45
52
 
46
53
  You may want to add `.latex-cache` (or whatever you set in your
47
- `latex_cache_path`) to your `.gitignore`. This is where we store the latex
48
- files for faster recompiling if needed.
54
+ `latex_cache_path`) and `assets/tikz/` to your `.gitignore`. This is where we
55
+ store the latex files for faster recompiling if needed.
49
56
 
50
57
  ## Usage
51
58
 
@@ -60,6 +67,12 @@ In your post template use
60
67
  to get a link to the pdf version of your page. Maybe you want to surround this
61
68
  in an if clause if you have posts which should not be rendered to pdf too.
62
69
 
70
+ Please note that if you use a baseurl, this is not automatically included. In this case you should use:
71
+ ```
72
+ <a href="{{ page.pdf_url | prepend:site.baseurl }}" target="_blank">PDF</a>
73
+ ```
74
+
75
+
63
76
  ## Configuration
64
77
 
65
78
  We ship a latex template which is derived from the kramdown original to add
@@ -79,15 +92,16 @@ All this variables can also be adjusted in the yaml header of your post.
79
92
 
80
93
  Variables to customize are:
81
94
 
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` |
95
+ | Variable | Description |
96
+ |:------------------|:----------------------------------------------------------------------------------|
97
+ | `pdf_engine` | Defaults to `lualatex` and can be changed to pdflatex, xelatex, ... |
98
+ | `bib_engine` | Defaults to `biber` and is used when `jekyll-scholar` is present. |
99
+ | `template` | Defaults to `jekyll-latex-pdf` |
100
+ | `template_path` | Is where we look for your own templates. Defaults to `_latex`. |
101
+ | `date_as_note` | Is `false` by default. See apa6 |
102
+ | `tikz_path` | Defaults to `assets/tikz`. See tikz section. |
103
+ | `latex_cache_dir` | Path where we hold the latex files. Default: `.latex_cache` |
104
+ | `tikz_md5` | Default: `false`. Use md5 digest in filename to force browser reload on changes. |
91
105
 
92
106
  Just set up a ticket on
93
107
  (issues)[https://gitlab.com/grauschnabel/jekyll-latex-pdf/issues] to add feature
@@ -99,7 +113,11 @@ The default template is a good way to start. Copy it to your `_latex` folder,
99
113
  and adjust it. Change the name and set the `template` in your config or the
100
114
  yaml header of your post. Your template in `_latex` will be prefered to the one
101
115
  shiped with this gem if it has the same name. Files should have the `.latex`
102
- extension.
116
+ extension.
117
+
118
+ If you change the template when pdfs are allready created, make sure to delete
119
+ the `latex_cache_dir`, otherwise only changed posts will be recompiled with the
120
+ new template.
103
121
 
104
122
  ### jekyll-latex-pdf
105
123
 
@@ -158,6 +176,17 @@ in a customized template.
158
176
  Use this to create figure environments inside html. With jekyll-latex-pdf you
159
177
  get also the figure environment inside latex files.
160
178
 
179
+ jekyll-figure did not use label and reference, which is often used in latex
180
+ documents. So I implemented this to jekyll-figure, see my (pull
181
+ request)[https://github.com/paulrobertlloyd/jekyll-figure/pull/7]. As long as
182
+ the pull isn't activated, you can use
183
+
184
+ ```
185
+ gem 'jekyll-figure', git: 'https://github.com/grauschnabel/jekyll-figure.git', branch: 'figure_label'
186
+ ```
187
+
188
+ in your jekyll sites Gemfile to have that feature activated for websites.
189
+
161
190
  ## Other extras
162
191
 
163
192
  ### Tikz
@@ -176,6 +205,13 @@ be converted to svg and png then. This svg is included as object. For latex,
176
205
  the tikz code will go directly into the source file and will be rendered during
177
206
  the rendering process.
178
207
 
208
+ You can also use tikzlibraries by using for example:
209
+
210
+ ```
211
+ {% tikz filename libraries: arrows snakes %}
212
+ ...
213
+ ```
214
+
179
215
  You can adjust the `tikz_path` if you want to store the svg and png files
180
216
  somewhere else. The svg file will be used in your page by default, but if the
181
217
  browser cannot render it, the png file will be used.
@@ -21,17 +21,21 @@ encmap = {
21
21
  }
22
22
  %><%
23
23
  enclang = {
24
+ 'en' => 'english',
24
25
  'de' => 'ngerman',
25
26
  'sv' => 'swedish'
26
27
  }
27
28
  %>
28
29
  \documentclass[a4paper,jou,biblatex]{apa6}
30
+ \usepackage[utf8]{luainputenc}
31
+ %\usepackage{fontspec}
29
32
 
30
33
  \usepackage{amsmath}
31
34
  \usepackage{graphicx}
32
35
  %\usepackage[colorinlistoftodos]{todonotes}
33
- \usepackage{tikz}
34
36
 
37
+ \usepackage{tikz}
38
+ <%= data[:tikzlibraries] %>
35
39
 
36
40
  \usepackage{hyperref}
37
41
  \hypersetup{
@@ -39,11 +43,15 @@ colorlinks,
39
43
  citecolor=black,
40
44
  filecolor=black,
41
45
  linkcolor=black,
42
- urlcolor=black
46
+ urlcolor=darkgray
43
47
  }
48
+
44
49
  <% if data[:lang] %>
45
50
  \usepackage[<%= enclang[data[:lang]] %>]{babel}
46
51
  \usepackage[<%= enclang[data[:lang]] %>]{isodate}
52
+ <% else %>
53
+ \usepackage[english]{babel}
54
+ \usepackage[english]{isodate}
47
55
  <% end %>
48
56
 
49
57
  <% if data[:bibtex_files] %>
@@ -22,6 +22,7 @@ encmap = {
22
22
  %>
23
23
  <%
24
24
  enclang = {
25
+ 'en' => 'english',
25
26
  'de' => 'ngerman',
26
27
  'sv' => 'swedish'
27
28
  }
@@ -38,11 +39,15 @@ enclang = {
38
39
  <% @converter.data[:packages].each {|pkg| %>\usepackage{<%= pkg %>}
39
40
  <% } %>
40
41
  \usepackage{tikz}
42
+ <%= data[:tikzlibraries] %>
41
43
  \usepackage{hyperref}
42
44
 
43
45
  <% if data[:lang] %>
44
46
  \usepackage[<%= enclang[data[:lang]] %>]{babel}
45
47
  \usepackage[<%= enclang[data[:lang]] %>]{isodate}
48
+ <% else %>
49
+ \usepackage[english]{babel}
50
+ \usepackage[english]{isodate}
46
51
  <% end %>
47
52
 
48
53
  <% if data[:bibtex_files] %>
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
  spec.email = ["martin@kaffanke.at"]
12
12
 
13
13
  spec.summary = "Crates pdfs using just latex for jekyll posts. (needs kramdown)"
14
- spec.description = "The aim is to have a very comfortable and configurabe latex interface for jekyll posts."
14
+ spec.description = "Create PDFs for download from your posts, using latex flexible and comfortable."
15
15
  spec.homepage = "https://gitlab.com/grauschnabel/jekyll-latex-pdf"
16
16
  spec.license = "MIT"
17
17
 
@@ -22,17 +22,17 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r!^exe/!) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_development_dependency "bundler", "~> 1.16"
26
- spec.add_development_dependency "method_source", "~> 0.8.2"
27
- spec.add_development_dependency "pry"
28
- spec.add_development_dependency "pry-doc", "~> 0.6.0"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- spec.add_development_dependency "rubocop", "~> 0.67"
31
- spec.add_development_dependency "jekyll-scholar", "~> 5.14.1"
25
+ spec.add_development_dependency "bundler", "~> 2.2"
26
+ spec.add_development_dependency "method_source", "~> 1.0"
27
+ spec.add_development_dependency "pry", "~> 0.14"
28
+ spec.add_development_dependency "pry-doc", "~> 1.2.0"
29
+ spec.add_development_dependency "rake", "~> 13"
30
+ spec.add_development_dependency "rubocop", "~> 1.23"
31
+ spec.add_development_dependency "jekyll-scholar", "~> 7.0"
32
32
  #spec.add_development_dependency "minitest", "~> 5.0.0"
33
33
  #spec.add_development_dependency "rouge"
34
34
  #spec.add_development_dependency "stringex", "~> 1.5.1"
35
35
 
36
- spec.add_runtime_dependency "jekyll", "~> 3.8.5"
37
- spec.add_runtime_dependency "kramdown", "~> 1.17"
36
+ spec.add_runtime_dependency "jekyll", "~> 4.2"
37
+ spec.add_runtime_dependency "kramdown", "~> 2.3"
38
38
  end
@@ -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
 
@@ -13,11 +13,11 @@ module Jekyll
13
13
 
14
14
  def initialize(site, page)
15
15
  @site = site
16
+ @page = page
16
17
  @base = site.source
17
18
  @dir = File.dirname(page.url)
18
19
  @name = File.basename(page.url, File.extname(page.url)) + ".pdf"
19
20
  @texname = File.basename(page.url, File.extname(page.url)) + ".tex"
20
- # @settings = site.config["pdf"] ? site.config["pdf"].clone : {}
21
21
 
22
22
  process(@name)
23
23
 
@@ -25,13 +25,14 @@ module Jekyll
25
25
  self.content = page.content.clone
26
26
  self.source = page.content.dup
27
27
  page.data["pdf_url"] = url
28
- # data["layout"] = layout
28
+
29
29
  data["html_url"] = page.url
30
30
  data["date_str"] = data["date"].strftime("%Y-%m-%d")
31
31
  @config = Defaults.defaults.merge(site.config["pdf"] || {})
32
32
 
33
33
  @kramdowndata = KramdownData.new data
34
- @kramdowndata.add(site.config["pdf"] || {})
34
+ @kramdowndata.add(@site.config["pdf"] || {})
35
+ @kramdowndata.add(page.data || {})
35
36
 
36
37
  check_scholar
37
38
  check_figure
@@ -61,8 +62,10 @@ module Jekyll
61
62
  def write(dest)
62
63
  path = File.join(dest, CGI.unescape(url))
63
64
 
64
- latex = Latex.new(source, @site, @kramdowndata, @name)
65
+ latex = Latex.new(source, @site, @page, @kramdowndata, @name)
65
66
  if 0 == latex.compile
67
+ # Create target directory if not existing yet (in case of a new post - the HTML rendering which creates folders if needed happens later, so we need to do it here first)
68
+ FileUtils.mkdir_p(File.dirname(path.to_s))
66
69
  FileUtils.cp(latex.pdf_file, path)
67
70
  Jekyll.logger.debug "cp " + latex.pdf_file.to_s + " " + path.to_s
68
71
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+ module Jekyll
3
+ module Latex
4
+ module Pdf
5
+ module Figure
6
+ # Overrides the figref tag from jekyll-figure
7
+ class FigRefTag < Liquid::Tag
8
+
9
+ include Utilities
10
+
11
+ def initialize(tag_name, markup, tokens)
12
+ @label = markup.gsub(/\s/, '')
13
+ super
14
+ end
15
+
16
+ def render(_context)
17
+ nomarkdown "\\ref{#{@label}}"
18
+ end
19
+
20
+ end
21
+ end
22
+ TempLiquid.register_tag("figref", Figure::FigRefTag)
23
+ end
24
+ end
25
+ end
@@ -33,8 +33,6 @@ module Jekyll
33
33
  # Caption: convert markdown and remove paragraphs
34
34
  unless @caption.nil?
35
35
  figure_caption = @caption.gsub!(/\A"|"\Z/, "")
36
- # figure_caption = converter.convert(figure_caption).gsub(/<\/?p[^>]*>/, "").chomp
37
- # figure_caption = " <figcaption>#{figure_caption}</figcaption>\n"
38
36
  figure_caption = Kramdown::Document.new(figure_caption).to_latex.strip
39
37
  figure_caption = "\\caption{#{figure_caption}}\n"
40
38
  end
@@ -1,2 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
  require "jekyll/latex/pdf/figure/figure"
3
+ require "jekyll/latex/pdf/figure/figref"
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Latex
5
+ module Pdf
6
+ module JekyllBase
7
+ # Overrides the default Link tag with it not usable for pdf, where we
8
+ # don't want to have relative pathes.
9
+ class LinkTag < Jekyll::Tags::Link
10
+
11
+ def render(context)
12
+ site = context.registers[:site]
13
+
14
+ site.config["url"] + super
15
+ end
16
+
17
+ end
18
+ end
19
+ TempLiquid.register_tag("link", JekyllBase::LinkTag)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll/latex/pdf/jekyll/link"
@@ -12,10 +12,10 @@ module Jekyll
12
12
 
13
13
  attr_accessor :source, :latex
14
14
  attr_reader :pdf_file
15
- def initialize(source, site, data, name)
16
- # @options = options
15
+ def initialize(source, site, page, data, name)
17
16
  @kramdowndata = data
18
17
  @site = site
18
+ @page = page
19
19
  @name = name
20
20
  @engine = @site.config["pdf"]["pdf_engine"] # @options.options[:pdf_engine]
21
21
  @bibengine = @site.config["pdf"]["bib_engine"] # @options.options[:bib_engine]
@@ -24,7 +24,7 @@ module Jekyll
24
24
  end
25
25
 
26
26
  def find_template
27
- template = @site.config["pdf"]["template"]
27
+ template = @kramdowndata.data[:template]
28
28
 
29
29
  template.concat(".latex") unless template.end_with?(".latex")
30
30
 
@@ -36,27 +36,27 @@ module Jekyll
36
36
  if File.file? t
37
37
  return t
38
38
  else
39
- Jekyll.warn "jekyll-latex-pdf", "Could not find template #{t}."
39
+ Jekyll.logger.error "jekyll-latex-pdf", "Could not find template #{t}."
40
40
  end
41
41
  end
42
42
  end
43
43
 
44
44
  def prepare_latex
45
45
  TempLiquid.run do
46
- liquid_parsed = Liquid::Template.parse(@source, error_mode: :strict)
47
- unless liquid_parsed.errors.empty?
48
- Jekyll.logger.warn("Liquid parse errors", liquid_parsed.errors.join(", "))
49
- end
50
- prep_latex = liquid_parsed.render(strict_filters: true,
51
- strict_variables: true)
52
- unless liquid_parsed.errors.empty?
53
- Jekyll.logger.warn liquid_parsed.errors.join ", "
54
- end
46
+ info = {
47
+ registers: {site: @site, page: @site.site_payload["page"]},
48
+ strict_filters: true,
49
+ strict_variables: true,
50
+ }
51
+
52
+ prep_latex = Jekyll::Renderer.new(@site, @page).render_liquid(@source,
53
+ @site.site_payload,
54
+ info,
55
+ @page.path)
56
+
55
57
  options = {"data" => @kramdowndata.data,
56
58
  "template" => find_template}
57
- @latex = Kramdown::Document.
58
- new(prep_latex, options).
59
- to_latex
59
+ @latex = Kramdown::Document.new(prep_latex, options).to_latex
60
60
  end
61
61
  end
62
62
 
@@ -68,7 +68,7 @@ module Jekyll
68
68
  Jekyll.logger.debug "Trying to get the abstract from the excerpt."
69
69
  abstract, _, @source = @source.to_s.partition(excerpt_separator)
70
70
  @kramdowndata.add(abstract: Kramdown::Document.new(abstract).to_latex)
71
- end
71
+ end
72
72
  end
73
73
  end
74
74
 
@@ -76,9 +76,22 @@ 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
+
83
+ def latex_same?(file, code)
84
+ return false unless File.exist? file
85
+
86
+ File.open(file, 'r') do |latexfile|
87
+ latexfile.read == code
88
+ end
89
+ end
90
+
79
91
  def prepare
80
92
  prepare_abstract
81
93
  prepare_date_as_note if @site.config["pdf"]["date_as_note"]
94
+ prepare_tikz
82
95
  prepare_latex
83
96
 
84
97
  basename = File.basename(@name, ".*")
@@ -86,7 +99,15 @@ module Jekyll
86
99
  FileUtils.mkdir_p @tempdir
87
100
  @latexfile = basename + ".tex"
88
101
 
89
- File.open(File.join(@tempdir, @latexfile), "w:UTF-8") do |f|
102
+ # stop here, if it does not need to compile
103
+ latex_full_path = File.join(@tempdir, @latexfile)
104
+
105
+ if latex_same? latex_full_path, latex
106
+ @no_need_to_compile = true
107
+ return
108
+ end
109
+
110
+ File.open(latex_full_path, "w:UTF-8") do |f|
90
111
  f.write(latex)
91
112
  end
92
113
 
@@ -125,11 +146,14 @@ module Jekyll
125
146
 
126
147
  def compile
127
148
  prepare
128
- cmds = prepare_cmds
149
+ status = 0
150
+ if @no_need_to_compile.nil?
151
+ cmds = prepare_cmds
129
152
 
130
- Jekyll.logger.debug "jekyll-latex-pdf", "compiling in tempdir: #{@tempdir}"
153
+ Jekyll.logger.debug "jekyll-latex-pdf", "compiling in tempdir: #{@tempdir}"
131
154
 
132
- out, status = run_cmds cmds, @tempdir
155
+ _out, status = run_cmds cmds, @tempdir
156
+ end
133
157
 
134
158
  if 0 == status
135
159
  @pdf_file = File.join(@tempdir, File.basename(@latexfile, ".*") + ".pdf")
@@ -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
- @file_name = markup.gsub(/\s+/, "")
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) || !File.exist?(svg_path)
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}\" alt=\"#{@file_name}\" />" \
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
- # @file_name = markup.gsub(/\s+/, "")
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
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "jekyll/latex/pdf/tikz/tikz-html"
4
- require "jekyll/latex/pdf/tikz/tikz-latex"
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"
@@ -12,7 +12,7 @@ module Jekyll
12
12
  end
13
13
 
14
14
  def nomarkdown_p(string_to_wrap)
15
- "\n" + nomarkdown(string_to_wrap) + "\n"
15
+ "\n{::nomarkdown type=\"latex\"}\n" + string_to_wrap + "\n{:/}\n"
16
16
  end
17
17
 
18
18
  # Run some commands und stop on errors.
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  module Latex
5
5
  module Pdf
6
- VERSION = "0.5.1"
6
+ VERSION = "0.6.0"
7
7
  end
8
8
  end
9
9
  end
@@ -5,6 +5,7 @@ require "jekyll/latex/pdf/kramdown_data"
5
5
  require "jekyll/latex/pdf/utilities"
6
6
  require "jekyll/latex/pdf/liquid"
7
7
 
8
+ require "jekyll/latex/pdf/jekyll"
8
9
  require "jekyll/latex/pdf/tikz"
9
10
 
10
11
  require "jekyll/latex/pdf/latex"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-latex-pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Kaffanke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-01 00:00:00.000000000 Z
11
+ date: 2021-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,128 +16,127 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: '2.2'
20
20
  type: :development
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.16'
26
+ version: '2.2'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: method_source
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.2
33
+ version: '1.0'
34
34
  type: :development
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: 0.8.2
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '0.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry-doc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.6.0
61
+ version: 1.2.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.6.0
68
+ version: 1.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.67'
89
+ version: '1.23'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.67'
96
+ version: '1.23'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: jekyll-scholar
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 5.14.1
103
+ version: '7.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 5.14.1
110
+ version: '7.0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: jekyll
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.8.5
117
+ version: '4.2'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 3.8.5
124
+ version: '4.2'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: kramdown
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '1.17'
131
+ version: '2.3'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '1.17'
139
- description: The aim is to have a very comfortable and configurabe latex interface
140
- for jekyll posts.
138
+ version: '2.3'
139
+ description: Create PDFs for download from your posts, using latex flexible and comfortable.
141
140
  email:
142
141
  - martin@kaffanke.at
143
142
  executables: []
@@ -163,8 +162,11 @@ files:
163
162
  - lib/jekyll/latex/pdf/defaults.rb
164
163
  - lib/jekyll/latex/pdf/document.rb
165
164
  - lib/jekyll/latex/pdf/figure.rb
165
+ - lib/jekyll/latex/pdf/figure/figref.rb
166
166
  - lib/jekyll/latex/pdf/figure/figure.rb
167
167
  - lib/jekyll/latex/pdf/generator.rb
168
+ - lib/jekyll/latex/pdf/jekyll.rb
169
+ - lib/jekyll/latex/pdf/jekyll/link.rb
168
170
  - lib/jekyll/latex/pdf/kramdown_data.rb
169
171
  - lib/jekyll/latex/pdf/latex.rb
170
172
  - lib/jekyll/latex/pdf/liquid.rb
@@ -172,8 +174,10 @@ files:
172
174
  - lib/jekyll/latex/pdf/scholar/bibliography.rb
173
175
  - lib/jekyll/latex/pdf/scholar/cite.rb
174
176
  - lib/jekyll/latex/pdf/tikz.rb
175
- - lib/jekyll/latex/pdf/tikz/tikz-html.rb
176
- - lib/jekyll/latex/pdf/tikz/tikz-latex.rb
177
+ - lib/jekyll/latex/pdf/tikz/html.rb
178
+ - lib/jekyll/latex/pdf/tikz/latex.rb
179
+ - lib/jekyll/latex/pdf/tikz/libraries.rb
180
+ - lib/jekyll/latex/pdf/tikz/utils.rb
177
181
  - lib/jekyll/latex/pdf/utilities.rb
178
182
  - lib/jekyll/latex/pdf/version.rb
179
183
  homepage: https://gitlab.com/grauschnabel/jekyll-latex-pdf
@@ -195,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
199
  - !ruby/object:Gem::Version
196
200
  version: '0'
197
201
  requirements: []
198
- rubyforge_project:
199
- rubygems_version: 2.6.14
202
+ rubygems_version: 3.1.2
200
203
  signing_key:
201
204
  specification_version: 4
202
205
  summary: Crates pdfs using just latex for jekyll posts. (needs kramdown)