Pretty Code module
Posted by cgardner
|
Pretty Code module December 15, 2006 05:50PM |
Registered: 19 years ago Posts: 8 |
I got bored the other day and decided to write a module that makes the
tags prettier. See it in action: [goodpacket.com] Here it is in all of it's glory. Hope it helps someone. Edited 5 time(s). Last edit at 01/12/2007 06:31PM by cgardner.
|
Re: Pretty Code module December 16, 2006 03:39AM |
Admin Registered: 23 years ago Posts: 9,240 |
|
Re: Pretty Code module December 17, 2006 08:53PM |
Registered: 19 years ago Posts: 5 |
|
Re: Pretty Code module December 19, 2006 05:53AM |
Registered: 19 years ago Posts: 11 |
It doesn't work with this: [www.phorum.org]
I need that for the inbodyattachments module, otherwise it wouldn't scale
I need that for the inbodyattachments module, otherwise it wouldn't scale
|
Re: Pretty Code module December 20, 2006 12:49PM |
Registered: 19 years ago Posts: 8 |
Yes, it will highlight the code for PHP only, but there is absolutely no reason you wouldn't be able to use it for other languages or just for fun.
I made some updates, but unfortunately I don't have any PHP4 servers that I can test with...
I made some updates, but unfortunately I don't have any PHP4 servers that I can test with...
|
Re: Pretty Code module December 21, 2006 03:22PM |
Registered: 19 years ago Posts: 5 |
|
Re: Pretty Code module December 21, 2006 05:52PM |
Registered: 19 years ago Posts: 11 |
|
Re: Pretty Code module January 03, 2007 06:08AM |
Admin Registered: 22 years ago Posts: 8,532 |
Quote
cgardner
Yes, it will highlight the code for PHP only, but there is absolutely no reason you wouldn't be able to use it for other languages or just for fun.
One problem with that, is that any other preformatted text will be PHP code highlighted as well. For example ASCII art or HTML code (see the examples I posted on the URL you mentioned above).
I think it might be a better idea to introduce a special [php] tag, which can be used for PHP coloring the code contained within that tag. I see two advantages for that:
1) The users can still create preformatted text using
without the highlighting; 2) There will be no module ordering problems with the bbcode mod, which implements thetag as well (which is probably the problem that Hiiri is running into).
Maurice Makaay Phorum Development Teammy blog
linkedin profile
secret sauce
|
Re: Pretty Code module January 12, 2007 06:14PM |
Registered: 19 years ago Posts: 8 |
Quote
mmakaay
I think it might be a better idea to introduce a special [php] tag, which can be used for PHP coloring the code contained within that tag.
I took your advice and got rid of the formatting, but I'm still noticing what Hiiri mentioned. Any URLs that are posted within the code tags are truncated and formatted according to the bbcode bare URL formatter.
I've played with the bbcode module a bit to try to make it exclude any URLs that are in code tags, but have been unsuccessful so far. If you modify the bbcode module to disable bare url formatting by commenting out the following line it works, but any other URLs that you may want formatted are not formatted.
// convert bare urls into bbcode tags as best we can
// the haystack has to have a space in front of it for the preg to work.
$body = preg_replace("/([^='\"([url\]|[img\])])((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#]+)/i", "$1:$rnd:$2:/$rnd:", " $body");
I also uploaded the newest version of the formatter.
Edited 1 time(s). Last edit at 01/12/2007 06:16PM by cgardner.
Sorry, only registered users may post in this forum.