I was looking around for some stuff, mainly a syntax highlighter and I never came across one so I went ahead and made my own. I have already submitted on EE Plugins page and figured I would post here as well
http://www.codingdesigns.net/ee_plugin_syntax_highlight.zip
It also includes the GeSHi folder which is uploaded to the plugin directory as well.
For the javascript expand/contract ability you need to add
function toggle_visibility(id)
{
var e = document.getElementById(id);
if(e.style.display == 'none')
e.style.display = 'block';
else
e.style.display = 'none';
}
</script>
Usage
{exp:highlight}{body}{/exp:highlight}
Some text in my body and then
<code lang="csharp" line="1" name="Function">
public someCode()
{
string str = "in my body";
}
I know this is a short description but I am still working on it but it works with no problems that I can see right now.
HTH, Jason
Quick question. I am in the process of converting this into true eecode and need some advice. Would everyone want the ability to change all of GeSHi parameters within the {exp}{/exp} tags? Or is this just too much. There really arent a lot of variables, but it can get overwhelming. All the default values automatically take effect if one is not used so it is not a big deal if you don’t set something. Unless it is the lang tag.
Guys/Gals,
If anyone does have a copy would you mind? Our server and backup server crashed due to a power outage and we lost all of our data. Unfortunately, that was the only place I kept this plugin. Yeah, I know, you don’t have to tell me. 😊
Thanks for any help if anyone happens to have it.
Jason
Sounds interesting. But it’s not clear to me what the practical usage for this is. I understand it’s for highlighting some text, right? Can someone explain to me with an example for what problem this fixes or what functionality this adds? I’m genuinely interested in knowing more and it sounds neat, it’s just not clear from the first post and the code in the page what situation I might deploy this for.
GeSHi is fantastic, essentially it allows syntax highlighting for code snippets. This is incredibly useful in posting tutorials or instructions for projects, and syntax highlighting in the appropriate language.
I would recommend that when looking at your site, you decide what features you want then go looking for how to accomplish that - not quite the other way around. Just a comment; not everything is needed on every project, thankfully!
Thanks for the clarification Lisa. Ditto what Victor said. I’m sure that’s great advice for someone still trying to grasp EE so they don’t get overwhelmed but for someone that’s been a part of the forum since 2004 and likes to stay up on what’s new and how to better use EE and contribute to the forum, well, I guess I would disagree here.
Also, I guess I just like to get to know and play around with add-ons and trouble-shoot when needed. shrugs 😊
Ah, well - Victor, just refresh the forums every 30 seconds for about 22,000 posts and you’ll achieve that. winks
nods at Rob - I think that sometimes it’s possible to do too much of that; often if you have no real purpose for something and play with it, one might uh, over-complicate to make room for the new toy. It’s always best to keep it simple; and if you are ever hit with needing functionality that you’re not sure exists - well, just ask!
Cool. No worries.
I’ve been looking into the highlighting functionality for search results as I think EE search capabilities could use some added functionality in that area and the current plugins seem to fail in that area for what I would like to see. That’s what piqued my interest actually. And not knowing if this solution was remotely related because it wasn’t clear from the original post, I did have some interest in knowing more and saying, it sounds “neat” is just my way of being polite in asking for clarification on a post that was not clear to anyone other than those that already knew something about GeSHi.
Not trying to hi-jack this thread; in response to you (who has always been sooo helpful to me in the past), I would just say I would agree to disagree here. 😊
Ah… well, how about asking directly how to achieve that functionality, Rob? Which plugins have you tried? There is Search Marker from silenz, as well as Search Hilite.
The original post does assume that one knows what GeSHi is, certainly, as that has been around for quite awhile - the plugin simply makes it easier to use within ExpressionEngine.
Anyhow, we want to help, that’s why we’re here, but sometimes asking the right question can be difficult, which is why we’re here, as well, and often recommend simple, plain explanations so that we can suggest a solution, rather than untangling one. =)
Wow. Really didn’t realize there was such a demand for this. I just started it up cause I needed something for my site. 😊
However, after speaking with Derrick, he gave me some ideas about making it an extension instead of a plugin so that is what I was up to. However, I soon realized that the GeSHi parser was very slow when parsing code and page load times where very slow. Since then, I have started work on an original piece called Ignite.
Please excuse the horrible page layout but I haven’t got anytime to design my site with working on this extension. You can view it in action at http://www.codingdesigns.net
If at anytime viewing it you don’t see anything it is probably because I am working on it. 😊
The one thing about this compared to GeSHi is that it uses Regex’s to highlight what it needs to. So, once I get the code highlighting part correct, I will then start work on different languages. Right now, I have C++, C#, PHP, ADAB, and ActionScript all working. Another difference is that you will be able to control all of the colors from within your templates area. So instead of having GeSHi automatically put “style” in the tag this uses something of this nature.
<span class="php_function">str_replace(...)</span>
So a CSS file will be included and you can change all of the different classes to what you want them to be. I have been working on this very hard and hopefully will at least be able to get a Beta version up with minimal documentation. Creating a language file is going to be a little advanced but it is that way for a reason.
The script on my site takes approx. .0703 to load the entire page. When I used GeSHi parsing the same exact code it took nearly 4 seconds.
So more to come on this. 😊
Victor,
It will do exactly that. Each language file actually has two different arrays.
$language_regex takes and replaces whatever the user wants to add in there specific to that language. So, in the php languae file I have the following being replace with there ASCII alternative (, ), [, ], {, }, <, > and this holds true to each language.
For instance, C++ uses < > tags as well and your browser will parse them and hide whatever was inside those tags. So in this language file, it replaces the same thing as the PHP file just to be on the safe side.
The second array is the $language array which holds regular expressions on matching things like, quotes, opening/closing tags, comments, and much more. Since each language is different I am doing the hard part of creating the comment’s regex patterns.
Here is an example of a language file for ABAP.
In viewing this language file you can see how easily it is to add keywords. It is; however, a little more difficult to match certain patterns unless you know Regular Expressions. This language is actually a little different than most because it’s single comment starts with double quotes and only uses single quotes for strings. Where you see “abap_comment” this is the CSS class that you will be able to change within your template area for each language so you can easily update colors, font weights, fonts, etc without having to open the language file.
<?php
$language_regex = array();
$language = array(
0 => array(
'single_quotes',
'/\'(\\\\.|[^\']|[^\'$])*\'/',
'abap_string',
null
),
1 => array(
'single_comment',
'/"(\\\\.|[^"]|[^"$])*"/',
'abap_comment',
null
),
2 => array(
'single_comment',
'[\*[^\n]*]',
'abap_comment',
null
),
3 => array(
'delimeters',
'((()|())|([)|(])|(\{)|(\})|(<<)|(>>)|[/\;/])',
'abap_delimeter',
null
),
4 => array(
'operators',
'(([/\=/][/\=/])|([/\!/][/\=/])|([/\>/]|[/\</])|([/\>/][/\=/])|([/\</][/\=/])|
([/\=/])|([/\+/][/\=/])|([/\-/][/\=/])|([/\*/][/\=/])|([/\//][/\=/])|([/\./][/\=/])|([/\%/][/\=/])|
([/\&&/])|([/\||/])|([/\!/])|
([/\+/])|([/\-/])|([/\*/])|([/\/\])|([/\%/]))',
'abap_operators',
null
),
5 => array(
'keywords',
null,
'abap_keywords',
'ADD|ADD-CORRESPONDING|ASSIGN|AT|AUTHORITY-CHECK|BACK|BREAK-POINT|CASE|CHECK|CLEAR|CLOSE|CNT|COLLECT|COMMIT|
COMMUNICATION|COMPUTE|CONCATENATE|CONDENSE|CONSTANTS|CONTINUE|CONTROLS|CONVERT|CREATE|CURRENCY|DATA|DEFINE|
DELETE|DESCRIBE|DETAIL|DIVIDE|DIVIDE-CORRESPONDING|DO|EDITOR-CALL|ELSE|ELSEIF|END-OF-DEFINITION|END-OF-PAGE|
END-OF-SELECTION|ENDAT|ENDCASE|ENDDO|ENDEXEC|ENDFORM|ENDFUNCTION|ENDIF|ENDIFEND|ENDLOOP|ENDMODULE|ENDON|
ENDPROVIDE|ENDSELECT|ENDWHILE|EXEC|EXIT|EXIT FROM STEP LOOP|EXPORT|EXTRACT|FETCH|FIELD-GROUPS|FIELD-SYMBOLS|
FIELDS|FORM|FORMAT|FREE|FUNCTION|FUNCTION-POOL|GENERATE|GET|HIDE|IF|IMPORT|INCLUDE|INFOTYPES|INITIALIZATION|
INPUT|INSERT|LEAVE|LOAD|LOCAL|LOOP|MESSAGE|MODIFY|MODULE|MOVE|MOVE-CORRESPONDING|MULTIPLY|
MULTIPLY-CORRESPONDING|NEW-LINE|NEW-PAGE|NEW-SECTION|ON|OVERLAY|PACK|PARAMETERS|PERFORM|POSITION|PRINT-CONTROL|
PROGRAM|PROVIDE|PUT|RAISE|RANGES|READ|RECEIVE|REFRESH|REJECT|REPLACE|REPORT|RESERVE|RESTORE|ROLLBACK|SCAN|
SCROLL|SEARCH|SELECT|SELECT-OPTIONS|SELECTION-SCREEN|SET|SHIFT|SKIP|SORT|SPLIT|START-OF-SELECTION|STATICS|STOP|
SUBMIT|SUBTRACT|SUBTRACT-CORRESPONDING|SUM|SUMMARY|SUPPRESS|SYNTAX-CHECK|SYNTAX-TRACE|TABLES|TOP-OF-PAGE|
TRANSFER|TRANSLATE|TYPE-POOL|TYPE-POOLS|TYPES|ULINE|UNPACK|UPDATE|WHEN|WHILE|WINDOW|WRITE'
)
);
?>
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.