Jekyll:我如何定义自己的方法?
我正在使用 Jekyll (https://github.com/mojombo/jekyll)。我不喜欢写这么多只是为了强调使用 Pygment。目前我有这个:
{% highlight bash %}
$ bash <<( curl https://rvm.io/releases/rvm-install-head)
{% endhighlight bash %}
我希望能够做到:
highlight :bash do
$ bash <<( curl https://rvm.io/releases/rvm-install-head)
end
我该怎么做?
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-install-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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与 Jekyll 无关,更多的是关于 Liquid 模板引擎,杰基尔使用。
如果你真的想要这个功能,最好的选择可能是分叉 Liquid 并在那里进行修改。
但请注意,Liquid/Jekyll 不仅仅解释 Ruby 代码。您可能需要深入研究词法分析/解析,才能使您的示例正常工作,而不会破坏很多其他事情。
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.
Hopefully you can something similar to your text editor of choice.