Jekyll:我如何定义自己的方法?

发布于 2024-10-12 14:25:48 字数 382 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哆兒滾 2024-10-19 14:25:48

这与 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.

北城孤痞 2024-10-19 14:25:48

我也不喜欢液体模板语法。但是这个文本伙伴片段(映射到选项卡触发器“代码”)使它不那么痛苦。

{% highlight ${1:bash} %}
$2
{% endhighlight %}

希望您可以使用与您选择的文本编辑器类似的东西。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文