Alright so for my website (I’ve totally revamped it and what not) I want to make a code highlighter for source code / tutorials I’ve posted.
At the moment I’m just using some css:
[CODE]div.code
{
font:1em “Courier New”;
margin: 10px auto 10px auto;
background-color: #FFFFFF;
border: thick solid #555555;
color: #000000;
white-space: pre;
font-size: 12;
}
So the code stays neat and in a box. But what I want to do now is somehow make a small javascript function that scans the text inside the html file etc :
[CODE]<div class=”code”>float TimerTicksPerSecond = 0;
float TimerTicksPerMillisecond = 0;
int value = 0;
std::string s = “hello world”;
</div>
and can format it so float and int is blue, “hello world” is red etc. Be a great help if someone can point me in the right direction. As from the javascript I’ve done myself I can’t see it being to hard. I’m just unsure how to scan for text inside like I have above.
Cheers Myth.