octopress / codefence

Write beautiful fenced code snippets with in any template.
MIT License
16 stars 16 forks source link

Plugin doesn't seem to work and causes endless regeneration #8

Closed linduxed closed 9 years ago

linduxed commented 9 years ago

If I add some lines to a test blog post like this:

```ruby
require 'something'

(with closing backticks after the require-line, I don't know how to make that appear in this markdown) ...then it will cause the following:

linduxed@computer ❯ bundle exec jekyll serve
Configuration file: /home/linduxed/Documents/blog/_config.yml
            Source: /home/linduxed/Documents/blog
       Destination: /home/linduxed/Documents/blog/_site
      Generating... 
                    done.
 Auto-regeneration: enabled for '/home/linduxed/Documents/blog'
Configuration file: /home/linduxed/Documents/blog/_config.yml
    Server address: http://127.0.0.1:4000/
  Server running... press ctrl-c to stop.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:54 ...done in 0.271644956 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:54 ...done in 0.252244708 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:54 ...done in 0.258697563 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:54 ...done in 0.264106491 seconds.
      Regenerating: 2 file(s) changed at 2015-05-16 16:22:55 ...done in 0.255456769 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:55 ...done in 0.248859985 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:55 ...done in 0.252699799 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:55 ...done in 0.25256642 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:56 ...done in 0.249855767 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:56 ...done in 0.257399454 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:56 ...done in 0.254693863 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:57 ...done in 0.263261802 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:57 ...done in 0.254344753 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:57 ...done in 0.252286845 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:57 ...done in 0.251319978 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:58 ...done in 0.246391523 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:58 ...done in 0.253487809 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:58 ...done in 0.252913958 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:58 ...done in 0.253092253 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:59 ...done in 0.248940986 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:59 ...done in 0.252027992 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:59 ...done in 0.253656358 seconds.
      Regenerating: 1 file(s) changed at 2015-05-16 16:22:59 ...done in 0.254218001 seconds.
      ...

This doesn't stop.

Since I'm on Arch Linux, normally when there are problems and pygments.rb is involved it's just a question of jumping into the gem and tweaking what python is being used (2 or 3), but that was not the case here.

Additionally, If I chage the file into which logging for pygments.rb is done with MENTOS_LOG=/tmp/mentos.log, this results in a ton of output like this:

...
 I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlight in process.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlighting complete.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Out header: {"method":"highlight","args":null,"kwargs":{"formatter":"html","options":{"encoding":"utf-8","outencoding":"utf-8"},"lexer":"rb","fd":10,"id":"VILDIAKO","bytes":1943}}
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Size in: 00000000000000000000000000100110 (39)
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] In header: {"bytes": 9278, "method": "highlight"}

I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlight in process.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlighting complete.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Out header: {"method":"highlight","args":null,"kwargs":{"formatter":"html","options":{"encoding":"utf-8","outencoding":"utf-8"},"lexer":"rb","fd":10,"id":"WOFVGOWC","bytes":1768}}
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Size in: 00000000000000000000000000100110 (39)
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] In header: {"bytes": 8828, "method": "highlight"}

I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlight in process.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlighting complete.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Out header: {"method":"highlight","args":null,"kwargs":{"formatter":"html","options":{"encoding":"utf-8","outencoding":"utf-8"},"lexer":"rb","fd":10,"id":"AHWNHKTH","bytes":530}}
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Size in: 00000000000000000000000000100110 (39)
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] In header: {"bytes": 2466, "method": "highlight"}

I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlight in process.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Highlighting complete.
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Out header: {"method":"highlight","args":null,"kwargs":{"formatter":"html","options":{"encoding":"utf-8","outencoding":"utf-8"},"lexer":"rb","fd":10,"id":"FNWTMJXA","bytes":1943}}
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] Size in: 00000000000000000000000000100110 (39)
I, [2015-05-16 16:21 #5550]  INFO -- : [2015-05-16T16:21:52+02:00] In header: {"bytes": 9278, "method": "highlight"}
...

Clearly, it's doing something, I'm just not sure if it's doing the right thing. No lines with anything else than the INFO log level; it's as if nothing went wrong.

However, the page is indeed generated, it just results in almost unformatted text: ugly_code_blocks

Any help would be appreciated.

imathis commented 9 years ago

Thanks for posting this. I've looked into it, and I'm not sure I can say what the problem is. I can't get it to reproduce locally. You can actually use rouge instead of pygments.rb and avoid the whole python toolchain. Try this out and let me know if it works for you, add this to your Gemfile, bundle install and and try bundle exec jekyll server again.

group :jekyll_plugins do
  gem 'rouge'
end
linduxed commented 9 years ago

The endless regeneration didn't stop, so that makes me think it has something to do with the regeneration triggering itself (or something to that effect).

Additionally, the code wasn't coloured; a new brand of "not coloured" happened instead: white_code_blocks

linduxed commented 9 years ago

Hmm, that was with the gem posix-spawn gem set to = 0.3.8. When I use the latest version of posix-spawn it looks like in the first screenshot.

linduxed commented 9 years ago

Deleting my added codefence in the "Welcome to Jekyll!" post makes it stop regenerating. Note that that post has a {% highlight ruby %} block which works.

Also as a side-note, I noticed that when I save that file (without the codefence) it regenerates twice. When I save with nano instead of vim it only saves once. With that said, even when using nano, if I have the codefence in the code and save, the endless regenerating starts anyway.

imathis commented 9 years ago

I think I've figured out the source of the multiple generation. Add to your Jekyll configuration:

exclude:
  - .code-highlighter-cache

This will be sure that changes to code cache won't trigger regeneration. Let me know if this fixes it for you. I'm going to see if there's a way I can make this plugin automatically add the cache to the exclude list.

imathis commented 9 years ago

I've just released an update to octopress-code-highlighter which shouldn't cause Jekyll watch to unnecessarily build multiple times. Please run bundle update and try this again. It should work without needing to exclude the cache directory.

imathis commented 9 years ago

I'm going to mark this as resolved. Let me know if this is still a problem for you.