I have been fiddling for days on getting decent wiki formatting working in Drupal. My requirements are modest (ahem):
- Bullet points entered typing a simple asterisk and a space: no toolbars, nothing more elaborate.
- New style hyperlinks, far easier than restructuredtext e.g:
[go here|htttp://www.here.com]
- Facility to put in raw html, specificly source code snippets that have been syntax highlighted using vim.
- No need to edit snippets, such as inserting indents in every line, just adding a start and end tag.
Drupal's problem, acknowledged in the forums, is that the system of filtering that is used to convert the raw text to the formatted html does not really work very well: the filters step on each other's toes. My specific problem was that code snippets I put in would be altered by later filters, specificly text in square brackets would be converted to hyperlinks that didn't work. The wiki module also managed to interfere with itself: every line was transformed unless an exclamation mark was put at the start of each line: a tedious amount of extra editing.
I tried a number of options:
- try to get the latest phpwiki source to work with Drupal. I got this to a state where it was kinda working but it continually messed up external links. The code was hard work, complex object model, no useful comments (only FixMes). I gave up on this as my head was hurting from banging on a brick wall.
- try using textile. I didn't like this ones syntax.
- try using bbcode but the syntax is worse, virtually html using [] instead of <>.
- try using the markdown module but this is not free for commercial use.
- hack on the existing wiki module, adding the concept of blocks that are not processed by other forms of markup within the wiki module itself.
I've gone for the last option, I've added two forms of block tags:
- <verbatim> tag
- html entities are escaped so < > & etc can all be used:
$text = str_replace("<p>%::%</p>","",$text);
$text = str_replace("%::%</p>","",$text);
$text = str_replace("%::%","",$text);
$text .= $DontScrewWithSquareBrackets[9];
$two = 1 & 1;
- <rawhtml> tag
- insert raw html, e.g. pre syntax-highlighted code
<?php
// $Id: wiki.module,v 1.8 2004/02/08 22:39:38 tdobes Exp $
/**
* wiki.module - mostly taken from <http://phpwiki.sourceforge.net/>, v1.2.2
*/
function wiki_link($type) {
if ($type == "system") {
menu("wiki", t("Wiki Text Formatting Rules"), "wiki_page", 0, MENU_HIDE);
}
}
function wiki_page()
{
if (!user_access("access content")) {
print theme("page", message_access(), t("Access Denied"));
return;
}
I'm not entirely happy with this as a solution, beating on the phpwiki code would have been better as that is a far more complete language. Maybe I will give that another try?
Update: I beat some more and did fix my problem. However, I came across other problems:
- The vertabim tag is equivalent to my code tag, it does not allow raw html to pass through
- phpwiki allows certain raw html tags to pass through, for example b, small, etc but not the font tag. The regexp matching that it uses is restrictive and does not allow tags with attributes past. This could not be fixed without hacking on the phpwiki code itself. I don't want to use a library I have to hack on directly. I could work around it by subclassing but what if the base classes get changed (ref broken PyDS problems).
- phpwiki has a 'RawHTML' plugin but that applies to the whole page, not sections thereof. Also this did not work as it relied upon the larger phpwiki structure rather then the bit that converted a string to html.
- phpwiki folk are paranoid about javascript security holes in raw html. I want this for intranet so anyone who breaks things gets sacked.
- there are also purists who think the markup should be enough and html is a cop out. They are probably not people who like to push boundaries, they prefer to erect them.
I'll stick with my hacked wiki module until something better comes along.
|