Liquid code block formatting (cause it's fun)
Ref:
Formatting liquid code under jekyll using pygment code block is a pain. Mainly due to the { } and %'s. The Jekyll bootstrap has some liquid raw support for this built-in:
- Get your liquid code wanted for posting...
- Replace all the { with |.
- Replace all the } with .|
- wrap the result in { % capture text % } [your code here ]{ % endcapture % }
- include the JB magic... { % include JB/liquid_raw % }
Example:
{% assign sortedPosts = site.posts | sort_by:name %}
Another Way
Yeah... the result can be difficult to accomplish. I personally like ways that keep the text markdown very close to the rendered html. You can accomplish the same affect by code fencing and putting a space between the {. Note: In code fences, we don't need to escape the curly.
Although - the spaces are annoying at least the are consitent; unlike the above JB magic. and the spaces also throw off the pygment syntax highlighting. its a fair compromise for cleaner text.
blog comments powered by Disqus