(anonymous guest) (logged out)

Copyright (C) by the contributors. Some rights reserved, license BY-SA.

Sponsored by the Wiki Symposium and the Nuveon GmbH.

 

Add new attachment

Only authorized users are allowed to upload new attachments.

This page (revision-11) was last changed on 27-May-2008 17:45 by ChristophSauer  

This page was created on 15-Dec-2006 17:53 by RadomirDopieralski

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Difference between version and

At line 1 changed 46 lines
!Braindamaged substitution
This is the simplest parsing method, used by some scratch wikis and "write a wiki in minimal number of lines of code" engines. It's pretty easy to uderstand and implement in any language that supports regular expressions, but is very limited and not guaranteed to produce valid html. Still, it works most of the time
The idea is to apply a number of regexp subtitutions:
{{{
s/&/&/
s/</&lt;/
s/>/&gt;/
s/^/<p>
s/$/</p>
s/\n(\s*\n)+/</p><p>/
s/\n----/<hr>/
s/\n==(.*)=*/<\/p><h1>\1<\/h1><p>/
s/\n===(.*)=*/<\/p><h2>\1<\/h2><p>/
s/\n====(.*)=*/<\/p><h3>\1<\/h3><p>/
s/\n\s*\*\s+(.*)/<\/p><ul><li>\1<\/li><\/ul><p>/
s/\n\s*\*\*\s+(.*)/<\/p><ul><li><ul><li>\1<\/li><\/ul><\/li><\/ul><p>/
s/\n\s*\*\*\*\s+(.*)/<\/p><ul><li><ul><li><ul><li>\1<\/li><\/ul><\/li><\/ul><\/li><\/ul><p>/
s/\n\{\{\{(([^}]|\}[^}]|\}\}[^}])*)\n\}\}\}/</p><pre>\1</pre><p>/
s/\{\{\{(([^}]|\}[^}]|\}\}[^}])*)\}\}\}/<code>\1</code>/
s/\/\/([^\/]|\/[^\/])*\/\//<em>\1<\/em>/
s/\*\*([^\*]|\*[^\*])*\*\*/<strong>\1<\/strong>/
s/\[\[(\w+)\]\]/<a href="wiki?\1">\1</a>/
s/\[\[(\w+)\|(.*)\]\]/<a href="wiki?\1">\2</a>/
s/\[\[(http:[^\]|]*)\]\]/<a href="\1">\1</a>/
s/\[\[(http:[^|]*)\|(.*)\]\]/<a href="\1">\2</a>/
s/<p></p>//
s/</li></ul><ul><li>//
s/</li></ul><ul><li>//
s/</li></ul><ul><li>//
}}}
You get the point. This technique has a number of drawbacks:
* no mixing of //**bold italic**//
* no markup inside lists, headings, etc.
* no mixing of list types, unless a large number of regexps is introduced to accommodate them (like /\n\*\#\*/ etc.)
* limited number of headings and list levels
* impossible (or extremely hard) to accommodate special cases like the \n --> <br> in paragraphs only, or the list/bold special case
* impossible to distinguish different levels of indentation
!Two-level regular expressions
This is a very popular approach. It's pretty fast, as it scans the raw text exactly two times.
The idea is to create two kinds of regular expressions -- one to split the text into blocks of different kinds (paragraphs, headings, lists, preformatted blocks, etc.) and then process each of them with different character-level regular expression.
plime-keys2.txt;4;11
Version Date Modified Size Author Changes ... Change note
11 27-May-2008 17:45 2.211 kB ChristophSauer to previous restore
10 27-May-2008 14:13 0.603 kB 89.149.244.45 to previous | to last comment1, http://www.ittoolbox.com/profiles/buy_Naprosyn_here buy naprosyn onlin
9 01-May-2008 15:40 2.211 kB ChristophSauer to previous | to last restore
8 28-Apr-2008 10:21 0.022 kB 89.149.242.226 to previous | to last UdvHUpQMFzXUj
7 28-Apr-2008 08:39 2.211 kB ChristophSauer to previous | to last revert spam
6 28-Apr-2008 01:03 0.021 kB 89.149.242.226 to previous | to last kTLXmGXKLydgsqZV
5 27-Apr-2008 16:51 2.211 kB IvanFomichev to previous | to last revert spam
4 27-Apr-2008 02:16 0.189 kB 89.149.242.226 to previous | to last iOwadNEXjdfHxJIqjG
3 18-Oct-2007 23:47 2.211 kB 207.171.180.101 to previous | to last Fixed spelling
2 15-Dec-2006 20:38 2.208 kB RadomirDopieralski to previous | to last
1 15-Dec-2006 17:53 1.764 kB RadomirDopieralski to last braindamaged substitution
« This page (revision-11) was last changed on 27-Mai-2008 17:45 by ChristophSauer