user225269
user225269

Reputation: 10893

How to make syntax highlighting work in octopress

This is really getting frustrating. I don't know what's wrong with my markdown files as it compiled to html before without any problems but now its giving me this error whenever I run rake generate. Now I mainly use trial and error for every file(30 markdown files) and I test them out one by one if it compiles when I run rake generate

enter image description here

I'm fine with running the same command a hundred times but if I have no idea what is wrong then how can I debug it.

Here are the files that I found to be causing the error:

https://gist.github.com/4307839

https://gist.github.com/4307833

Update

Ok it turns out that this isn't a problem with the syntax, its about the syntax highlighting. When I do something like:

{% codeblock lang:JavaScript %}
console.log(25 + "yoyos"); 
//output: "25yoyos" 
{% endcodeblock %}

It doesn't work. But when I remove the language option:

{% codeblock %}
console.log(25 + "yoyos"); 
//output: "25yoyos" 
{% endcodeblock %}

It works.

I'm getting this error whenever I view the page using rake preview.

Liquid error: No such file or directory - -c “import sys; print ‘%d.%d’ % sys.version_info[:2]”

I already did some research and tried every possible solution on the issues on github.

if (@python.include? 'python2.7') @python = "python27" end

I've installed ruby 1.9.3 via yari and python 2.7.3 via windows installer. Basically everything has gone smoothly when I installed octopress but the syntax highlighting is really giving me a headache. It was even mentioned in this blog post that there's really an issue with the syntax highlighting in windows:

http://blog.zerosharp.com/setting-up-octopress-on-windows/

But nothing works.

I would really appreciate if you can point some of the mistakes that I did there.

Upvotes: 3

Views: 734

Answers (2)

Dan Esparza
Dan Esparza

Reputation: 28385

When faced with a similar choice on my blog, I punted and chose Google Code Prettify hosted on a CDN.

You'll need to insert some code to dynamically add the correct CSS class to your code blocks.

I added the following code to my blog\source_includes\custom\footer.html file:

<script type='text/javascript'>
    $(function() 
    {
        $('pre').addClass('prettyprint');
        prettyPrint();
    })
</script>

Upvotes: 0

cboettig
cboettig

Reputation: 12707

Not a direct answer, but perhaps consider simply switching your markdown parser to redcarpet (in _config.yml, set markdown: redcarpet) and then just use Github-flavored markdown's fenced codeblocks to provide the syntax highlighting?

Support for the latest redcarpet that provides github-flavored markdown was only recently added to Jekyll, so you may need to update your Jekyll gem first. Personally I think it makes much more sense to have posts written in pure markdown than to have to use Liquid for syntax highlighting.

Upvotes: 5

Related Questions