0

I have a Blog, I want to Auto-Colorize its codes when I post something in HTML/CSS/Javascript/Jquery etc.. Just like Stackoverflow I know I'm a worst explainer, let me try it.. like this, its automatically colorize the script..

<style type='text/css'>
img.opacity {
    opacity: 0.5;
    filter: alpha(opacity=50);
    -webkit-transition: opacity 1s linear;
}
img.opacity:hover {
    opacity: 1;
    filter: alpha(opacity=100);
    -webkit-transition: opacity 1s linear;
}
</style>

I want this feature on my Blog, can you help me please?? This is my Blog: http://kownleg.blogspot.com/

Spectre87
  • 2,374
  • 1
  • 24
  • 37
RJ Style
  • 111
  • 1
  • 2
  • 11
  • Google "javascript code colorization plugins". There are many available solutions. – Denys Séguret Jul 10 '12 at 10:26
  • possible duplicate of [Syntax highlighting code with Javascript](http://stackoverflow.com/questions/160694/syntax-highlighting-code-with-javascript) – Quentin Jul 10 '12 at 10:47

4 Answers4

1

You will need to parse the text, and based on keywords, syntax etc colour your code using css.

An example of this would be JavaToHTML which uses Java to convert a Java file to HTML. It may be worth reading up on this and seeing how it works.

Jon Taylor
  • 7,865
  • 5
  • 30
  • 55
1

I always use the Google Code Prettify

Oswaldo Acauan
  • 2,730
  • 15
  • 23
0

take a look at this http://www.webdesignbooth.com/9-useful-javascript-syntax-highlighting-scripts/

LorDex
  • 2,591
  • 1
  • 20
  • 32
0

You should take a look at CodeMirror. It works amazingly well and I'm pretty sure Stack Overflow uses it.

EDIT: I was wrong. Stack Overflow uses something else. Anyway, CodeMirror is extremely popular and you should have a look at it.

Community
  • 1
  • 1
Rudolph Gottesheim
  • 1,671
  • 1
  • 17
  • 30