File format guessing from vim modelines

Issue #796 new
Michał Górny created an issue

I believe that pygments could benefit if it were able to find vim (and possible other kinds of) modelines in files and prefer the information supplied in them over language autodetection.

I would be happy to write some code for this but I'd like to get a few tips on how would you like such a feature implemented. Most importantly, whether you would prefer the modeline parsing code in pygments itself or should I start working on a separate (and more complete) modeline parsing module for Python.

I'd also like to know how best to plug it into Pygments. It'd be probably a good idea to add an additional (optional) property to various syntaxes, specifying the 'vim names' for them.

Comments (3)

  1. Michał Górny reporter

    I've started some work on the topic, and I have created an initial version of modeline parser at pymodeline.

    I'm still not sure how to put it into the workflow. It would probably be beneficial in `guess_lexer()`, and maybe should have a function for itself. For `get_lexer_for_filename()` it would be beneficial probably only if more than one supported format used the same suffix.

  2. Log in to comment