add get_lexer_by_doctype

Issue #128 resolved
Former user created an issue

I started playing with this yesterday and I like it very much. it occur to me why not add this? it will be great for all those "Template Language" lexers

what do you think?

Reported by Jorge

Comments (7)

  1. Former user Account Deleted

    I would vote for "wontfix" because it would only affect xml based template languages. But i would like to have something like `guess_lexer` so that it automatically recognizes lexers. Each lexer provides a `analyse_text` method that returns an float between -1 and 1. The lexer with the highest return value wins the battle and lexes the content. If the highest value is -1 then it would use the plain text lexer.

  2. Former user Account Deleted


    by doctype I was referring either to the HTML doctype or a namespace that the engine uses, it depends on the templating engine but it will be (from the lexer's perspective) the same since it's a way to identify the lexer for mix of html+extension.

    @blackbird actually this was step one of my idea, if you look at the current "Filename patterns" and get_lexer_for_filename you will see that those apply only to file extensions.

    so my idea as a whole was as you suggested make a 3th method that will wrap both and will evertually be the guess_lexer you suggested.

    ones this was implemented

  3. Log in to comment