jekyll-pandoc-multiple-formats 0.2.8

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae4f204b25da48bf23c3cc6415a023adf413dc23
4
+ data.tar.gz: f8d4adf58a8aa816fc875f2f1707c919206657aa
5
+ SHA512:
6
+ metadata.gz: e98d40eb67505688a4f1f5fa753471b6b9f62e2d652e7a788d425df2ee8e83d56cbf7e6aa0e5fa4ecf609e39e7bbdfb3097808b7609aeeee5d4794e99600f1f3
7
+ data.tar.gz: 7be4cf3f2dd1199720c40d8999740177392e0839367e246df0b8da70babb9363b065de48d4e25958414a3fd96b4e309741cb769ff7e24bf72923bd7222a27f72
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ Y&� &_�4_b ��� ��mw�4h���ga~�;��DF��R�}�7��I�=p
data.tar.gz.sig ADDED
@@ -0,0 +1,3 @@
1
+ O� 'i�S�VF7�U�:in��n�ht�Y�)D ���6xa�i�5� i�72�T�\|���3�Eם�[�9&��٪�Zg�nY�Z9�s4���
2
+ |0V|��_�F%���p!����Zhz�i ��Y�}a,hz =Q��<ʟ�3����eG��^�BfСOo����nD�G����?+q���蟟!�9S������K�Sh
3
+ x��+��J�b������2��@��+'t��� �ybږ��E���}�U
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ test/destination/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
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.
data/README.md ADDED
@@ -0,0 +1,183 @@
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
+
45
+ flags: '--smart'
46
+ site_flags: '--toc'
47
+ outputs:
48
+ latex:
49
+ pdf: '--latex-engine=xelatex'
50
+ epub: '--epub-chapter-level=2'
51
+
52
+ ```
53
+
54
+ * `markdown: pandoc` will instruct jekyll to use the pandoc html
55
+ converter.
56
+
57
+ * `skip` allows you to skip the other formats generation and proceed with the
58
+ regular jekyll site build.
59
+
60
+ * `site_flags` are flags applied to the html generation
61
+
62
+ * `flags` is a string with the flags you will normally pass to `pandoc` on cli.
63
+ It's used on all output types.
64
+
65
+ * `outputs` is a hash of output formats (even markdown!). You can add
66
+ output-specific flags.
67
+
68
+ * `imposition` creates ready to print PDFs if you're creating PDF
69
+ output.
70
+
71
+ * `binder` creates ready to print PDFs
72
+
73
+ * `bundle_permalink` is the path of the bundled articles
74
+
75
+ * `papersize` is the page size for PDF
76
+
77
+ * `sheetsize` is the page size for ready the print PDF
78
+
79
+ * `covers_dir` the directory where covers are stored
80
+
81
+ **IMPORTANT**: As of version 0.1.0 the syntax of the config changed.
82
+ Please upgrade your `_config.yml` accordingly.
83
+
84
+
85
+ ## Front Matter
86
+
87
+ ### Covers
88
+
89
+ Support for epub covers has been added. You can add the path to
90
+ a cover on the front matter of the article to have pandoc add a cover
91
+ image on the epub result.
92
+
93
+ ---
94
+ cover: images/awesome.png
95
+ ---
96
+
97
+ For categories or posts without a cover specified, the plugin looks for
98
+ a PNG file inside the `covers_dir` whose file name will be the
99
+ category/post slug.
100
+
101
+ Since 0.2.0, there's also support for PDF covers. If you have a PNG
102
+ cover, it will get converted to PDF. You can also provide a PDF cover
103
+ as long as it's the same file name as the PNG cover.
104
+
105
+ * Category cover: `assets/covers/the_category_slug.png`
106
+ * PDF cover: `assets/covers/the_slug.pdf`
107
+
108
+ ### Paper sizes
109
+
110
+ For PDFs, each article can have a `papersize` and a `sheetsize`. The
111
+ `papersize` indicates the page size, and the `sheetsize` indicates the
112
+ pages per fold size.
113
+
114
+ Only A* sizes from A7 to A0 are supported for now.
115
+
116
+ ---
117
+ papersize: a5paper
118
+ sheesize: a4paper
119
+ ---
120
+
121
+ This example will generate a 2 pages per A4 sheet.
122
+
123
+ ### Bundled articles
124
+
125
+ If articles share a category, the generator will create a PDF book
126
+ including all of them. The name of the category will become the title
127
+ of the book.
128
+
129
+ ---
130
+ category: [ 'En Defensa del Software Libre #0' ]
131
+ ---
132
+
133
+ The papersize will be the `papersize` of the first article found or the
134
+ default papersize on the `_config.yml` file. Same applies for
135
+ `sheetsize`.
136
+
137
+ NOTE: Authorship will be set to empty. This could change in the future.
138
+
139
+ ## Bibliography
140
+
141
+ If you have bibliography, pandoc recommends leaving an empty
142
+ section at the end of the document if you want to have a separate
143
+ section for it. For bundled articles, this plugin will remove the extra
144
+ sections and create one for everything at the end.
145
+
146
+ # Bibliography
147
+
148
+ <EOF>
149
+
150
+ You can also use the underlined version of the section title (aka
151
+ `settext style` vs `atx style`).
152
+
153
+
154
+ ## Layout
155
+
156
+ Add this liquid snippet on your `_layout/post.html` to generate links to the
157
+ other available formats from the post itself:
158
+
159
+ <ul>
160
+ {% for format in site.pandoc.outputs %}
161
+ {% capture extension %}{{ format | first }}{% endcapture %}
162
+ <li>
163
+ <a href="{{ page.url | remove:'.html' }}.{{ extension }}">
164
+ {{ extension }}
165
+ </a>
166
+ </li>
167
+ {% endfor %}
168
+ </ul>
169
+
170
+ ## How to install
171
+
172
+ Add this snippet to your `_config.yml` on jekyll 1.3
173
+
174
+ gems: [ 'jekyll-pandoc-multiple-formats' ]
175
+
176
+ Alternative, see
177
+ [here](https://github.com/fauno/jekyll-pandoc-multiple-formats/issues/7).
178
+
179
+
180
+ ## How to run
181
+
182
+ Execute `jekyll build` normally :D
183
+
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/, ''}"`
@@ -0,0 +1,30 @@
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/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = 'jekyll-pandoc-multiple-formats'
8
+ gem.version = JekyllPandocMultipleFormats::VERSION
9
+ gem.authors = ['Mauricio Pasquier Juan', 'Nicolás Reynolds']
10
+ gem.email = ['mauricio@pasquierjuan.com.ar', 'fauno@endefensadelsl.org']
11
+ gem.description = %q{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.homepage = 'https://github.com/fauno/jekyll-pandoc-multiple-formats'
17
+ gem.license = 'MIT'
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ['lib']
23
+
24
+ gem.add_dependency('jekyll', '~> 3.3.0')
25
+ gem.add_dependency('pdf_info', '~> 0.5.0')
26
+ gem.add_dependency('rtex', '~> 2.1.0')
27
+ gem.add_development_dependency('rake', '~> 10.5.0')
28
+ gem.add_development_dependency('minitest', '~> 5.8.0')
29
+ gem.add_development_dependency('shoulda', '~> 3.5.0')
30
+ 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/version'
27
+ require 'jekyll-pandoc-multiple-formats/config'
28
+
29
+ # TODO this may go to a separate gem
30
+ require 'jekyll-pandoc-multiple-formats/printer'
31
+ require 'jekyll-pandoc-multiple-formats/imposition'
32
+ require 'jekyll-pandoc-multiple-formats/binder'
33
+ require 'jekyll-pandoc-multiple-formats/unite'
34
+
35
+ require 'jekyll-pandoc-multiple-formats/pandoc_file'
36
+ require 'jekyll-pandoc-multiple-formats/generator'
37
+ require 'jekyll-pandoc-multiple-formats/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