jekyll-pandoc-multiple-formats-jekyll34 0.2.10 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +190 -0
- data/Rakefile +13 -0
- data/bin/imponer +62 -0
- data/jekyll-pandoc-multiple-formats-jekyll34-0.2.11.gem +0 -0
- data/jekyll-pandoc-multiple-formats-jekyll34.gemspec +29 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34.rb +37 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/binder.rb +45 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/config.rb +40 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/converter.rb +81 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/generator.rb +110 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/imposition.rb +97 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/pandoc_file.rb +276 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/printer.rb +105 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/unite.rb +70 -0
- data/lib/jekyll-pandoc-multiple-formats-jekyll34/version.rb +3 -0
- data/test/fixtures/test.pdf +0 -0
- data/test/source/_layouts/nil.html +1 -0
- data/test/source/_posts/2014-01-01-test.markdown +10 -0
- data/test/source/_posts/2015-01-01-another_post.markdown +11 -0
- data/test/test_helper.rb +37 -0
- data/test/test_pandoc_file.rb +106 -0
- data/test/test_printer.rb +483 -0
- metadata +38 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f26bdb61d717f7c75c85f2fc8f3e688d76e831f
|
4
|
+
data.tar.gz: 1c071b0ec7c88cb176ccc2a7d6ad56df72fdeb72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '049a1d23a4b3c89cc41cc203b4ee6291768f34b6db8809326d7a397c084b404ec313f79bb60c3720770d98e8cd3cec599db5fb63a5bc41d38f28c825f3c7e37c'
|
7
|
+
data.tar.gz: 477e32477687e9625a87e7e491b5e21f28d5a6071567accfe05570cec162cee4d7646bbafd7856bbf1f9128adfca5a87a471bbdfaf36f517b846b95c46ad0959
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copytight 2017 윤병익 <by_yeun@daum.net>
|
2
|
+
|
3
|
+
Original Authors : Nicolás Reynolds <fauno@endefensadelsl.org>, Mauricio Pasquier Juan <mpj@endefensadelsl.org>, Brian Candler <b.candler@pobox.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,190 @@
|
|
1
|
+
# Another pandoc plugin for jekyll
|
2
|
+
|
3
|
+
This jekyll plugin was inspired by [jekyll-pandoc-plugin][1] but it was changed
|
4
|
+
to generate multiple outputs, rather than just using pandoc to generate jekyll
|
5
|
+
html posts. Besides, it doesn't require the 'pandoc-ruby' gem.
|
6
|
+
|
7
|
+
It's used on [En Defensa del Software Libre][0]. Please check [our
|
8
|
+
repo](https://github.com/edsl/endefensadelsl.org) if you like to see how
|
9
|
+
it works in production.
|
10
|
+
|
11
|
+
[0]: http://endefensadelsl.org
|
12
|
+
[1]: https://github.com/dsanson/jekyll-pandoc-plugin
|
13
|
+
|
14
|
+
|
15
|
+
## What does it do
|
16
|
+
|
17
|
+
It replaces the html generation for pandoc. This means you will have
|
18
|
+
support for pandoc's markdown extensions, like ~strikethrough~ and
|
19
|
+
[@cite], tables and [a lot more stuff](http://pandoc.org/README.html).
|
20
|
+
|
21
|
+
It'll also generate the post in other formats you like, so your
|
22
|
+
blog can be made available in different formats at the same time. Epub
|
23
|
+
for ebook readers, mediawiki for copy&paste to wikis, etc.
|
24
|
+
|
25
|
+
If instructed, this plugin will also generate pdfs in ready for print
|
26
|
+
format.
|
27
|
+
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
Add to `_config.yml`:
|
32
|
+
|
33
|
+
```yaml
|
34
|
+
|
35
|
+
markdown: pandoc
|
36
|
+
pandoc:
|
37
|
+
skip: false
|
38
|
+
bundle_permalink: ':output_ext/:slug.:output_ext'
|
39
|
+
papersize: 'a5paper'
|
40
|
+
sheetsize: 'a4paper'
|
41
|
+
imposition: true
|
42
|
+
binder: true
|
43
|
+
covers_dir: assets/covers
|
44
|
+
signature: 20
|
45
|
+
|
46
|
+
flags: '--smart'
|
47
|
+
site_flags: '--toc'
|
48
|
+
outputs:
|
49
|
+
latex:
|
50
|
+
pdf: '--latex-engine=xelatex'
|
51
|
+
epub: '--epub-chapter-level=2'
|
52
|
+
|
53
|
+
```
|
54
|
+
|
55
|
+
* `markdown: pandoc` will instruct jekyll to use the pandoc html
|
56
|
+
converter.
|
57
|
+
|
58
|
+
* `skip` allows you to skip the other formats generation and proceed with the
|
59
|
+
regular jekyll site build.
|
60
|
+
|
61
|
+
* `site_flags` are flags applied to the html generation
|
62
|
+
|
63
|
+
* `flags` is a string with the flags you will normally pass to `pandoc` on cli.
|
64
|
+
It's used on all output types.
|
65
|
+
|
66
|
+
* `outputs` is a hash of output formats (even markdown!). You can add
|
67
|
+
output-specific flags.
|
68
|
+
|
69
|
+
* `imposition` creates ready to print PDFs if you're creating PDF
|
70
|
+
output.
|
71
|
+
|
72
|
+
* `binder` creates ready to print PDFs
|
73
|
+
|
74
|
+
* `bundle_permalink` is the path of the bundled articles
|
75
|
+
|
76
|
+
* `papersize` is the page size for PDF. You can also use this option on
|
77
|
+
the front matter.
|
78
|
+
|
79
|
+
* `sheetsize` is the page size for ready the print PDF. You can also
|
80
|
+
use this option on the front matter.
|
81
|
+
|
82
|
+
* `covers_dir` the directory where covers are stored
|
83
|
+
|
84
|
+
* `signature` is the amount of pages per fold on the imposition version.
|
85
|
+
Specify `0` for a single fold of all the pages. You can also use this
|
86
|
+
option on the front matter.
|
87
|
+
|
88
|
+
**IMPORTANT**: As of version 0.1.0 the syntax of the config changed.
|
89
|
+
Please upgrade your `_config.yml` accordingly.
|
90
|
+
|
91
|
+
|
92
|
+
## Front Matter
|
93
|
+
|
94
|
+
### Covers
|
95
|
+
|
96
|
+
Support for epub covers has been added. You can add the path to
|
97
|
+
a cover on the front matter of the article to have pandoc add a cover
|
98
|
+
image on the epub result.
|
99
|
+
|
100
|
+
---
|
101
|
+
cover: images/awesome.png
|
102
|
+
---
|
103
|
+
|
104
|
+
For categories or posts without a cover specified, the plugin looks for
|
105
|
+
a PNG file inside the `covers_dir` whose file name will be the
|
106
|
+
category/post slug.
|
107
|
+
|
108
|
+
Since 0.2.0, there's also support for PDF covers. If you have a PNG
|
109
|
+
cover, it will get converted to PDF. You can also provide a PDF cover
|
110
|
+
as long as it's the same file name as the PNG cover.
|
111
|
+
|
112
|
+
* Category cover: `assets/covers/the_category_slug.png`
|
113
|
+
* PDF cover: `assets/covers/the_slug.pdf`
|
114
|
+
|
115
|
+
### Paper sizes
|
116
|
+
|
117
|
+
For PDFs, each article can have a `papersize` and a `sheetsize`. The
|
118
|
+
`papersize` indicates the page size, and the `sheetsize` indicates the
|
119
|
+
pages per fold size.
|
120
|
+
|
121
|
+
Only A* sizes from A7 to A0 are supported for now.
|
122
|
+
|
123
|
+
---
|
124
|
+
papersize: a5paper
|
125
|
+
sheesize: a4paper
|
126
|
+
---
|
127
|
+
|
128
|
+
This example will generate a 2 pages per A4 sheet.
|
129
|
+
|
130
|
+
### Bundled articles
|
131
|
+
|
132
|
+
If articles share a category, the generator will create a PDF book
|
133
|
+
including all of them. The name of the category will become the title
|
134
|
+
of the book.
|
135
|
+
|
136
|
+
---
|
137
|
+
category: [ 'En Defensa del Software Libre #0' ]
|
138
|
+
---
|
139
|
+
|
140
|
+
The papersize will be the `papersize` of the first article found or the
|
141
|
+
default papersize on the `_config.yml` file. Same applies for
|
142
|
+
`sheetsize`.
|
143
|
+
|
144
|
+
NOTE: Authorship will be set to empty. This could change in the future.
|
145
|
+
|
146
|
+
## Bibliography
|
147
|
+
|
148
|
+
If you have bibliography, pandoc recommends leaving an empty
|
149
|
+
section at the end of the document if you want to have a separate
|
150
|
+
section for it. For bundled articles, this plugin will remove the extra
|
151
|
+
sections and create one for everything at the end.
|
152
|
+
|
153
|
+
# Bibliography
|
154
|
+
|
155
|
+
<EOF>
|
156
|
+
|
157
|
+
You can also use the underlined version of the section title (aka
|
158
|
+
`settext style` vs `atx style`).
|
159
|
+
|
160
|
+
|
161
|
+
## Layout
|
162
|
+
|
163
|
+
Add this liquid snippet on your `_layout/post.html` to generate links to the
|
164
|
+
other available formats from the post itself:
|
165
|
+
|
166
|
+
<ul>
|
167
|
+
{% for format in site.pandoc.outputs %}
|
168
|
+
{% capture extension %}{{ format | first }}{% endcapture %}
|
169
|
+
<li>
|
170
|
+
<a href="{{ page.url | remove:'.html' }}.{{ extension }}">
|
171
|
+
{{ extension }}
|
172
|
+
</a>
|
173
|
+
</li>
|
174
|
+
{% endfor %}
|
175
|
+
</ul>
|
176
|
+
|
177
|
+
## How to install
|
178
|
+
|
179
|
+
Add this snippet to your `_config.yml` on jekyll 1.3
|
180
|
+
|
181
|
+
gems: [ 'jekyll-pandoc-multiple-formats' ]
|
182
|
+
|
183
|
+
Alternative, see
|
184
|
+
[here](https://github.com/fauno/jekyll-pandoc-multiple-formats/issues/7).
|
185
|
+
|
186
|
+
|
187
|
+
## How to run
|
188
|
+
|
189
|
+
Execute `jekyll build` normally :D
|
190
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
Bundler.setup(:default, :development, :test)
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/testtask'
|
6
|
+
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.pattern = 'test/**/test_*.rb'
|
10
|
+
test.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => 'test'
|
data/bin/imponer
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Copyright (c) 2012-2015 Nicolás Reynolds <fauno@endefensadelsl.org>
|
3
|
+
# 2012-2013 Mauricio Pasquier Juan <mpj@endefensadelsl.org>
|
4
|
+
# 2013 Brian Candler <b.candler@pobox.com>
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
# a copy of this software and associated documentation files (the
|
8
|
+
# "Software"), to deal in the Software without restriction, including
|
9
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
# the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be
|
15
|
+
# included in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
|
25
|
+
|
26
|
+
file = ARGV.first
|
27
|
+
exit if not File.exist? file
|
28
|
+
|
29
|
+
# Los temporales tiene un sufijo -tmp
|
30
|
+
file_tmp = file.gsub(/\.pdf$/, '-tmp.pdf')
|
31
|
+
# Los definitivos -tmp-imposed
|
32
|
+
file_imp = file.gsub(/\.pdf$/, '-tmp-imposed.pdf')
|
33
|
+
|
34
|
+
# Cantidad de páginas
|
35
|
+
pages = `pdfinfo '#{file}' | grep '^Pages:' | cut -d: -f2 | tr -d ' '`.to_i
|
36
|
+
|
37
|
+
# Encontramos el múltiplo de 4 más cercano a la cantidad de páginas
|
38
|
+
pages4 = ((pages+3)/4)*4.to_i
|
39
|
+
# y luego el múltiplo de 4 más cercano al dividir la cantidad de páginas
|
40
|
+
# por dos (porque cada hoja tiene dos mitades del libro)
|
41
|
+
pages8 = ((pages4/2+3)/4*4).to_i
|
42
|
+
|
43
|
+
# Creamos la imposición de páginas para A5
|
44
|
+
`pdfjam --vanilla \
|
45
|
+
--outfile "#{File.dirname file}" \
|
46
|
+
--paper a5paper \
|
47
|
+
--suffix tmp \
|
48
|
+
--landscape \
|
49
|
+
--signature #{pages4} \
|
50
|
+
"#{file}"`
|
51
|
+
|
52
|
+
# Y luego lo dividimos por la mitad y hacemos 2x2 en A4
|
53
|
+
`pdfjam --vanilla \
|
54
|
+
--outfile "#{File.dirname file}" \
|
55
|
+
--paper a4paper \
|
56
|
+
--suffix imposed \
|
57
|
+
--no-landscape \
|
58
|
+
--signature #{pages8} \
|
59
|
+
"#{file_tmp}"`
|
60
|
+
|
61
|
+
`rm -v "#{file_tmp}"`
|
62
|
+
`mv -v "#{file_imp}" "#{file_imp.gsub /-tmp/, ''}"`
|
Binary file
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'jekyll-pandoc-multiple-formats-jekyll34'
|
8
|
+
gem.version = JekyllPandocMultipleFormats::VERSION
|
9
|
+
gem.authors = ['윤병익']
|
10
|
+
gem.email = ['by_yeun@daum.net']
|
11
|
+
gem.description = %q{This is a fork of the original "jekyll-pandoc-multiple-formats" to update dependencies. This jekyll plugin was inspired by
|
12
|
+
jekyll-pandoc-plugin but it was changed to generate multiple outputs,
|
13
|
+
rather than just using pandoc to generate jekyll html posts. Besides,
|
14
|
+
it doesn't require the 'pandoc-ruby' gem.}
|
15
|
+
gem.summary = %q{Use pandoc on jekyll to generate posts in multiple formats}
|
16
|
+
gem.license = 'MIT'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ['lib']
|
22
|
+
|
23
|
+
gem.add_dependency('jekyll', '>= 3.4')
|
24
|
+
gem.add_dependency('pdf_info', '>= 0.5')
|
25
|
+
gem.add_dependency('rtex', '>= 2.1')
|
26
|
+
gem.add_development_dependency('rake', '>= 12.0.0')
|
27
|
+
gem.add_development_dependency('minitest', '>= 5.10.0')
|
28
|
+
gem.add_development_dependency('shoulda', '~> 3.5.0')
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Copyright (c) 2012-2015 Nicolás Reynolds <fauno@endefensadelsl.org>
|
2
|
+
# 2012-2013 Mauricio Pasquier Juan <mpj@endefensadelsl.org>
|
3
|
+
# 2013 Brian Candler <b.candler@pobox.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
require 'open3'
|
25
|
+
|
26
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/version'
|
27
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/config'
|
28
|
+
|
29
|
+
# TODO this may go to a separate gem
|
30
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/printer'
|
31
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/imposition'
|
32
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/binder'
|
33
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/unite'
|
34
|
+
|
35
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/pandoc_file'
|
36
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/generator'
|
37
|
+
require 'jekyll-pandoc-multiple-formats-jekyll34/converter'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright (c) 2012-2015 Nicolás Reynolds <fauno@endefensadelsl.org>
|
2
|
+
# 2012-2013 Mauricio Pasquier Juan <mpj@endefensadelsl.org>
|
3
|
+
# 2013 Brian Candler <b.candler@pobox.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
module JekyllPandocMultipleFormats
|
25
|
+
class Binder < Printer
|
26
|
+
def initialize(file, papersize = nil, sheetsize = nil, extra_options = nil)
|
27
|
+
super
|
28
|
+
@output_file = file.gsub(/\.pdf\Z/, '-binder.pdf')
|
29
|
+
|
30
|
+
render_template
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_nup
|
35
|
+
@pages.times.map{|i|i+1}.map do |page|
|
36
|
+
sheet=[]
|
37
|
+
@nup.times do
|
38
|
+
sheet << page
|
39
|
+
end
|
40
|
+
|
41
|
+
sheet
|
42
|
+
end.flatten
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module JekyllPandocMultipleFormats
|
2
|
+
class Config
|
3
|
+
DEFAULTS = {
|
4
|
+
'skip' => false,
|
5
|
+
'bundle_permalink' => ':output_ext/:slug.:output_ext',
|
6
|
+
'papersize' => 'a5paper',
|
7
|
+
'sheetsize' => 'a4paper',
|
8
|
+
'imposition' => true,
|
9
|
+
'binder' => true,
|
10
|
+
'signature' => 20,
|
11
|
+
'flags' => '--smart',
|
12
|
+
'site_flags' => '--toc',
|
13
|
+
'outputs' => {},
|
14
|
+
'covers_dir' => 'images/'
|
15
|
+
}
|
16
|
+
|
17
|
+
attr_accessor :config
|
18
|
+
|
19
|
+
def initialize(config = {})
|
20
|
+
@config = Jekyll::Utils.deep_merge_hashes(DEFAULTS, config)
|
21
|
+
end
|
22
|
+
|
23
|
+
def skip?
|
24
|
+
@config['skip']
|
25
|
+
end
|
26
|
+
|
27
|
+
def imposition?
|
28
|
+
@config['imposition']
|
29
|
+
end
|
30
|
+
|
31
|
+
def binder?
|
32
|
+
@config['binder']
|
33
|
+
end
|
34
|
+
|
35
|
+
# TODO magic
|
36
|
+
def outputs
|
37
|
+
@config['outputs']
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|