jekyll-latex-pdf 0.4.1 → 0.4.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 +12 -5
- data/Gemfile.lock +2 -2
- data/README.md +74 -12
- data/data/kramdown/apa6.latex +74 -0
- data/jekyll-latex-pdf.gemspec +1 -1
- data/lib/jekyll/latex/pdf/document.rb +1 -1
- data/lib/jekyll/latex/pdf/latex.rb +27 -9
- data/lib/jekyll/latex/pdf/options.rb +33 -10
- data/lib/jekyll/latex/pdf/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3e64ce2d3f03984f249c185edaa31dcdb03270f
|
4
|
+
data.tar.gz: 0a2f6ba85b753252c292d0fc8ebe4d1b32ee3e80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 517ab1602eec6a55fa7ce0db5887885ff1ac9be7a76003d1389d219fdf65ee3a7c7509330b6aa1cbaff6f23eee16ef2424a38e134974eb6600f0f9ff40a9c593
|
7
|
+
data.tar.gz: 40f6b2b970b29046263cccae9a66f40a7e678963dd705e40c19ce01390dc1754f31a2459b4224bfb8a96a4c467a5e247633137a527c63757416725f34d1f0684
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
##
|
4
|
-
|
5
|
-
-
|
6
|
-
-
|
7
|
-
-
|
3
|
+
## [Unreleased]
|
4
|
+
### [0.4.2] - 2019-04-21
|
5
|
+
- Template search routine
|
6
|
+
- apa6 template
|
7
|
+
- some new config variables (see readme)
|
8
|
+
|
9
|
+
## [0.4.1] - 2019-04-19
|
10
|
+
### Fixed
|
11
|
+
- works again with filters on date in jekyll templates.
|
12
|
+
- works again without jekyll-scholar.
|
13
|
+
- wrong extname in some cases.
|
14
|
+
- if permalink is set
|
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.2)
|
5
5
|
jekyll (~> 3.8.5)
|
6
6
|
kramdown (~> 1.17)
|
7
7
|
|
@@ -111,7 +111,7 @@ PLATFORMS
|
|
111
111
|
DEPENDENCIES
|
112
112
|
bundler (~> 1.16)
|
113
113
|
jekyll-latex-pdf!
|
114
|
-
jekyll-scholar
|
114
|
+
jekyll-scholar (~> 5.14.1)
|
115
115
|
method_source (~> 0.8.2)
|
116
116
|
pry
|
117
117
|
pry-doc (~> 0.6.0)
|
data/README.md
CHANGED
@@ -63,18 +63,80 @@ pdf:
|
|
63
63
|
template: myowntemplate
|
64
64
|
```
|
65
65
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
66
|
+
All this variables can also be adjusted in the yaml header of your post.
|
67
|
+
|
68
|
+
Variables to customize are:
|
69
|
+
- *pdf_engine*: Defaults to `lualatex` and can be changed to pdflatex, xelatex,
|
70
|
+
...
|
71
|
+
- *bib_engine*: Defaults to `biber` and is only used if the
|
72
|
+
(jekyll-scholar)[https://github.com/inukshuk/jekyll-scholar] is present and
|
73
|
+
enabled in your `_config.yml` file. biber is part of biblatex, which is
|
74
|
+
used by default. If you use bibtex, change this to 'bibtex' instead.
|
75
|
+
- *template*: defaults to `jekyll-latex-pdf` which is a upgraded template from
|
76
|
+
kramdown, but to use title author and date and creates the title. There is
|
77
|
+
also `apa6` present which can be used. See section *apa6* below. If you
|
78
|
+
want to use, and this is why this gem was made, just start with one of this
|
79
|
+
templates from the git repository and save it inside the `template_path`
|
80
|
+
(which defaults to '_latex') folder in your project with the `.latex`
|
81
|
+
extension, and set the template in your `_config.yml`.
|
82
|
+
- *template_path*: defaults to `_latex` and is the path where your custom
|
83
|
+
templates can be stored. It is not used if you use the shipped templates only.
|
84
|
+
|
85
|
+
Just set up a ticket on
|
86
|
+
(issues)[https://gitlab.com/grauschnabel/jekyll-latex-pdf/issues] to add feature
|
87
|
+
requests you need.
|
88
|
+
|
89
|
+
## Customize Templates
|
90
|
+
|
91
|
+
The default template is a good way to start. Copy it to your `_latex` folder,
|
92
|
+
and adjust it. Change the name and set the `template` in your config or the
|
93
|
+
yaml header of your post. Your template in _latex will be prefered to the one
|
94
|
+
shiped with this gem if it has the same name.
|
95
|
+
|
96
|
+
### jekyll-latex-pdf
|
97
|
+
|
98
|
+
This is the default template which was taken from the `kramdown` gem, but added
|
99
|
+
support for author, date and title, which is taken from the header of the post
|
100
|
+
or the _config.yml file. There will also be used `lang` for babel and isodate
|
101
|
+
to support different languages. (Only sv, de and en is supported at the moment,
|
102
|
+
just issue your language if this isn't enaugh.)
|
103
|
+
|
104
|
+
### apa6
|
105
|
+
|
106
|
+
I use the `apa6` template mostly. This requires the `jekyll-scholar` gem to be
|
107
|
+
added to your procject and enabled in the `_config.yml`. A few more variables
|
108
|
+
can be set in the post (or globally in _config.yml). The content of the extra
|
109
|
+
variables will not be parsed with kramdown. You may use latex notation here, or
|
110
|
+
just use plain text. Not documented headers will be directly passed as is like
|
111
|
+
documented in the (apa6
|
112
|
+
class)[http://mirrors.ctan.org/macros/latex/contrib/apa6/apa6.pdf].
|
113
|
+
|
114
|
+
- *abstract*: Add your abstract to the post in the yaml header. Abstract is
|
115
|
+
required for apa, so if it is not present the excerpt will be used. This does
|
116
|
+
not work fine in some cases. If so, put it into the yaml header may help.
|
117
|
+
- *shortitle*
|
118
|
+
- *affiliation*: The authors affiliation is required with the apa6 class.
|
119
|
+
- *note*: apa6 does not support the \date, so you can set the date here if you
|
120
|
+
want to. Use `\printdate{yyyy-mm-dd}`, so its converted to your language.
|
121
|
+
- *date_as_note*: When set to `true` this will add the posts date as note
|
122
|
+
instead of the date.
|
123
|
+
- *authornote*
|
124
|
+
- *keywords*
|
125
|
+
|
126
|
+
## jekyll-scholar integration
|
127
|
+
|
128
|
+
Check the (jekyll-scholar
|
129
|
+
documentation)[https://github.com/inukshuk/jekyll-scholar] to figure out how
|
130
|
+
citation works. Not everything is supported right now, send me an issue if you
|
131
|
+
need a feature which doesn't work correct for you.
|
132
|
+
|
133
|
+
Basically this ignores most of the jekyll-scholar configuration which is just
|
134
|
+
for the webpages it creates. You need to define your citation styles and so on
|
135
|
+
in a customized template.
|
136
|
+
|
137
|
+
## Todo:
|
138
|
+
|
139
|
+
- add cite support in the abstract.
|
78
140
|
|
79
141
|
## Development
|
80
142
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<% data = @converter.options[:data] %>
|
2
|
+
<%
|
3
|
+
encmap = {
|
4
|
+
'UTF-8' => 'utf8x',
|
5
|
+
'US-ASCII' => 'ascii',
|
6
|
+
'ISO-8859-1' => 'latin1',
|
7
|
+
'ISO-8859-2' => 'latin2',
|
8
|
+
'ISO-8859-3' => 'latin3',
|
9
|
+
'ISO-8859-4' => 'latin4',
|
10
|
+
'ISO-8859-5' => 'latin5',
|
11
|
+
'ISO-8859-9' => 'latin9',
|
12
|
+
'ISO-8859-10' => 'latin10',
|
13
|
+
'CP850' => 'cp850',
|
14
|
+
'CP852' => 'cp852',
|
15
|
+
'CP858' => 'cp858',
|
16
|
+
'CP437' => 'cp437',
|
17
|
+
'CP865' => 'cp865',
|
18
|
+
'CP1250' => 'cp120',
|
19
|
+
'CP1252' => 'cp1252',
|
20
|
+
'CP1257' => 'cp1257'
|
21
|
+
}
|
22
|
+
%><%
|
23
|
+
enclang = {
|
24
|
+
'de' => 'ngerman',
|
25
|
+
'sv' => 'swedish'
|
26
|
+
}
|
27
|
+
%>
|
28
|
+
\documentclass[a4paper,jou,biblatex]{apa6}
|
29
|
+
|
30
|
+
\usepackage{amsmath}
|
31
|
+
\usepackage{graphicx}
|
32
|
+
\usepackage[colorinlistoftodos]{todonotes}
|
33
|
+
|
34
|
+
\usepackage{hyperref}
|
35
|
+
\hypersetup{
|
36
|
+
colorlinks,
|
37
|
+
citecolor=black,
|
38
|
+
filecolor=black,
|
39
|
+
linkcolor=black,
|
40
|
+
urlcolor=black
|
41
|
+
}
|
42
|
+
<% if data[:lang] %>
|
43
|
+
\usepackage[<%= enclang[data[:lang]] %>]{babel}
|
44
|
+
\usepackage[<%= enclang[data[:lang]] %>]{isodate}
|
45
|
+
<% end %>
|
46
|
+
|
47
|
+
<% if data[:bibtex_files] %>
|
48
|
+
\usepackage{biblatex}
|
49
|
+
<% data[:bibtex_files].each { |bibfile| %>\addbibresource{<%= bibfile %>}
|
50
|
+
<% } %>
|
51
|
+
<% end %>
|
52
|
+
|
53
|
+
<% if data[:title] %>\title{<%= data[:title] %>}<% end %>
|
54
|
+
<% if data[:author] %>\author{<%= data[:author] %>}<% end %>
|
55
|
+
<% if data[:date_str] %>
|
56
|
+
<% if data[:lang] %>\date{\printdate{<%= data[:date_str] %>}}
|
57
|
+
<% else %>\date{<%= data[:date_str] %>}
|
58
|
+
<% end %>
|
59
|
+
<% end %>
|
60
|
+
|
61
|
+
<% if data[:shorttitle] %>\shorttitle{<%= data[:shorttitle] %>}<% end %>
|
62
|
+
<% if data[:affiliation] %>\affiliation{<%= data[:affiliation] %>}<% end %>
|
63
|
+
<% if data[:abstract] %>\abstract{<%= data[:abstract] %>}<% end %>
|
64
|
+
<% if data[:note] %>\note{<%= data[:note] %>}<% end %>
|
65
|
+
<% if data[:authornote] %>\authornote{<%= data[:authornote] %>}<% end %>
|
66
|
+
<% if data[:keywords] %>\keywords{<%= data[:keywords] %>}<% end %>
|
67
|
+
|
68
|
+
\begin{document}
|
69
|
+
<% if data[:title] %>
|
70
|
+
\maketitle
|
71
|
+
<% end %>
|
72
|
+
|
73
|
+
<%= @body %>
|
74
|
+
\end{document}
|
data/jekyll-latex-pdf.gemspec
CHANGED
@@ -28,7 +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
|
+
spec.add_development_dependency "jekyll-scholar", "~> 5.14.1"
|
32
32
|
|
33
33
|
spec.add_runtime_dependency "jekyll", "~> 3.8.5"
|
34
34
|
spec.add_runtime_dependency "kramdown", "~> 1.17"
|
@@ -8,7 +8,7 @@ module Jekyll
|
|
8
8
|
module Latex
|
9
9
|
module Pdf
|
10
10
|
# The Latex Class will create the tex file and compile it to the pdf file.
|
11
|
-
class Latex
|
11
|
+
class Latex < Jekyll::Document
|
12
12
|
attr_accessor :source, :latex
|
13
13
|
attr_reader :pdf_file
|
14
14
|
def initialize(source, site, options)
|
@@ -17,12 +17,12 @@ module Jekyll
|
|
17
17
|
@bibengine = @options.options[:bib_engine]
|
18
18
|
@site = site
|
19
19
|
|
20
|
-
|
20
|
+
@source = source
|
21
21
|
end
|
22
22
|
|
23
23
|
def prepare_latex
|
24
24
|
TempLiquid.run do
|
25
|
-
liquid_parsed = Liquid::Template.parse(source, :error_mode => :strict)
|
25
|
+
liquid_parsed = Liquid::Template.parse(@source, :error_mode => :strict)
|
26
26
|
unless liquid_parsed.errors.empty?
|
27
27
|
Jekyll.logger.warn("Liquid parse errors", liquid_parsed.errors.join(", "))
|
28
28
|
end
|
@@ -37,7 +37,25 @@ module Jekyll
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def prepare_abstract
|
41
|
+
# only when excerpt is present
|
42
|
+
unless @options.data.key? :abstract
|
43
|
+
Jekyll.logger.debug "Abstract missing. This may be ok for your latex template."
|
44
|
+
if @options.data.key? :excerpt
|
45
|
+
Jekyll.logger.debug "Trying to get the abstract from the excerpt."
|
46
|
+
abstract, _, @source = @source.to_s.partition(excerpt_separator)
|
47
|
+
@options.add_data(:abstract => Kramdown::Document.new(abstract).to_latex)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def prepare_date_as_note
|
53
|
+
@options.add_data(:note => "\\printdate{#{@options.data[:date_str]}}")
|
54
|
+
end
|
55
|
+
|
40
56
|
def prepare
|
57
|
+
prepare_abstract
|
58
|
+
prepare_date_as_note if @options[:date_as_note]
|
41
59
|
prepare_latex
|
42
60
|
|
43
61
|
@tempdir = Dir.mktmpdir("jekyll-latex-pdf")
|
@@ -83,10 +101,10 @@ module Jekyll
|
|
83
101
|
Jekyll.logger.info "jekyll-latex-pdf", "compiling in tempdir: #{@tempdir}"
|
84
102
|
|
85
103
|
status = 0
|
86
|
-
out = ""
|
104
|
+
out = "\n"
|
87
105
|
cmds.each do |cmd|
|
88
106
|
Open3.popen2(*cmd, :chdir => @tempdir) do |_i, oe, t|
|
89
|
-
oe.each { |l| out += l }
|
107
|
+
oe.each { |l| out += l + "\n" }
|
90
108
|
status = t.value
|
91
109
|
end
|
92
110
|
end
|
@@ -96,10 +114,10 @@ module Jekyll
|
|
96
114
|
@pdf_file = File.join(@tempdir, "texput.pdf")
|
97
115
|
else
|
98
116
|
# puts stdout_str
|
99
|
-
Jekyll.logger.
|
100
|
-
Jekyll.logger.
|
101
|
-
Jekyll.logger.
|
102
|
-
Jekyll.logger.
|
117
|
+
Jekyll.logger.error "jekyll-latex-pdf", "Error when trying to run #{@options.options[:pdf_engine]}."
|
118
|
+
Jekyll.logger.error "jekyll-latex-pdf", "status: #{status}"
|
119
|
+
Jekyll.logger.error "jekyll-latex-pdf", "output: #{out}"
|
120
|
+
Jekyll.logger.error "jekyll-latex-pdf", "See #{@tempdir}/texput.log"
|
103
121
|
end
|
104
122
|
status
|
105
123
|
end
|
@@ -6,12 +6,16 @@ module Jekyll
|
|
6
6
|
class Options
|
7
7
|
@@liquid_tags = {}
|
8
8
|
def initialize(*args)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
template_dirname = File.expand_path(File.join(File.dirname(__FILE__),
|
10
|
+
"..", "..", "..", "..",
|
11
|
+
"data", "kramdown"))
|
12
|
+
|
13
|
+
@options = { :pdf_engine => "lualatex",
|
14
|
+
:bib_engine => "biber",
|
15
|
+
:template => File.join(template_dirname, "jekyll-latex-pdf.latex"),
|
16
|
+
:default_template_path => template_dirname,
|
17
|
+
:template_path => "_latex",
|
18
|
+
:date_as_note => false, }
|
15
19
|
|
16
20
|
@data = {}
|
17
21
|
@allowed_keys = @options.keys
|
@@ -24,12 +28,27 @@ module Jekyll
|
|
24
28
|
hashed_args.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v; }
|
25
29
|
end
|
26
30
|
|
31
|
+
def expand_template(template)
|
32
|
+
template.concat(".latex") unless template.end_with?(".latex")
|
33
|
+
end
|
34
|
+
|
35
|
+
def update_template(template)
|
36
|
+
t = expand_template File.expand_path(File.join(@options[:template_path], template))
|
37
|
+
if File.file? t
|
38
|
+
return t
|
39
|
+
else
|
40
|
+
t = expand_template File.expand_path(File.join(@options[:default_template_path], template))
|
41
|
+
if File.file? t
|
42
|
+
return t
|
43
|
+
else
|
44
|
+
Jekyll.warn "jekyll-latex-pdf", "Could not find template #{t}."
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
def add_options(*args)
|
28
50
|
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")
|
32
|
-
end
|
51
|
+
hashed_args[:template] = update_template(hashed_args[:template]) if hashed_args[:template]
|
33
52
|
|
34
53
|
allowed_args = hashed_args.select { |key, _| @allowed_keys.include? key }
|
35
54
|
@options.merge! allowed_args
|
@@ -41,6 +60,10 @@ module Jekyll
|
|
41
60
|
@options
|
42
61
|
end
|
43
62
|
|
63
|
+
def [](key)
|
64
|
+
@options[key]
|
65
|
+
end
|
66
|
+
|
44
67
|
def add_data(*args)
|
45
68
|
@data.merge! hash_args(*args)
|
46
69
|
end
|
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.2
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,16 +98,16 @@ dependencies:
|
|
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:
|
103
|
+
version: 5.14.1
|
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:
|
110
|
+
version: 5.14.1
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: jekyll
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- Rakefile
|
156
156
|
- bin/console
|
157
157
|
- bin/setup
|
158
|
+
- data/kramdown/apa6.latex
|
158
159
|
- data/kramdown/jekyll-latex-pdf.latex
|
159
160
|
- jekyll-latex-pdf.gemspec
|
160
161
|
- lib/jekyll-latex-pdf.rb
|