Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 380
  • Last Modified:

Colorize code

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
frugalmule
Asked:
frugalmule
4 Solutions
 
Phil PhillipsDirector of DevOpsCommented:
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
 
frugalmuleAuthor Commented:
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
 
Phil PhillipsDirector of DevOpsCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
frugalmuleAuthor Commented:
hmm can you post an example that I might paste into my gmail?
0
 
Ray PaseurCommented:
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
 
Slick812Commented:
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

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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now