I have a database storing "wiki formatted" text which I would like to display in XHTML using PHP.
Here is an example output with all the wiki markup:
Default text
== Heading 1 ==
=== Heading 2 ===
==== Heading 3 ====
===== Heading 4 =====
====== Heading 5 ======
'''Bold'''
''Italic''
<s>Strikethrough</s>
* List item 1
* List item 2
# Numbered item 1
# Numbered item 2
[[Image:http://domain.com/image.png|Image name]]
[http://google.com Link text goes here]
> Blockquote
<source lang="language">Source code</source>
Is that fairly standard wiki syntax? Is there a fairly standard way of interpreting it with PHP?
Thanks in advance!
Yes, that seems like a fairly standard wiki format. I've created several PHP wiki solutions using the PEAR package Text_Wiki. It does just what you want, and you can even expand it to support any custom syntax and translate according to any rule.
http://pear.php.net/package/Text_Wiki
It's going to depend very much on what language you are using to parse.
Client-side with Javascript?
Server Side with ASP or PHP?
MediaWiki is written in PHP and licensed under GPL. So you just could take the WikiText converter and use it.
I would say that the most standard wiki-like format around today is markdown. There are libraries available for almost any platform, including PHP.
I came up with a hack, but it breaks on a lot of things. Is this the best way forward?
PHP:
Input:
Output: