CodeIgniter Forums
How to display code samples on a blog page ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to display code samples on a blog page ? (/showthread.php?tid=19522)



How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]opel[/eluser]
I have almost finished writing my blog and hope to include code snippets and tutorials inside articles.

Can anyone recommend a CI library or JQuery plugin that can highlight the code, possibly offering a plain text version.

I found many plugins for wordpress but no stand along options ?

Cheers


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]eoinmcg[/eluser]
Hi Opel,

I've experimented a bit with Chili, which is jQuery based.

Have a look here:

http://code.google.com/p/jquery-chili-js/


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]Dam1an[/eluser]
The most common library for this is GeSHi, there's also a CI plug-in


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]Evil Wizard[/eluser]
php already has a function built in to highlight source code files, see highlight_file()


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]n0xie[/eluser]
[quote author="Dam1an" date="1244653797"]The most common library for this is GeSHi, there's also a CI plug-in[/quote]
In case anyone is interested I rewrote parts of it to make it a library instead of a hook. I don't need it checking/loading GeSHi on every page load plus I like to be able to just 'drop it in' a project and just add codehighlighting for certain views.

It's pretty much hacked together so it's rather inefficient and crude, but if it works, don't fix it Wink


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]TheFuzzy0ne[/eluser]
If it ain't broke, fix it 'til it is. Big Grin


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]Phil Sturgeon[/eluser]
[quote author="Evil Wizard" date="1244657796"]php already has a function built in to highlight source code files, see highlight_file()[/quote]

Hmmm... font tags. My favourite.


How to display code samples on a blog page ? - El Forum - 06-10-2009

[eluser]Evil Wizard[/eluser]
oh crud I forgot how old that function was, hmmmmm not sure of an XHTML compliant alternative hehe


How to display code samples on a blog page ? - El Forum - 06-11-2009

[eluser]opel[/eluser]
Thanks I'll try that library