Solved

Colorize code

Posted on 2014-02-02
6
308 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 12

Assisted Solution

by:Phil Phillips
Phil Phillips earned 250 total points
Comment Utility
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
Comment Utility
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 12

Assisted Solution

by:Phil Phillips
Phil Phillips earned 250 total points
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:frugalmule
Comment Utility
hmm can you post an example that I might paste into my gmail?
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 125 total points
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now