有胡须模板语言的任何pygments lexer吗?

发布于 2025-02-07 19:55:00 字数 179 浏览 2 评论 0原文

我想在论文中列出胡子模板的源代码,并且我正在使用铸造的软件包来突出显示我的乳胶源中的代码。铸造的软件包只需使用pygments。但是目前没有任何胡须的lexer。有人知道我的用例简单解决方案吗?例如,是否存在Python中实现的现有胡须Lexer并准备用于Pygments?

任何建议或想法都将不胜感激!

最好,妮可

I'd like to list source code of Mustache templates in my paper, and I'm using the minted package for highlighting code in my LaTeX source. The minted package simply uses Pygments. But there isn't any Pygments lexer for Mustache at the moment. Does anyone know an easy solution for my use case? For example, is there any existing Mustache lexer that is implemented in Python and is ready to use for Pygments?

Any suggestion or thoughts will be highly appreciated!

Best, Nicole

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

倾听心声的旋律 2025-02-14 19:55:00

您可以使用一个车把Lexer,因为车把或多或少是小胡子的超集。我说“或多或少”,因为上次我检查时,车把没有倒置选择。 lay词中的词汇似乎也不支持它们。 If your code uses them, you should be able to easily implement your own Mustache lexer by extending HandlebarsLexer and 车把barshtmllexer 。另请参见 https://pygments.org/docs/lexerdeveveloment/

这是一个示例:

\documentclass[preview]{standalone}

\usepackage[newfloat]{minted}

\begin{document}
\begin{minted}{html+handlebars}
<div id="cart">
  {{#cart_items}}
  <div class="cart-item">
    <span>{{name}}</span>
    <span>{{quantity}}</span>
    <span>{{price}}</span>
  </div>
  {{/cart_items}}
</div>
\end{minted}
\end{document}

将导致:

”示例“

There is already a Handlebars lexer which you can use, as Handlebars is more or less a superset of Mustache. I say “more or less” because, last time I checked, Handlebars did not have Inverted Selections. The lexer in Pygments does not seem to support them, either. If your code uses them, you should be able to easily implement your own Mustache lexer by extending HandlebarsLexer and HandlebarsHtmlLexer. See also https://pygments.org/docs/lexerdevelopment/.

Here is an example:

\documentclass[preview]{standalone}

\usepackage[newfloat]{minted}

\begin{document}
\begin{minted}{html+handlebars}
<div id="cart">
  {{#cart_items}}
  <div class="cart-item">
    <span>{{name}}</span>
    <span>{{quantity}}</span>
    <span>{{price}}</span>
  </div>
  {{/cart_items}}
</div>
\end{minted}
\end{document}

Which results in:

Example

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