Syntax Highlighting Now Available on DIC!

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

75 Replies - 10029 Views - Last Post: 05 October 2008 - 05:08 AM

#-2 skyhawk133   User is offline

  • Head DIC Head
  • member icon

Reputation: 1982
  • View blog
  • Posts: 20,434
  • Joined: 17-March 01

Syntax Highlighting Now Available on DIC!

Post icon  Posted 20 February 2008 - 07:55 PM

Alrighty, EVERYONE has asked for this at least once, and up until now I did not have a good solution, but tonight, I present to you.... syntax highlighting in the forums!

The old [code] tag is still available, but now you can use [code=language] to highlight the code you're posting.

Here's an example:
[code=php]echo 'Hello World';[/code]

Looks like this:

echo 'Hello World';



Or a little better example, this time using "cpp" for the language:

string StringToUpper(string strToConvert)
{//change each element of the string to upper case
for(unsigned int i=0;i<strToConvert.length();i++)
{
strToConvert[i] = toupper(strToConvert[i]);
}
return strToConvert;//return the converted string
}

string StringToLower(string strToConvert)
{//change each element of the string to lower case
for(unsigned int i=0;i<strToConvert.length();i++)
{
strToConvert[i] = tolower(strToConvert[i]);
}
return strToConvert;//return the converted string
}


You MUST type the language in all lower case, and it MUST be one of the following languages:

  • cpp
  • csharp
  • css
  • delphi
  • java
  • jscript
  • php
  • python
  • ruby
  • sql
  • vb
  • xml
So just another example of how to use the new code tag: [code=vb] would highlight Visual Basic, or (I believe) VB.NET, and [code=csharp] will highlight in C# mode.

Go ahead and test it out in this thread, and start using it when you post!!!

Enjoy.
Was This Post Helpful? 0
  • +
  • -

#-1 csmanoj   User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 150
  • Joined: 06-August 07

Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 07:58 PM

Oh wow that's awesome!

int SayIt(int number)
{
    int i = number;
    string s = "Great feature";
    while(i>0)
    {
        cout<<s<<endl;
        i--;
    }
    cout<<"I've said it "<<number<<" times.\n";
    return 0;
}


This post has been edited by csmanoj: 20 February 2008 - 08:04 PM

Was This Post Helpful? 0
  • +
  • -

#0 Louisda16th   User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 08:00 PM

Yay! Finally its here! This is something I've been looking forward to. Great work Chris. :)
Was This Post Helpful? 0
  • +
  • -

#1 RodgerB   User is offline

  • D.I.C Lover
  • member icon

Reputation: 66
  • View blog
  • Posts: 2,284
  • Joined: 21-September 07

Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 08:04 PM

Thanks very much for this, it was a much needed feature (for me anyway, it really helps me to be able to read code with colour). :)

While i < 5
    Console.WriteLine("LOLZ")
    i += 1
End While



Ah the fun.
Is This A Good Question/Topic? 0
  • +

Replies To: Syntax Highlighting Now Available on DIC!

#2 Mikhail   User is offline

  • Bastard Operator From Hell
  • member icon

Reputation: 59
  • View blog
  • Posts: 1,378
  • Joined: 26-October 07

Re: Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 08:09 PM

It does work! Thanks to whoever made this.

#include <stdio.h>

int main(void)
{
     printf ("Hello World \n");

     return 0;
} 

Was This Post Helpful? 0
  • +
  • -

#3 Nykc   User is offline

  • Gentleman of Leisure
  • member icon

Reputation: 740
  • View blog
  • Posts: 8,654
  • Joined: 14-September 07

Re: Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 08:10 PM

document.write('This is pretty slick');


This post has been edited by Nykc: 20 February 2008 - 08:12 PM

Was This Post Helpful? 0
  • +
  • -

#4 Louisda16th   User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 08:17 PM

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim n As Integer  'Number of rows
        Dim i As Integer, j As Integer  'Counters
        Dim term As Integer

        Dim CurrRow() As Integer       'Current Row
        Dim NextRow() As Integer       'Next Row

        n = Val(InputBox("Enter number of rows"))

        ReDim CurrRow(2)
        ReDim NextRow(3)
        CurrRow(1) = 1

        For i = 1 To n
            TextBox1.Text += Space(n - i)
            For j = 1 To i
                term = CurrRow(j - 1) + CurrRow(j)
                TextBox1.Text += Str(term)
                NextRow(j) = term
            Next j
            TextBox1.Text += vbNewLine
            ReDim CurrRow(i + 2)
            CurrRow = NextRow
            ReDim NextRow(i + 3)
        Next i
    End Sub


I llove this :D!
Was This Post Helpful? 0
  • +
  • -

#5 bhandari   User is offline

  • D.I.C Addict
  • member icon

Reputation: 9
  • View blog
  • Posts: 754
  • Joined: 31-January 08

Re: Syntax Highlighting Now Available on DIC!

Posted 20 February 2008 - 11:17 PM

System.out.println("Is this really good");


yes it is....
Was This Post Helpful? 0
  • +
  • -

#6 TheMagnitude   User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 144
  • Joined: 12-January 08

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 12:22 AM

Nice work!!!!
Was This Post Helpful? 0
  • +
  • -

#7 PennyBoki   User is offline

  • D.I.C Lover
  • member icon

Reputation: 55
  • View blog
  • Posts: 2,345
  • Joined: 11-December 06

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 12:32 AM

It looks really cool. But I have a question though, when we ask new users to use code tags, should we ask them to use syntax highlighting or just the plain old :code:?

I think only the answerers of the questions will use this feature. Anyways it looks cool like this, I like it :)
Was This Post Helpful? 0
  • +
  • -

#8 Jayman   User is offline

  • Student of Life
  • member icon

Reputation: 423
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 12:38 AM

PennyBoki, as long as they at least use the code tags I don't really care.

The key is just to get them to use them period.
Was This Post Helpful? 0
  • +
  • -

#9 MitkOK   User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 403
  • Joined: 09-August 07

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 01:19 AM

class Welcome

  def sayHello
       puts "Working nice !"
  end

end


Was This Post Helpful? 0
  • +
  • -

#10 Bench   User is offline

  • D.I.C Lover
  • member icon

Reputation: 945
  • View blog
  • Posts: 2,464
  • Joined: 20-August 07

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 02:06 AM

Cool stuff - That helps alot when posting code :)

I'm sure that 99% of the "one-off" posters will still forget to use it, but its great for those of us who post here alot,

One query though - is there a way to let it use a fixed width font? that just makes it a little bit easier to line things up

This post has been edited by Bench: 21 February 2008 - 02:08 AM

Was This Post Helpful? 0
  • +
  • -

#11 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 06:04 AM

for(int i = 0;i < DIC.Length;i++)
{
    Console.WriteLine("You rock Chris!");
}


Was This Post Helpful? 0
  • +
  • -

#12 ajaymatrix   User is offline

  • D.I.C Regular
  • member icon

Reputation: 1
  • View blog
  • Posts: 410
  • Joined: 15-May 07

Re: Syntax Highlighting Now Available on DIC!

Posted 21 February 2008 - 06:31 AM

nice feature..
Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »