Jinja 模板语法高亮
我想调整 jinja.el 以使用 ##
处理单行注释。但我对 elisp 的了解很差。谁能帮助我?我想要什么:我想将 hilite
## some text
## {% include "_template.html" %}
作为注释掉的字符串。但它的工作原理并不完全正确。代码片段的第一行看起来像是注释掉了,而第二行则不是。这是我得到的:
这是 jinja.el 的一部分,取自 Jinja 的 git 存储库加上我的 ##
正则表达式:
(defconst jinja-font-lock-keywords
(list
; (cons (rx "{% comment %}" (submatch (0+ anything))
; "{% endcomment %}") (list 1 font-lock-comment-face))
'("{%-?\\|-?%}\\|{{\\|}}" . font-lock-preprocessor-face)
'("{# ?\\(.*?\\) ?#}" . (1 font-lock-comment-face))
'("## ?\\(.*\\)" . (1 font-lock-comment-face))
'("{#\\|#}" . font-lock-comment-delimiter-face)
'("##" . font-lock-comment-delimiter-face)
;; first word in a block is a command
I'd like to adapt jinja.el to work with one-line comments using ##
. But my knowlege of elisp is bad. Who can help me? What do I want: i'd like to hilite
## some text
## {% include "_template.html" %}
as a commented out strings. But it works not fully correct. 1st line of snippet looks like comment out while 2nd - not. Here is what i've got:
And here is a part of jinja.el taken from Jinja's git repo plus my regexp for ##
:
(defconst jinja-font-lock-keywords
(list
; (cons (rx "{% comment %}" (submatch (0+ anything))
; "{% endcomment %}") (list 1 font-lock-comment-face))
'("{%-?\\|-?%}\\|{{\\|}}" . font-lock-preprocessor-face)
'("{# ?\\(.*?\\) ?#}" . (1 font-lock-comment-face))
'("## ?\\(.*\\)" . (1 font-lock-comment-face))
'("{#\\|#}" . font-lock-comment-delimiter-face)
'("##" . font-lock-comment-delimiter-face)
;; first word in a block is a command
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。我找到了解决方案。更改
为
ie 将“覆盖”参数设置为 true 解决了我的问题。
OK. I found solution. Change
to
ie setting 'override' parameter to true solves me question.