Reply to Syntax Highlighting using XML and regex

Your name:

Reply:


Posted by rockstar_ on 10/12/06 20:35

Hello all-

I'm developing a Content Management software for my own site, and
possibly package and deploy to other sites (for friends, family, etc.)
The content management software is combined blog, photo, and site
management tools. One the of the tools I would find INREDIBLY helpful
is the ability to block out and syntax highlight code. I would like to
be able to, as I'm writing a blog post about something I've done in
Python (for example), just stop and type something like:

<python>
def foo():
bar()

foo()

</python>

Do you get the idea? The only code I've been writing recently is
PHP, Python, and C++, so I could start with the regex for those
languages first and then expand. The blocks of code would then add
some style info (like making the font a fixed size font, etc....) and
then would highlight certain terms (a regex nightmare).

I've talked this over with another PHP dev, and he suggested I use
the xml_parser_create function to generate a parser object, and then
the xml parsing functions to find these tidbits of code. This sounds
like a great idea to me. However, does anyone have suggestions on a
better way to do this, or an efficient way to do the syntax
highlighting?

I'm assuming for syntax highlighting, I'd have to do a massive
preg_replace with the regex, and then add in the HTML for items I
wanted to highlight. I don't mind doing this, but I was also wondering
if someone had a great resource for syntax highlighting regex that
someone else may have created that I could use, and possibly modify.

Licensing for this software would be the GPL, so obviously everything
else should be GPL. I thought I'd bounce the idea against some other
PHP developers, and see what they thought of it.

Thanks in advance
rockstar_

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация