Welcome to Dream.In.Code
Become an Expert!

Join 136,941 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,862 people online right now. Registration is fast and FREE... Join Now!




Syntax Highlighting Now Available on DIC!

7 Pages V  1 2 3 > »   
Reply to this topicStart new topic

Syntax Highlighting Now Available on DIC!

skyhawk133
20 Feb, 2008 - 06:55 PM
Post #1

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,964



Thanked: 48 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
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:

php
echo 'Hello World';



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

cpp
string StringToUpper(string strToConvert)
{//change each element of the string to upper case
for(unsigned int i=0;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[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.
User is offlineProfile CardPM
+Quote Post

csmanoj
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 06:58 PM
Post #2

D.I.C Head
Group Icon

Joined: 6 Aug, 2007
Posts: 142



Thanked: 3 times
Dream Kudos: 50
My Contributions
Oh wow that's awesome!

cpp

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 Feb, 2008 - 07:04 PM
User is offlineProfile CardPM
+Quote Post

Louisda16th
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 07:00 PM
Post #3

 
Group Icon

Joined: 3 Aug, 2006
Posts: 1,790



Thanked: 1 times
Dream Kudos: 755
My Contributions
Yay! Finally its here! This is something I've been looking forward to. Great work Chris. smile.gif

User is offlineProfile CardPM
+Quote Post

RodgerB
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 07:04 PM
Post #4

D.I.C Lover
Group Icon

Joined: 21 Sep, 2007
Posts: 2,131



Thanked: 17 times
Dream Kudos: 2200
Expert In: Dot Net Technologies

My Contributions
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). smile.gif

vb

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


Ah the fun.
User is offlineProfile CardPM
+Quote Post

Mikhail
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 07:09 PM
Post #5

D.I.C Addict
Group Icon

Joined: 26 Oct, 2007
Posts: 980



Thanked: 1 times
Dream Kudos: 250
My Contributions
It does work! Thanks to whoever made this.

cpp
#include <stdio.h>

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

return 0;
}

User is offlineProfile CardPM
+Quote Post

Nykc
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 07:10 PM
Post #6

sudo rm -R /
Group Icon

Joined: 14 Sep, 2007
Posts: 4,152



Thanked: 16 times
Dream Kudos: 275
My Contributions
jscript

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




This post has been edited by Nykc: 20 Feb, 2008 - 07:12 PM
User is online!Profile CardPM
+Quote Post

Louisda16th
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 07:17 PM
Post #7

 
Group Icon

Joined: 3 Aug, 2006
Posts: 1,790



Thanked: 1 times
Dream Kudos: 755
My Contributions
vb


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 biggrin.gif!
User is offlineProfile CardPM
+Quote Post

bhandari
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 10:17 PM
Post #8

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
java
System.out.println("Is this really good");


yes it is....
User is offlineProfile CardPM
+Quote Post

TheMagnitude
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 11:22 PM
Post #9

D.I.C Head
Group Icon

Joined: 12 Jan, 2008
Posts: 88


Dream Kudos: 125
My Contributions
Nice work!!!!
User is offlineProfile CardPM
+Quote Post

PennyBoki
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 11:32 PM
Post #10

system("revolution");
Group Icon

Joined: 11 Dec, 2006
Posts: 2,009



Thanked: 5 times
Dream Kudos: 500
Expert In: Java,C++,C

My Contributions
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.gif?

I think only the answerers of the questions will use this feature. Anyways it looks cool like this, I like it smile.gif
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Syntax Highlighting Now Available On DIC!
20 Feb, 2008 - 11:38 PM
Post #11

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,959



Thanked: 43 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
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.
User is offlineProfile CardPM
+Quote Post

MitkOK
RE: Syntax Highlighting Now Available On DIC!
21 Feb, 2008 - 12:19 AM
Post #12

D.I.C Regular
Group Icon

Joined: 9 Aug, 2007
Posts: 314



Thanked: 12 times
Dream Kudos: 250
My Contributions
ruby
class Welcome

def sayHello
puts "Working nice !"
end

end

User is offlineProfile CardPM
+Quote Post

7 Pages V  1 2 3 > » 
Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 11:00PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month