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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5696d522098b6d7102e6a018725a5bdbd66fac63
4
- data.tar.gz: 2140c6d7fa8468fb02c1fa16c405ac89c7584298
3
+ metadata.gz: f526659d863b97cdab1bf626123d0916539ddada
4
+ data.tar.gz: cd78206e81ad94e8054f6bc6c6262da3ef55d7f5
5
5
  SHA512:
6
- metadata.gz: abf1490bb38c2f34cda5679dd76309a313dd0636226dcee8a435f81e4d69745df0c10e4bcb648b67605ab24b193a9c4b82e5027818f739fb2d3493a9ae5a7498
7
- data.tar.gz: 21ed7ba16de27881ef3bc2a9db5de399f69faf35d3a34bf10577dd703a4bc13c59b67d28f5cfa02087eb640bfa900e7978c280d84c6fd6136015c4d7dab54714
6
+ metadata.gz: e60dd71ecb453764881ea014a8d9aa032812e3db9d5d6ae142bc2c654197192223f5c6728772311956f05e40de609cf72aebfd2f44782d2e01271672b7c17bea
7
+ data.tar.gz: 2f43ce1f3c4055281974f7c44a4aca4f6639159b94a5b893b38957df449418cb36cdfd9e9e33a64324a978138d6c9d2fc0bbf893d70a1cbb86c718764341e91d
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.4.1
4
+ - Bugfix: works again with filters on date in jekyll templates.
5
+ - Bugfix: works again without jekyll-scholar.
6
+ - Bugfix: wrong extname in some cases.
7
+ - Bugfix: 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.0)
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.3)
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 'bundler/setup'
4
- require 'jekyll'
5
- require 'jekyll/latex/pdf'
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 'irb'
16
+ require "irb"
15
17
  IRB.start(__FILE__)
@@ -26,7 +26,7 @@ enclang = {
26
26
  'sv' => 'swedish'
27
27
  }
28
28
  %>
29
- \documentclass{scrartcl}
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[:date] %>
73
+ <% if data[:date_str] %>
74
74
  <% if data[:lang] %>
75
- \date{\printdate{<%= data[:date] %>}}
75
+ \date{\printdate{<%= data[:date_str] %>}}
76
76
  <% else %>
77
- \date{<%= data[:date] %>}
77
+ \date{<%= data[:date_str] %>}
78
78
  <% end %>
79
79
  <% end %>
80
80
 
@@ -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"
@@ -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
- require "jekyll/latex/pdf/scholar" if Jekyll.configuration({})["plugins"].include? "jekyll-scholar"
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
- initialize_data(page)
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
- FileUtils.cp(latex.pdf_file, path) if latex.compile == 0
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
@@ -4,6 +4,9 @@ module Jekyll
4
4
  module Latex
5
5
  module Pdf
6
6
  class Generator < Jekyll::Generator
7
+ safe true
8
+ priority :lowest
9
+
7
10
  def generate(site)
8
11
  site.posts.docs.each do |post|
9
12
  site.pages << Document.new(site, post) if post.data["pdf"]
@@ -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
- @engine = Options.options[:pdf_engine]
16
- @bibengine = Options.options[:bib_engine]
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, Options.options)
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 Options.data.key? :bibtex_files
55
- Options.data[:bibtex_files].each do |bibfile|
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 = [[Options.options[:pdf_engine],
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 Options.data.key? :bibtex_files
71
- cmds << [Options.options[:bib_engine],
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 #{Options.options[:pdf_engine]}."
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
@@ -23,8 +23,12 @@ module Jekyll
23
23
  end
24
24
  end
25
25
 
26
+ def tmp_keys
27
+ @tmp_keys ||= []
28
+ end
29
+
26
30
  def restore_liquid_tags
27
- @tmp_keys.each do |k|
31
+ tmp_keys.each do |k|
28
32
  if @saved_liquid_tags[k]
29
33
  Liquid::Template.register_tag(k, @saved_liquid_tags[k])
30
34
  else
@@ -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
- @@options = { :pdf_engine => "lualatex",
11
- :bib_engine => "biber",
12
- :template => File.expand_path(
13
- File.join(File.dirname(__FILE__), "..", "..", "..", "..",
14
- "data", "kramdown", "jekyll-latex-pdf.latex")
15
- ), }
16
-
17
- @@data = {}
18
- @@allowed_keys = @@options.keys
19
-
20
- class << self
21
- def hash_args(*args)
22
- hashed_args = args.detect { |f| f.class == Hash }
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
- def add_options(*args)
27
- hashed_args = hash_args(*args)
28
- if hashed_args[:template]
29
- hashed_args[:template] = File.expand_path(File.join("_latex", hashed_args[:template]))
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
- allowed_args = hashed_args.select { |key, _| @@allowed_keys.include? key }
34
- @@options.merge! allowed_args
35
- add_data(hashed_args.reject { |key, _| @@allowed_keys.include? key })
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
- def options
39
- @@options[:data] = @@data
40
- @@options
41
- end
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
- def add_data(*args)
44
- @@data.merge! hash_args(*args)
45
- puts "@@data is now:", @@data
46
- end
39
+ def options
40
+ @options[:data] = @data
41
+ @options
42
+ end
47
43
 
48
- def data
49
- @@data
50
- end
44
+ def add_data(*args)
45
+ @data.merge! hash_args(*args)
46
+ end
51
47
 
52
- def tags
53
- @@liquid_tags
54
- end
48
+ attr_reader :data
55
49
 
56
- def register_tag(name, klass)
57
- @@liquid_tags[name.to_s] = klass
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
- include Jekyll::Scholar::Utilities
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
 
@@ -3,7 +3,7 @@
3
3
  module Jekyll
4
4
  module Latex
5
5
  module Pdf
6
- VERSION = "0.4.0"
6
+ VERSION = "0.4.1"
7
7
  end
8
8
  end
9
9
  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.0
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-18 00:00:00.000000000 Z
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