开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜