0

I'm trying to find a pastie like webservice that do perform some kind of automatic language detection (in term of programming language) and does the syntax coloring accordingly.

Most pastie websites do not have this feature I'd really love to have and use.

Thanks !

Oct
  • 1,505
  • 13
  • 18
  • i couldn't find one such site in internet which would auto-detect the pasted script, normally i found is when a script is pasted and the language is set manually the syntax coloring is done accordingly otherwise they just treat them as text/plain only, can u name one site which does it automatically? – cypronmaya Apr 12 '12 at 19:33

2 Answers2

0

Pygments has something close : http://pygments.org/docs/quickstart/#lexer-and-formatter-lookup

>>> from pygments.lexers import guess_lexer, guess_lexer_for_filename

>>> guess_lexer('#!/usr/bin/python\nprint "Hello World!"')
<pygments.lexers.PythonLexer>

Not perfect but quite useful already.

But yeah I share your frustration with paste service, had the same. In my opinion actually the coloration should be done client side.

https://github.com/alexgorbatchev/SyntaxHighlighter http://code.google.com/p/google-code-prettify/

are pretty nice in that regard.

jnrg
  • 1,871
  • 1
  • 11
  • 7
  • Actually linguist has some of this feature too now: https://github.com/github/linguist/tree/master/lib/linguist – Oct Jun 28 '12 at 16:11
0

I've finished to develop my own tool to do that. It's called UU and performs automatic syntax recognition using highlight.js.

  • http://uu.zoy.org is free and encode locally what you paste in your browser before sending it to the server.
  • The API is WIP.
Oct
  • 1,505
  • 13
  • 18