Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add smart detection of input language #111

Open
hackonteur opened this issue Jan 30, 2013 · 1 comment
Open

Add smart detection of input language #111

hackonteur opened this issue Jan 30, 2013 · 1 comment
Labels
Milestone

Comments

@hackonteur
Copy link

I would like for coderay to be able to detect the input format by looking at the contents of the file. This would be particularly helpful in conjunction with #110: Add support for input from STDIN; since coderay can't use the file extension in that case.

I have two ideas for how to support this initially:

  • Detect a unified diff style input, for the example of piping a diff to coderay:
diff -U1 foo.txt bar.txt | coderay
  • Add support for Emacs mode hints. So coderay could understand that this means it should treat the input as C:
/* -*- mode: c -*- */
@korny
Copy link
Member

korny commented Feb 13, 2013

I'm trying to understand how Pygments implements this. They seem to send the input to every possible scanner to check and rate it: https://bitbucket.org/birkenfeld/pygments-main/src/157c9feaccb86ac52da3d6b234cad92c85ee419c/pygments/lexers/agile.py?at=default#cl-1008

What do you think about this approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants