Search code examples
c#javascriptasp.nett-sqlprettify

Given a .SQL file on an internal website, what options are there for pretty formatting on the fly?


So I want to put the files up on my local server, for reference purposes and aside from my regular DVCS because this will turn into training material later. But I want to be able to pretty format the SQL file. (Would be nice if it extended to C# code as well.)

I'm not sure what libraries do this already, and I'm willing to bet there's a Javascript library out there that does EXACTLY what I need.

Needy whiny preferences ;): runs with ASP.NET code, or in a jQuery fashion. eg: given
<div class="tsql">SELECT * FROM ...</div> — then maybe something like? $('.tsql').prettify();

All I want to do is take the existing file, (maybe I'll insert it inline in a code block as indicated above) apply coloring to it, and display it in a browser window. I'm not concerned about reformatting the file for me, I'm not concerned about hotlinking or API references or any of the like.

I would google it but my googlefu is weak today, and I know there are at least five people on stackoverflow that know just what I need.

EDIT: If you feel you have a better answer, feel free to suggest it below, I'm sure others will want to see something similar.


Solution

  • This seems to have C#, SQL, OracleSQL and an easy setup just as you described: http://shjs.sourceforge.net/doc/documentation.html

    Well at least google suggested it as first, hopyfully it won't go crazy with T-SQL :)