abemedia / jekyll-pdf

Create PDFs from Jekyll pages & documents.
http://abemedia.co.uk/jekyll-pdf/
GNU General Public License v3.0
104 stars 35 forks source link

Infinite loop in generator causes jekyll build to hang indefinitely #9

Open mdaizcorbe opened 7 years ago

mdaizcorbe commented 7 years ago

The following line in generator.rb causes an infinite loop since it is appending an item to the array it is iterating on that meets the condition:

site.pages << Document.new(site, site.source, item) if item.data['pdf']

I found that prepending the item instead seemed to have the desired effect.

abemedia commented 7 years ago

What version of Ruby, Jekyll etc. are you using? This plugin is in use on client websites right now and working...

I have been meaning to release a new version using hooks instead of a generator, just haven't gotten around to it yet.

mdaizcorbe commented 7 years ago

I'm using the following on Windows 7: ruby 2.3.3p222 (2016-11-21 revision 56859) [x64-mingw32] jekyll 3.1.6

I'm not sure what the difference is between site.pages and site.documents but I could imagine if the content to be put into the pdf is in site.documents then this wouldn't be an issue.

lexhl commented 7 years ago

I am also experiencing this issue when trying to generate a PDF for a page

ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16] Jekyll 3.4.3

There seems to be a fix for this in one of the forks https://github.com/magento-mcom/jekyll-pdf/commit/f6b6f9a439a18c8ca61d2abdb773f9ad4349a869

hoijui commented 5 years ago

see https://github.com/abeMedia/jekyll-pdf/issues/24

it also contains mlenkeit's fix for this issue