jekyll-latex-pdf 0.4.0 → 0.4.1
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 +7 -0
- data/Gemfile.lock +21 -2
- data/README.md +15 -0
- data/bin/console +6 -4
- data/data/kramdown/jekyll-latex-pdf.latex +4 -4
- data/jekyll-latex-pdf.gemspec +1 -0
- data/lib/jekyll/latex/pdf.rb +4 -1
- data/lib/jekyll/latex/pdf/document.rb +29 -14
- data/lib/jekyll/latex/pdf/generator.rb +3 -0
- data/lib/jekyll/latex/pdf/latex.rb +12 -10
- data/lib/jekyll/latex/pdf/liquid.rb +5 -1
- data/lib/jekyll/latex/pdf/options.rb +39 -42
- data/lib/jekyll/latex/pdf/scholar/bibliography.rb +1 -7
- data/lib/jekyll/latex/pdf/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f526659d863b97cdab1bf626123d0916539ddada
|
4
|
+
data.tar.gz: cd78206e81ad94e8054f6bc6c6262da3ef55d7f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60dd71ecb453764881ea014a8d9aa032812e3db9d5d6ae142bc2c654197192223f5c6728772311956f05e40de609cf72aebfd2f44782d2e01271672b7c17bea
|
7
|
+
data.tar.gz: 2f43ce1f3c4055281974f7c44a4aca4f6639159b94a5b893b38957df449418cb36cdfd9e9e33a64324a978138d6c9d2fc0bbf893d70a1cbb86c718764341e91d
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jekyll-latex-pdf (0.4.
|
4
|
+
jekyll-latex-pdf (0.4.1)
|
5
5
|
jekyll (~> 3.8.5)
|
6
6
|
kramdown (~> 1.17)
|
7
7
|
|
@@ -11,9 +11,20 @@ GEM
|
|
11
11
|
addressable (2.6.0)
|
12
12
|
public_suffix (>= 2.0.2, < 4.0)
|
13
13
|
ast (2.4.0)
|
14
|
+
bibtex-ruby (4.4.7)
|
15
|
+
latex-decode (~> 0.0)
|
16
|
+
citeproc (1.0.9)
|
17
|
+
namae (~> 1.0)
|
18
|
+
citeproc-ruby (1.1.10)
|
19
|
+
citeproc (~> 1.0, >= 1.0.9)
|
20
|
+
csl (~> 1.5)
|
14
21
|
coderay (1.1.2)
|
15
22
|
colorator (1.1.0)
|
16
23
|
concurrent-ruby (1.1.5)
|
24
|
+
csl (1.5.0)
|
25
|
+
namae (~> 1.0)
|
26
|
+
csl-styles (1.0.1.9)
|
27
|
+
csl (~> 1.0)
|
17
28
|
em-websocket (0.5.1)
|
18
29
|
eventmachine (>= 0.12.9)
|
19
30
|
http_parser.rb (~> 0.6.0)
|
@@ -39,9 +50,15 @@ GEM
|
|
39
50
|
safe_yaml (~> 1.0)
|
40
51
|
jekyll-sass-converter (1.5.2)
|
41
52
|
sass (~> 3.4)
|
53
|
+
jekyll-scholar (5.14.1)
|
54
|
+
bibtex-ruby (~> 4.0, >= 4.0.13)
|
55
|
+
citeproc-ruby (~> 1.0)
|
56
|
+
csl-styles (~> 1.0)
|
57
|
+
jekyll (~> 3.0)
|
42
58
|
jekyll-watch (2.2.1)
|
43
59
|
listen (~> 3.0)
|
44
60
|
kramdown (1.17.0)
|
61
|
+
latex-decode (0.3.1)
|
45
62
|
liquid (4.0.3)
|
46
63
|
listen (3.1.5)
|
47
64
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
@@ -49,6 +66,7 @@ GEM
|
|
49
66
|
ruby_dep (~> 1.2)
|
50
67
|
mercenary (0.3.6)
|
51
68
|
method_source (0.8.2)
|
69
|
+
namae (1.0.1)
|
52
70
|
parallel (1.17.0)
|
53
71
|
parser (2.6.2.1)
|
54
72
|
ast (~> 2.4.0)
|
@@ -79,7 +97,7 @@ GEM
|
|
79
97
|
ruby-progressbar (1.10.0)
|
80
98
|
ruby_dep (1.5.0)
|
81
99
|
safe_yaml (1.0.5)
|
82
|
-
sass (3.7.
|
100
|
+
sass (3.7.4)
|
83
101
|
sass-listen (~> 4.0.0)
|
84
102
|
sass-listen (4.0.0)
|
85
103
|
rb-fsevent (~> 0.9, >= 0.9.4)
|
@@ -93,6 +111,7 @@ PLATFORMS
|
|
93
111
|
DEPENDENCIES
|
94
112
|
bundler (~> 1.16)
|
95
113
|
jekyll-latex-pdf!
|
114
|
+
jekyll-scholar
|
96
115
|
method_source (~> 0.8.2)
|
97
116
|
pry
|
98
117
|
pry-doc (~> 0.6.0)
|
data/README.md
CHANGED
@@ -2,6 +2,21 @@
|
|
2
2
|
|
3
3
|
This gem uses kramdown and latex to generate pdf files.
|
4
4
|
|
5
|
+
## Introduction
|
6
|
+
|
7
|
+
I'm using latex for about 20 years now and jekyll for about 4. I like latex and
|
8
|
+
the results we get for text processing. And I like jekyll for its easy process
|
9
|
+
to generate great websites.
|
10
|
+
|
11
|
+
In this project I'll combine the best of both. The kramdown converter which
|
12
|
+
will be used by the most jekyll projects (as far as I know) supports latex.
|
13
|
+
Thats great! But we can get much more out of latex with a view tricks.
|
14
|
+
|
15
|
+
The project grows about the features I use. For example I wrote the optional
|
16
|
+
depencency to [jekyll-scholar](https://github.com/inukshuk/jekyll-scholar). So
|
17
|
+
if it's enabled in your project, we use the latex way of generating bibliography
|
18
|
+
citations. I didn't find any other package which will do so.
|
19
|
+
|
5
20
|
## Installation
|
6
21
|
|
7
22
|
Add this line to your application's Gemfile:
|
data/bin/console
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "jekyll"
|
6
|
+
require "jekyll-scholar"
|
7
|
+
require "jekyll/latex/pdf"
|
6
8
|
|
7
9
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
10
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,5 +13,5 @@ require 'jekyll/latex/pdf'
|
|
11
13
|
require "pry"
|
12
14
|
Pry.start
|
13
15
|
|
14
|
-
require
|
16
|
+
require "irb"
|
15
17
|
IRB.start(__FILE__)
|
@@ -26,7 +26,7 @@ enclang = {
|
|
26
26
|
'sv' => 'swedish'
|
27
27
|
}
|
28
28
|
%>
|
29
|
-
\documentclass{
|
29
|
+
\documentclass{article}
|
30
30
|
<% if RUBY_VERSION >= '1.9' %>
|
31
31
|
\usepackage[<%= encmap[@body.encoding.name] %>]{inputenc}
|
32
32
|
<% else %>
|
@@ -70,11 +70,11 @@ enclang = {
|
|
70
70
|
<% if data[:author] %>
|
71
71
|
\author{<%= data[:author] %>}
|
72
72
|
<% end %>
|
73
|
-
<% if data[:
|
73
|
+
<% if data[:date_str] %>
|
74
74
|
<% if data[:lang] %>
|
75
|
-
\date{\printdate{<%= data[:
|
75
|
+
\date{\printdate{<%= data[:date_str] %>}}
|
76
76
|
<% else %>
|
77
|
-
\date{<%= data[:
|
77
|
+
\date{<%= data[:date_str] %>}
|
78
78
|
<% end %>
|
79
79
|
<% end %>
|
80
80
|
|
data/jekyll-latex-pdf.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency "pry-doc", "~> 0.6.0"
|
29
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
30
30
|
spec.add_development_dependency "rubocop", "~> 0.67"
|
31
|
+
spec.add_development_dependency "jekyll-scholar"
|
31
32
|
|
32
33
|
spec.add_runtime_dependency "jekyll", "~> 3.8.5"
|
33
34
|
spec.add_runtime_dependency "kramdown", "~> 1.17"
|
data/lib/jekyll/latex/pdf.rb
CHANGED
@@ -5,7 +5,10 @@ require "jekyll/latex/pdf/utilities"
|
|
5
5
|
require "jekyll/latex/pdf/liquid"
|
6
6
|
|
7
7
|
# having jekyll-scholar installed?
|
8
|
-
|
8
|
+
if Jekyll.configuration({})["plugins"].include? "jekyll-scholar"
|
9
|
+
require "jekyll/scholar"
|
10
|
+
require "jekyll/latex/pdf/scholar"
|
11
|
+
end
|
9
12
|
|
10
13
|
require "jekyll/latex/pdf/latex"
|
11
14
|
require "jekyll/latex/pdf/document"
|
@@ -10,16 +10,6 @@ module Jekyll
|
|
10
10
|
class Document < Jekyll::Page
|
11
11
|
attr_accessor :source
|
12
12
|
|
13
|
-
def initialize_data(page)
|
14
|
-
self.data = page.data.clone
|
15
|
-
self.content = page.content.clone
|
16
|
-
self.source = page.content.dup
|
17
|
-
page.data["pdf_url"] = url
|
18
|
-
data["html_url"] = page.url
|
19
|
-
data["date"] = data["date"].strftime("%Y-%m-%d")
|
20
|
-
Options.add_data data
|
21
|
-
end
|
22
|
-
|
23
13
|
def initialize(site, page)
|
24
14
|
@site = site
|
25
15
|
@base = site.source
|
@@ -29,16 +19,41 @@ module Jekyll
|
|
29
19
|
@settings = site.config.key?("pdf") ? site.config["pdf"].clone : {}
|
30
20
|
|
31
21
|
process(@name)
|
32
|
-
Options.add_options @settings
|
33
22
|
|
34
|
-
|
23
|
+
self.data = page.data.clone
|
24
|
+
self.content = page.content.clone
|
25
|
+
self.source = page.content.dup
|
26
|
+
page.data["pdf_url"] = url
|
27
|
+
# data["layout"] = layout
|
28
|
+
data["html_url"] = page.url
|
29
|
+
data["date_str"] = data["date"].strftime("%Y-%m-%d")
|
30
|
+
@options = Options.new @settings
|
31
|
+
@options.add_data data
|
32
|
+
|
33
|
+
check_scholar
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_scholar
|
37
|
+
if Jekyll.configuration({})["plugins"].include? "jekyll-scholar"
|
38
|
+
(class <<self; include Jekyll::Scholar::Utilities; end)
|
39
|
+
# getting bibtex files
|
40
|
+
@config = Jekyll::Scholar.defaults.dup
|
41
|
+
@options.add_data(:bibtex_files => bibtex_files.map { |bibfile| File.join(config["source"], bibfile) })
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def permalink
|
46
|
+
data.key? "permalink" ? nil : (data["permalink"] + ext)
|
35
47
|
end
|
36
48
|
|
37
49
|
def write(dest)
|
38
50
|
path = File.join(dest, CGI.unescape(url))
|
39
51
|
|
40
|
-
latex = Latex.new(source, @site)
|
41
|
-
|
52
|
+
latex = Latex.new(source, @site, @options)
|
53
|
+
if latex.compile == 0
|
54
|
+
FileUtils.cp(latex.pdf_file, path)
|
55
|
+
puts "cp", latex.pdf_file, path
|
56
|
+
end
|
42
57
|
end
|
43
58
|
end
|
44
59
|
end
|
@@ -11,9 +11,10 @@ module Jekyll
|
|
11
11
|
class Latex
|
12
12
|
attr_accessor :source, :latex
|
13
13
|
attr_reader :pdf_file
|
14
|
-
def initialize(source, site)
|
15
|
-
@
|
16
|
-
@
|
14
|
+
def initialize(source, site, options)
|
15
|
+
@options = options
|
16
|
+
@engine = @options.options[:pdf_engine]
|
17
|
+
@bibengine = @options.options[:bib_engine]
|
17
18
|
@site = site
|
18
19
|
|
19
20
|
self.source = source
|
@@ -31,7 +32,7 @@ module Jekyll
|
|
31
32
|
Jekyll.logger.warn("Liquid render errors", liquid_parsed.errors.join(", "))
|
32
33
|
end
|
33
34
|
@latex = Kramdown::Document
|
34
|
-
.new(prep_latex,
|
35
|
+
.new(prep_latex, @options.options)
|
35
36
|
.to_latex
|
36
37
|
end
|
37
38
|
end
|
@@ -51,8 +52,8 @@ module Jekyll
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def add_bibliography
|
54
|
-
if
|
55
|
-
|
55
|
+
if @options.data.key? :bibtex_files
|
56
|
+
@options.data[:bibtex_files].each do |bibfile|
|
56
57
|
bibpath = File.join(@tempdir, File.dirname(bibfile))
|
57
58
|
FileUtils.mkdir_p bibpath unless File.directory? bibpath
|
58
59
|
FileUtils.cp(bibfile, bibpath)
|
@@ -61,17 +62,18 @@ module Jekyll
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def prepare_cmds
|
64
|
-
cmds = [[
|
65
|
+
cmds = [[@options.options[:pdf_engine],
|
65
66
|
# "--output-directory=#{@tempdir}",
|
66
67
|
"--output-format=pdf",
|
67
68
|
"--interaction=batchmode",
|
68
69
|
@latexfile,]]
|
69
70
|
# biber if bibfiles given
|
70
|
-
if
|
71
|
-
cmds << [
|
71
|
+
if @options.data.key? :bibtex_files
|
72
|
+
cmds << [@options.options[:bib_engine],
|
72
73
|
File.basename(@latexfile, File.extname(@latexfile)),]
|
73
74
|
cmds << cmds[0]
|
74
75
|
end
|
76
|
+
cmds
|
75
77
|
end
|
76
78
|
|
77
79
|
def compile
|
@@ -96,7 +98,7 @@ module Jekyll
|
|
96
98
|
# puts stdout_str
|
97
99
|
Jekyll.logger.debug "jekyll-latex-pdf", "status: #{status}"
|
98
100
|
Jekyll.logger.debug "jekyll-latex-pdf", "output: #{out}"
|
99
|
-
Jekyll.logger.debug "jekyll-latex-pdf", "Error when trying to run #{
|
101
|
+
Jekyll.logger.debug "jekyll-latex-pdf", "Error when trying to run #{@options.options[:pdf_engine]}."
|
100
102
|
Jekyll.logger.debug "jekyll-latex-pdf", "See #{@tempdir}/texput.log"
|
101
103
|
end
|
102
104
|
status
|
@@ -4,58 +4,55 @@ module Jekyll
|
|
4
4
|
module Latex
|
5
5
|
module Pdf
|
6
6
|
class Options
|
7
|
-
# setting default
|
8
|
-
|
9
7
|
@@liquid_tags = {}
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
hashed_args.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
|
24
|
-
end
|
8
|
+
def initialize(*args)
|
9
|
+
@options = { :pdf_engine => "lualatex",
|
10
|
+
:bib_engine => "biber",
|
11
|
+
:template => File.expand_path(
|
12
|
+
File.join(File.dirname(__FILE__), "..", "..", "..", "..",
|
13
|
+
"data", "kramdown", "jekyll-latex-pdf.latex")
|
14
|
+
), }
|
15
|
+
|
16
|
+
@data = {}
|
17
|
+
@allowed_keys = @options.keys
|
18
|
+
|
19
|
+
add_options(*args)
|
20
|
+
end
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
hashed_args[:template].concat(".latex") unless hashed_args[:template].end_with?(".latex")
|
31
|
-
end
|
22
|
+
def hash_args(*args)
|
23
|
+
hashed_args = args.detect { |f| f.class == Hash }
|
24
|
+
hashed_args.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
|
25
|
+
end
|
32
26
|
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
def add_options(*args)
|
28
|
+
hashed_args = hash_args(*args)
|
29
|
+
if hashed_args[:template]
|
30
|
+
hashed_args[:template] = File.expand_path(File.join("_latex", hashed_args[:template]))
|
31
|
+
hashed_args[:template].concat(".latex") unless hashed_args[:template].end_with?(".latex")
|
36
32
|
end
|
37
33
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
allowed_args = hashed_args.select { |key, _| @allowed_keys.include? key }
|
35
|
+
@options.merge! allowed_args
|
36
|
+
add_data(hashed_args.reject { |key, _| @allowed_keys.include? key })
|
37
|
+
end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
39
|
+
def options
|
40
|
+
@options[:data] = @data
|
41
|
+
@options
|
42
|
+
end
|
47
43
|
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
def add_data(*args)
|
45
|
+
@data.merge! hash_args(*args)
|
46
|
+
end
|
51
47
|
|
52
|
-
|
53
|
-
@@liquid_tags
|
54
|
-
end
|
48
|
+
attr_reader :data
|
55
49
|
|
56
|
-
|
57
|
-
|
50
|
+
def self.tags
|
51
|
+
@@liquid_tags
|
58
52
|
end
|
53
|
+
|
54
|
+
def self.register_tag(name, klass)
|
55
|
+
@@liquid_tags[name.to_s] = klass
|
59
56
|
end
|
60
57
|
end
|
61
58
|
end
|
@@ -7,15 +7,9 @@ module Jekyll
|
|
7
7
|
module Scholar
|
8
8
|
class Bibliography < Liquid::Tag
|
9
9
|
include Utilities
|
10
|
-
|
10
|
+
|
11
11
|
def initialize(tag_name, arguments, tokens)
|
12
12
|
super
|
13
|
-
|
14
|
-
# getting bibtex files
|
15
|
-
@config = Jekyll::Scholar.defaults.dup
|
16
|
-
puts "bibtex files", bibtex_files.class
|
17
|
-
Options.add_data(:bibtex_files => bibtex_files.map { |bibfile| File.join(@config["source"], bibfile) })
|
18
|
-
|
19
13
|
@keys = arguments
|
20
14
|
end
|
21
15
|
|
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.4.
|
4
|
+
version: 0.4.1
|
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-04-
|
11
|
+
date: 2019-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.67'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: jekyll-scholar
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: jekyll
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +146,7 @@ extra_rdoc_files: []
|
|
132
146
|
files:
|
133
147
|
- ".gitignore"
|
134
148
|
- ".rubocop.yml"
|
149
|
+
- CHANGELOG.md
|
135
150
|
- CODE_OF_CONDUCT.md
|
136
151
|
- Gemfile
|
137
152
|
- Gemfile.lock
|