Friday, February 12, 2010

PHP Creole 1.0 Wiki Markup Parser

I translated my JavaScript Creole 1.0 wiki markup parser in PHP.

I did it specially for making a wiki suitable for 110mb.com free web hosting. Just because alike most Russians, I experience irrational affinity to costless products and services.

You can see the wiki in action at 110mb.com or download its source code at Gitorious, the best source hosting service. The source code is distributed under the MIT/X11 License.

UPDATE: There is also a mirror at GitHub now.

14 comments:

Anonymous said...

Great work. Is it possible to use HTML and have it not escaped but processed?

codeholic said...

Yes, at least partially. The latest version supports extensions on the block level. You can make an extension that allows HTML use.

Anonymous said...

By "block" you mean blocks like divs? If so, could you please explain how to make a div being processed?

codeholic said...

For an instance see "Embedded HTML" test in http://gitorious.org/w/trunk/blobs/master/t/creole.php

Anonymous said...

Great! Thanks so much!

Anonymous said...

hey, the creole.php is outputing some warning :
Warning: get_class() expects parameter 1 to be object, array given in I:\xampplite\htdocs\w\creole.php on line 77

Warning: get_class() expects parameter 1 to be object, array given in I:\xampplite\htdocs\w\creole.php on line 89

Warning: get_class() expects parameter 1 to be object, array given in I:\xampplite\htdocs\w\creole.php on line 89

codeholic said...

http://www.php.net/manual/en/function.get-class.php#93597

> As of 5.3.0 this function seems to have started throwing an E_WARNING error if you pass it a non-object.

I hate PHP :-S

P. S. I've fixed that.

Anonymous said...

Good job, thank you!

kib said...

Hi Ivan,

thanks for the great work.

Today, I've encountered a problem while parsing, ie this snippet of creole text just crashes (with a strange 'ERR_CONNECTION_RESET'):

http://paste.lisp.org/+2PSN

Now, replace it with the following:


http://paste.lisp.org/display/126744

and it goes fine. Have you got any idea why ?

codeholic said...

Hello, kib,

that's strange. Does your database support UTF-8? It works for me:

http://codeholic.110mb.com/w.php?id=French%20diacritics

Which line produces this error?

codeholic said...

And. by the way, it's not "Creole Parser 1.0", but "Creole 1.0 Parser" ;) "Creole 1.0" refers to the version of the markup specification.

kib said...

Sorry for the late Ivan.

Your sample is working fine, but not for me in my current application.
It may be related to the latest version of slqlite, I'll investigate.

Thanks anyway for testing!

Vasily Ivanovich Chapaev said...

Hi Ivan
Does your parser convert only wikicreole to html?
Or it can also convert the other way around, that is html to wiki creole?

codeholic said...

Nope. It's a one-way converter :(