x

Prettifying code to give it the same colourization as SSMS

How can you prettify SQL code correctly with this site?

I'm a great fan of color-coding SQL so that it looks just like it does in SSMS. I've pored through the various help texts, but it looks to me as it is not possible with this site or in Stack Overflow. If someone can come up with an answer it would be great. I'll certainly alter the Prettifier to do it.

more ▼

asked Oct 11, 2009 at 07:57 PM in Default

Phil Factor gravatar image

Phil Factor
3.8k 8 9 16

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

I believe that we've managed to get the code formatting on the main SSC site working reasonably well now (albeit with maybe one or two issues still outstanding). We have a fair amount of control over this site though, so we ought to be able to substitute the javascript that causes the code to be highlighted with the one we've been using fairly successfully, including the CSS that will style it more like management studio.

more ▼

answered Oct 12, 2009 at 03:46 AM

Melvyn Harbour 1 gravatar image

Melvyn Harbour 1 ♦♦
1.4k 18 20 22

Yes, once things have settled down, it would be great to get this going. After all, we are a SQL site!
Oct 12, 2009 at 05:33 AM Phil Factor
Right. Now we have a new site with the friendly and competent people at OSQA to help, what about getting the colorizing stuff out of SSC into ASK?
Jun 29, 2010 at 02:21 PM Phil Factor
(comments are locked)
10|1200 characters needed characters left

Phil:

The SO code allows very limited formatting control, in large part because it already highlights & colorizes code blocks, like so:

    protected char LA(int count)
    {
        if (_pos + count >= _data.Length)
            return _EOF;
        else
            return _data[_pos + count];
    }

However, as you know by now, it only works right on C-style syntax (C, C++, C#, Java, etc.), because of the persuasive belief by many who code exclusively in these languages that this list "covers just about everything".

Frankly, and IMHO, this is a problem with the software product being used here, and Redgate and the other SQL sites using it should take this back to them and tell them to make it work correctly for SQL code.

more ▼

answered Oct 11, 2009 at 09:57 PM

RBarryYoung gravatar image

RBarryYoung
782 5 5 8

Yes, Barry. For some reason, I find it far easier to read code if it is colorized exactly the same way as SSMS/QA. I think I've just been staring at SQL Server code for too many years. I'm hoping that the Web Team for SQL Server Central will be able to add their work to this site.
Oct 12, 2009 at 05:36 AM Phil Factor
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x985
x148
x125
x28
x2

asked: Oct 11, 2009 at 07:57 PM

Seen: 2195 times

Last Updated: Feb 17, 2010 at 07:27 AM