Jekyll: How can I define my own method?
I am using Jekyll (https://github.com/mojombo/jekyll). I don't like to have to write so much just to highlight using Pygment. Currently I have this:
{% highlight bash %}
$ bash <<( curl https://rvm.io/releases/rvm-inst开发者_StackOverflow中文版all-head)
{% endhighlight bash %}
I want to be able to do:
highlight :bash do
$ bash <<( curl https://rvm.io/releases/rvm-install-head)
end
How can I do this?
This is less about Jekyll, and more about the Liquid Templating Engine, which Jekyll uses.
If you really want that feature, the best option is likely to fork Liquid and make the modifications there.
Note, though, that Liquid/Jekyll doesn't just interpret Ruby code. You'll likely have to dig pretty deep into the lexical analysis/parsing to get your example to work correctly without breaking a lot of other things.
I'm not so fond of the liquid templating syntax either. But this textmate snippit (mapped to the tab trigger 'code') makes it a bit less painful.
{% highlight ${1:bash} %}
$2
{% endhighlight %}
Hopefully you can something similar to your text editor of choice.
精彩评论