Jan 06 2010

[JavaScript] EditArea: Realtime Syntax Highlighting JavaScript Library

Category: Articles,JavaScriptFractalizeR @ 3:19 pm

Recently, improving my WordPress plugin WP-SynHighlight, I chose EditArea as a source code editor with realtime syntax highlighting. The syntax of language description files for highlighting of EditArea is pretty much the same as Geshi has. So, I wrote a small converter and executed it over all Geshi files for 1.0.x version.

I have posted a patch for EditArea with all generated files.

So, now you can have EditArea with almost all power of supporting more than 130 languages 😉

Tags: , ,


Jan 06 2010

[JavaScript] PHP PCRE_DOT_ALL option emulation in JavaScript

Category: Articles,JavaScriptFractalizeR @ 2:06 pm

Writting my WP-SynHighlight WordPress plugin, I came to a need of parsing multilined shortcode like this:

[ codesyntax option1=”optionvalue1″…] <many lines here….> [ / codesyntax]

So, I extracted regular expression to parse shortcode from WordPress source code (if you are interested in it, see /wp-includes/shortcodes.php file). This regex was executed with /s option (PCRE_DOT_ALL) which makes dot (“.”) to match newlines also. There is no such option in JavaScript for some reason and I had to replace dot by such character class:

[\S\s]

Actually, any opposite metacharacters should work. [\W\w] for example.

Quite easy, isn’t it? 🙂

Tags: , ,