Jekyll on Windows: Pygments not working

前端 未结 10 1275
失恋的感觉
失恋的感觉 2020-12-23 20:06

I updated to the latest JekyllBuild (1.0.3) before I always used the RC. After updating the parsing of codes (with Pygments) doesn\'t work anymore. I always get the followin

相关标签:
10条回答
  • 2020-12-23 20:35

    if you add highlighter: false to your config.yml, you can avoid loading Pygments at all

    0 讨论(0)
  • 2020-12-23 20:37

    Expanding upon zzheng's explanation, if you're still having issues try running gem list. Then make sure pygments.rb (0.5.2) isn't installed. If it is, just run this command.

    gem uninstall pygments.rb --version "=0.5.2"
    

    That should take care of your problem, and you should be able to publish with Jekyll happily on Windows once again.

    EDIT: Also, based upon my own experience, this may cause another error. Liquid Error: Failed to get header. in 2013-07-20-post-name-here.md. The (unconfirmed) solution is to install Python 2.7.* if you have not already done so, although some people report that this does not fix the problem.

    Further Reading:

    Jekyll Github Issue #1181

    Pygments.rb Github Issue #45

    Run jekyll --server Failed in Win7

    0 讨论(0)
  • 2020-12-23 20:39

    I know this is answered but sharing my experience. So it appears that the issue lies with pygments.rb of ruby installation. After installing jekyll and trying to run at localhost it would give an error at the default post file. By deleting the syntax highlighting code from the markdown file (see below) and removing the reference of pygments from _config.yml file, I was able to run it on the localhost.

    {% highlight ruby %}
    def print_hi(name) puts "Hi, #{name}" end print_hi('Tom') prints 'Hi, Tom' to STDOUT. {% endhighlight %}

    Remove the striked-out lines

    The changes worked however am yet to figure out if there is a possible way to use the pygments.rb for code highlighting.

    0 讨论(0)
  • 2020-12-23 20:42

    Adding to what @noobcode said, you can actually continue to use pygments.rb if you add the Python27 directory (wherever you stored it) to your path (as another user mentioned in a response to a thread above).

    Those who don't have any idea how to add the directory to their PATH should visit this site.

    0 讨论(0)
  • 2020-12-23 20:44

    Lately, I've found the best way to deploy jekyll or whatever else environment on windows is using http://scoop.sh/ or https://chocolatey.org/.


    This error is mainly for the reason that Windows Shell can not find this command 'which' but Cygwin and MinGW. I think the best solution is modifying the popen.rb

    to this below:

    # Detect a suitable Python binary to use. We can't just use `python2`
    # because apparently some old versions of Debian only have `python` or
    # something like that.
    def python_binary
        if RUBY_PLATFORM =~ /(mswin|mingw|cygwin|bccwin)/
            return 'python'
        end
        @python_binary ||= begin
            `which python2`
            $?.success? ? "python2" : "python"
        end
    end
    

    There are also some details according to This page .

    0 讨论(0)
  • 2020-12-23 20:44

    For me, the fix was to add a symbolic link to python.exe called python2.exe

    Do this, with elevated privileges, in the directory where python 2.x is installed:

    mklink python2.exe python.exe
    
    0 讨论(0)
提交回复
热议问题