开发者

How to program Emacs to syntax highlight html character references specified numerically

开发者 https://www.devze.com 2023-03-19 09:56 出处:网络
In html major mode, Emacs is programmed to syntax highlight html character entity references (i.e., character references specified by name, e.g.,  ) but not, for some reason, numeric characte

In html major mode, Emacs is programmed to syntax highlight html character entity references (i.e., character references specified by name, e.g.,  ) but not, for some reason, numeric character references (e.g.,   or &#xa0). I guess this is a special case of the more general problem of customizing syntax highlight in a given mode. I imagine it involves some use of regex开发者_开发技巧es. Can someone give me some guidance on how get started with this?


Following code snippet should help you:

(add-to-list 'sgml-font-lock-keywords-2 
   '("\\&#x?[0-9a-fA-F][0-9a-fA-F]*;?" . font-lock-variable-name-face))

but it should be put after loading of sgml-mode that provides html-mode. You can force loading with following command:

(require 'sgml-mode)
0

精彩评论

暂无评论...
验证码 换一张
取 消