![]() |
How to implement code highlighting features ? - 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 implement code highlighting features ? (/showthread.php?tid=35878) |
How to implement code highlighting features ? - El Forum - 11-14-2010 [eluser]mi6crazyheart[/eluser] Dose any body have any idea, how code highlighting work in this forum editor ? I'm trying to build an environment like this. Every things are working perfect except the code highlighting feature. Can't understand how to implement it. If any body have any solution plz share with me... How to implement code highlighting features ? - El Forum - 11-14-2010 [eluser]WanWizard[/eluser] I'm using http://qbnz.com/highlighter/ in my forum code... How to implement code highlighting features ? - El Forum - 11-14-2010 [eluser]InsiteFX[/eluser] PHP PHP highlight_string InsiteFX How to implement code highlighting features ? - El Forum - 11-14-2010 [eluser]mi6crazyheart[/eluser] [quote author="WanWizard" date="1289789871"]I'm using http://qbnz.com/highlighter/ in my forum code...[/quote] Hey WanWizard, if i've a text like this(mixture of text & codes as we use in CI forum generally)... Code: $text = 'Good morning.<code>echo 'PHP is a great language';</code> Today is a great day'; Then, can GeSHi will able to color codes which present inside "colorTag" & leave rest text as usual as CI forum do. How to implement code highlighting features ? - El Forum - 11-15-2010 [eluser]WanWizard[/eluser] No, geshi is just a highlighter. You have to create the proper CSS code for geshi to work with, then use some technique ( for example a preg_match() ) to get the code blocks from the text, run the code blocks through gehsi, and reinsert them into the text. Geshi output will contains lots of span's that uses CSS to highlight. Check the docs on the Gehsi site, they explain everything. How to implement code highlighting features ? - El Forum - 11-15-2010 [eluser]mi6crazyheart[/eluser] @WanWizard Exactly in this situation(use some technique for example a preg_match() to get the code blocks) i've stuck. I've piece of code for this. But, it's not working properly. Here is that code... Code: $parentstring = preg_replace_callback( '#<code>(.*)</code>#', 'mycallback', $parentstring); How to implement code highlighting features ? - El Forum - 11-15-2010 [eluser]WanWizard[/eluser] what's not working properly? your highlight_code() function? The rendering of <code> tags? How to implement code highlighting features ? - El Forum - 11-15-2010 [eluser]mi6crazyheart[/eluser] Actually, it couldn't able to enter to the "mycallback()". May be, some problem with that REGXP... Code: #<code>(.*)</code># How to implement code highlighting features ? - El Forum - 11-16-2010 [eluser]WanWizard[/eluser] I use it to parse BBcode, I use Code: $rawmsg = preg_replace_callback('#\[code(=.*?)?\](.*?)([\r\n]*)\[/code\]#si', '_parse_bb_code', $rawmsg); How to implement code highlighting features ? - El Forum - 11-16-2010 [eluser]mi6crazyheart[/eluser] @WanWizard Wow!!! Man, u'r REGXP just made a magic. Now, every things are working perfect. Thx a lot. It's just make my day... |