Introducing EE-Syntax

Oct 03 2011 | 3 Responses

EE-Syntax is a code syntax highlighter for ExpressionEngine 2. EE-Syntax is a server side parser that uses Geshi for the highlighting so it supports any language that Geshi supports over 190 different programming languages. The specific goal with EE-Syntax was to enable me to write about code and since ExpressionEngine didn't have a server side syntax parser for ExpressionEngine 2 it just made sense to write a module.

EE-Syntax is a fork of WP-Syntax, the WordPress plugin, and hence is licensed under the GPL. Because it's built using WP-Syntax conventions any WordPress site that uses that plugin can have it's data imported into ExpressionEngine and have EE-Syntax still format and style their code without any issues.

Note that this is more a soft release right now; because this a 100% free and GPL licensed add-on it's taking a little bit of time to do an official release with it's own section and documentation sections with this site. For now, please use the below as a base.

Usage Example

EE-Syntax works by using template tags combined with HTML markup within an entry. For the template, you wrap the code you want to highlight like the below:

{exp:ee_syntax:add_head} 
{exp:ee_syntax:filter}
	{content_with_code}
{/exp:ee_syntax:filter}
Note that the {exp:ee_syntax:add_head} tag is used to include a default CSS style sheet. If you have your own CSS file you'll be using you can omit that tag.

Then, within your entries, you'll want to ensure the formatting is set to None and mark up your code like the below:

1
2
3
4
5
6
7
8
9
10
<pre lang="php" line="1">
if($foo)
{
 
}
elseif($bar)
{
 
}			   
</pre>

Download

Ee syntax.1.0

Author: Eric Lamb

Eric is the CTO and founder of mithra62. He has been writing his own blog since 2008 and has been involved with the php community for years before that working within the entertainment industry.

Enjoyed this Post? Share it!

Share on Facebook Tweet This!

3 Comments

  1. John Faulds says:

    Hi Eric,

    I’m trying this out and have a small problem when trying to display ExpressionEngine code in that it turns all the { and } into entities &#123; and &#125;. I’m also getting {path=/{url_title}} outputting http://siteurl.com/{url_title} but that seems to be an EE problem as I get that whether I’m using {exp:ee_syntax:filter} or not.

  1. Eric Lamb says:

    Hi John,

    To encode EE tags you set the lang parameter to “ee”. Any others will attempt to encode them smile

    Eric

  1. funplayz says:

    thanks, been searching your idea. its nice that it was clarified well in this article. thanks for sharing admin.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">