We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Code Highlighter Extension

Development and Programming

Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Well I am finally getting around to zipping this up for everyone to test out. It is getting there but I just haven’t had time to finish it all up. I still have one proble to correct which is highlighting things like “is” inside of “list”. Once I get that worked out it will be much better.

This is a beta version so as with all beta’s please provide feedback.

All highlighting is done through the use of stylesheets and a naming convention of your choice. For instance, in my ignite_cpp.php file, I have that the class for strings will be called cpp_strings. Then, in my stylesheet I have

.cpp_strings { color: green; }

which will highlight all strings green. This is to prevent you from having to go into the php files to change something so simple.

If you have any questions please let me know and sorry about the small help file but time always gets the best of us.

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

Great will try it out for you!

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

Jason, I have installed the extension fine although I have a problem. Maybe I missed something.

In my entry I have

[ code lang="php" line_start="2"]
<?php
echo “test”;
?>
[ /code]

when rendered I receive

Notice: Undefined variable: code in /extensions/ext.ignite.php on line 155

and my rendered code has the background image aswell as the line numbers but no highlighting. My source looks like so with gobbled code

<div class='php' id='code'><span class='number'>2</span> 38897477e41c4be3c6
<span class='number'>3</span> 1869477e41c4bf3bc “test”;
<span class='number'>4</span> 22805477e41c4bebc4
</div>

Any help would be great thanks

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Thanks for that. Try this update.

Just changed the $code variable to $retCode.

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

Thanks, that has gotten rid of the error but the code is still being converted to something odd as above

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Do you happen to have any other extensions or plugins that modify the content of your page? That could be the problem, if so I will need to check that out.

In the mean time, try this version out.

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

I installed on a clean version of EE aswell and the same problem I’m afraid. The garbage is different everytime I refresh the page. The new version you supplied does not seem to help.

Other details ExpressionEngine 1.6.1 Build: 20071204

Can you post an example of how you add your code block to an entry? Maybe I am wrong there. I only put it together from looking at your extension file

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

You have it right. I am running 1.6.0 so let me upgrade and see what is going on. It could just be that I need to tweak something for the latest version.

That string of characters is the unique id for that part of the highlighting. It is stored in an array and then transformed back to the highlighted code. But for some reason your is not doing that. That is why it is different each time you refresh thepage.

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Just upgraded and no problems here.

What version of PHP are you running?

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

Test Site 1 has 4.3.9 EngineHosting Test Site 2 has 4.4.4 and is running in a windows environment using php running as a CGI

Both sites have same difficulty

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

Victor, just make sure to remove the space after the ‘[’ before the code . I had to add that so it would render correctly in these forums

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Thanks for the update. I will check into both of these. The only problem I experienced was in a WAMP setup with PHP4 but it was due to a memory issue. That was worked out but obviously something else is causing a problem.

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

Not 100% sure if this will fix the problems but go ahead and try this version. I am pretty sure that it has something to do with the way preg_replace_callback is calling other functions but until I am 100% positive I have to keep looking around. 😊

       
John Henry Donovan's avatar
John Henry Donovan
12,339 posts
17 years ago
John Henry Donovan's avatar John Henry Donovan

Sorry Jason but I am getting these errors now.

Notice: Undefined variable: this in /extensions/ext.ignite.php on line 193
Notice: Undefined property: code_matches in /extensions/ext.ignite.php on line 136

And you say the extension works on your installation of 1.6.0?

       
Jason Bullard's avatar
Jason Bullard
55 posts
17 years ago
Jason Bullard's avatar Jason Bullard

It works on 1.6.1 as well for me. I figured that would happen because of the way the preg_replace_callback function is called. I will keep looking and maybe see if I can at least duplicate the error. It may be something within php.ini that is different.

       
1 2 3

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.