fauno / jekyll-pandoc-multiple-formats

Use pandoc on jekyll to generate posts in multiple formats. Development has moved to https://0xacab.org/edsl/jekyll-pandoc-multiple-formats
https://endefensadelsl.org
Other
88 stars 28 forks source link

Blog post output paths are wrong #9

Closed candlerb closed 10 years ago

candlerb commented 10 years ago

Using the default my-awesome-site jekyll site, with

pandoc:
  skip: false
  output: ./tmp
  outputs:
    pdf:
    epub:

Jekyll creates the required parent directory, e.g. ./tmp/pdf/jekyll/update/2013/11/20, but then tries to write to ./tmp/pdf/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.pdf instead of ./tmp/pdf/jekyll/update/2013/11/20/welcome-to-jekyll.pdf, and hence fails.

$ jekyll build
Configuration file: /Users/brian/tmp/my-awesome-site/_config.yml
            Source: /Users/brian/tmp/my-awesome-site
       Destination: /Users/brian/tmp/my-awesome-site/_site
      Generating... Creating ./tmp/pdf/jekyll/update/2013/11/20
pandoc  -o ./tmp/pdf/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.pdf
pandoc: ./tmp/pdf/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.pdf: openBinaryFile: does not exist (No such file or directory)
Creating ./tmp/epub/jekyll/update/2013/11/20
pandoc  -o ./tmp/epub/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.epub
pandoc: ./tmp/epub/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.epub: openBinaryFile: does not exist (No such file or directory)

done.

Tested with jekyll 1.3.0 under ruby 2.0.0p247

candlerb commented 10 years ago

Here is the result of adding some STDERR.puts lines

base_dir="./tmp"
output="pdf"
File.dirname(post.url)="/jekyll/update/2013/11/20"
post_path="./tmp/pdf/jekyll/update/2013/11/20"
Creating ./tmp/pdf/jekyll/update/2013/11/20
filename="/jekyll/update/2013/11/20/welcome-to-jekyll.pdf"
filename_with_path="./tmp/pdf/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.pdf"
pandoc  -o ./tmp/pdf/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.pdf
pandoc: ./tmp/pdf/jekyll/update/2013/11/20/jekyll/update/2013/11/20/welcome-to-jekyll.pdf: openBinaryFile: does not exist (No such file or directory)

This simple fix makes it work:

--- a/lib/jekyll-pandoc-multiple-formats.rb
+++ b/lib/jekyll-pandoc-multiple-formats.rb
@@ -27,7 +27,7 @@ class PandocGenerator < Generator
         # Have a filename!
         filename = "#{post.url.gsub(/\//, "-").gsub(/-$/, "")}.#{output}" if filename =~ /\/$/

-        filename_with_path = File.join(post_path, filename)
+        filename_with_path = File.join(base_dir, output, filename)

         # Special cases, stdout is disabled for these
         if ['pdf', 'epub', 'odt', 'docx'].include?(output)

but I can't see how it could have worked before without this.

fauno commented 10 years ago

thanks! if you do the pull request(s) i'll merge your changes :)

vhuber commented 8 years ago

Is there any pull request done @fauno @candlerb ?

candlerb commented 8 years ago

This is someone else's code which, as I said, I don't understand why it was written the way it was. I think the author needs to make a decision as to whether the frig patch I made is in fact the correct solution, or there is something else underlying which needs to be changed.

fauno commented 8 years ago

the patch is already applied

https://github.com/fauno/jekyll-pandoc-multiple-formats/blob/master/lib/jekyll-pandoc-multiple-formats.rb#L21

i guess since it was so simple i just went ahead and applied it

http://librevpn.org.ar