Jinja模板语法hilighting

Nil*_*lor 2 emacs syntax-highlighting jinja2

我想调整jinja.el来使用单行注释##.但我对elisp的了解很糟糕.谁能帮我?我想要什么:我想要hilite

## some text
## {% include "_template.html" %}
Run Code Online (Sandbox Code Playgroud)

作为注释掉的字符串.但它的工作并不完全正确.第一行的片段看起来像是注释而第二 - 不是.这是我得到的:

在此输入图像描述

这里是jinja.el的一部分,取自Jinja的git repo加上我的regexp ##:

(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
Run Code Online (Sandbox Code Playgroud)

Nil*_*lor 5

好.我找到了解决方案 更改

'("## ?\\(.*\\)" . (1 font-lock-comment-face))
Run Code Online (Sandbox Code Playgroud)

'("## ?\\(.*\\)" . (1 font-lock-comment-face t))
Run Code Online (Sandbox Code Playgroud)

即将'override'参数设置为true可以解决我的问题.