Solved

Colorize code

Posted on 2014-02-02
6
327 Views
Last Modified: 2014-02-16
Many message boards and even Gmail (I think?) support some form of tagging "<code>colorize text</code>".  Is it possible to include a colorize me indicator of some sort so that the code gets colorized?
0
Comment
Question by:frugalmule
6 Comments
 
LVL 13

Assisted Solution

by:Phil Phillips
Phil Phillips earned 250 total points
ID: 39828832
There are some javascript libraries out there that can do that.  Two that I know of are:

https://code.google.com/p/google-code-prettify/
http://alexgorbatchev.com/SyntaxHighlighter/
0
 

Author Comment

by:frugalmule
ID: 39828838
Your second option looks pretty good and appears to have some standardization behind it.  It is a zip file on this download page http://alexgorbatchev.com/SyntaxHighlighter/download/.

How would I implement it on let's say, an email message?
0
 
LVL 13

Assisted Solution

by:Phil Phillips
Phil Phillips earned 250 total points
ID: 39828856
Generally speaking, email clients don't allow javascript.  In that case, you'll have to generate the HTML of the styled code to show to the client.

Assuming you're using php to generate the email, you're looking at using something along these lines:

https://code.google.com/p/hyperlight/
http://qbnz.com/highlighter/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:frugalmule
ID: 39828870
hmm can you post an example that I might paste into my gmail?
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 125 total points
ID: 39829197
Trying to get the email rendering programs to do this may be an impossible task.  There are so many different email rendering engines that you'll be testing and tweaking forever.  A more straightforward way might be to send the client a link to a syntax-highlighted web page on your server.  Most email engines will support hyperlinks, and cause them to be opened in a browser window.  The major browsers are much more consistent and standards oriented than the email engines.

This may also be useful:
http://php.net/manual/en/function.highlight-file.php
0
 
LVL 34

Assisted Solution

by:Slick812
Slick812 earned 125 total points
ID: 39830430
greetings frugalmule, You can do EMAIL code as HTML, and have colored TEXT output in the email output as html, , BUT in this question you do not say what your php code problem is, , , , as you say - "include a colorize me indicator of some sort so that the code gets colorized"
can you tell us about the code you may have problems with that you need us to do code for to get the result as "code gets colorized" ?? ? If you can show us this code, then this may help us to do code for a fix ?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question