Solved

Colorize code

Posted on 2014-02-02
6
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 14

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 14

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
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.

 

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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

626 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