Solved

Colorize code

Posted on 2014-02-02
6
320 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

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

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 33

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 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