I started on a very, very basic m4 lexer, but couldn't get it to work. My issue will probably get ignored, but here you go:
I find the online documentation unhelpful and out of date. I looked at:
The doco mentions a
Makefile, but I couldn't find one. It mentions
__ALL__ but I couldn't find it.
python _mapping.py and somewhere else I found
Would you guys just write a simple "soup to nuts" guide to writing a simple Lexer? How to test it, how to set up some test data. No regexes, just plain old text matching.
from pygments.lexers.agile import PythonLexer from pygments.token import Name, Keyword __all__ = ['M4Lexer'] class M4Lexer(PythonLexer): name = 'M4' aliases = ['m4'] filenames = ['*.m4'] mimetypes = ['text/x-m4'] EXTRA_KEYWORDS = ['divert', 'DNL', 'define'] def get_tokens_unprocessed(self, text): for index, token, value in PythonLexer.get_tokens_unprocessed(self, text): if token is Name and value in self.EXTRA_KEYWORDS: yield index, Keyword.Pseudo, value else: yield index, token, value
giving the line in
'M4Lexer': ('pygments.lexers.m4', 'M4', ('m4',), ('*.m4',), ('text/x-m4',)),