Octopress/Jekyll syntax highlighting: What are the advantages of ``` (backticks) vs. {% codeblock %} (liquid extensions), etc.?
Asked Answered
B

1

8

I'm using Octopress for blogging, but I still haven't quite grasped the difference, if any, between "liquid extension"-style code blocks, using {% codeblock %}, and the more normal markdown-looking code blocks, using backticks, as well as the variations provided my kramdown and other markdown converters. That is:

{% codeblock haskell %}
main = putStrLn "Hello world"
-- liquid style
{% endcodeblock %}

vs.

```haskell
main = putStrLn "Hello world"
-- backtick fencing style (GitHub-flavored)
```

vs.

~~~ haskell
main = putStrLn "Hello world"
-- kramdown's tilde fencing
~~~

vs.

    main = putStrLn "Hello world"
    -- another kramdown style, I think
{:lang="haskell"}

etc.

Octopress provides the {% codeblock %} and backtick versions as "plugins", and they seem to support the same stuff: syntax highlighting, filenames for the code block, URL, etc.

I haven't gotten the kramdown-specific ones to work properly, I think because they depend on coderay or something, which I downloaded but couldn't get to work.

Anyway, here's my question:

Is there any reason to prefer one syntactic style over the other? On the one hand, I like the backtick fencing because it's GitHub-flavored markdown, which I'm used to and which seems "simpler", but on the other hand, the liquid syntax seems more "native" to Octopress.

Any thoughts would be much appreciated. At the moment, my posts have a random combination of styles, and I'd really like to streamline them into one style.

Botel answered 3/3, 2013 at 21:59 Comment(0)
A
6
{% codeblock haskell %}
main = putStrLn "Hello world"
-- liquid style
{% endcodeblock %}

requires Liquid

```haskell
main = putStrLn "Hello world"
-- backtick fencing style (GitHub-flavored)
```

is not "portable"

~~~ haskell
main = putStrLn "Hello world"
-- kramdown's tilde fencing
~~~

is my choice

    main = putStrLn "Hello world"
    -- another kramdown style, I think
{:lang="haskell"}

is outdated

Amateur answered 4/3, 2013 at 7:28 Comment(2)
Thanks - that helps. Unfortunately, I still can't get coderay syntax highlighting to work with Octopress + kramdown ~~~ fencing. I added the relevant parts to _config.yml as well as a _coderay.scss style sheet, but no dice. Is there anything special I have to do to get this working?Botel
Nevermind - figured it out. The trick was to install coderay using bundle rather than directly with gem.Botel

© 2022 - 2024 — McMap. All rights reserved.