Markup Plugins
When I was trying to rewrite the wiki.py parser, I noticed that adding markup for an element usually only needs several steps:
- Add a regular expression either to the block-level or to the text-level regular expressions
- (optional) Make sure it comes at the right place (i.e. before any more general expressions)
- Add a _repl method adding needed nodes to the document tree
- (optional) Add a method to the emitter to handle new node kind
This makes me wonder if I could refactor it to use markup objects instead. Such an object could look something like this:
1 class Markup:
2 def __init(self)__:
3 self.level = 'block' # or 'text' for text-level markup
4 self.priority = 3 # determines the order of '|'.joining the expressions
5 self.expression = r'...' # the expression, with apropriate groups
6
7 def matched(self, groups, parser):
8 """
9 The function called when any of the groups in self.expression is matched.
10
11 groups - the groups from match.groupdict()
12 parser - used to carry some state
13 """
14 parser.current_node = DocumentNode('paragraph', parser.current_node)
The fourth step would have to be performed with other means (or maybe not at all).
This would enable admins to enable and disable markup on per-element basis, and also to easily add markup when it's required by the community.
It is not intended that many moin wikis have different markups or different sets of markup features enabled or disabled. Many users write content in different wikis and it is hard enough to cope with different wiki markups used by different engines, so there is no need to make it even more different within the same engine. -- ThomasWaldmann 2006-04-13 09:35:57
I would suggest to rethink about it. I think it is generally a bad idea to tie the markup and the engine together. This makes it very unflexible. I have experimented a bit with OddMuse (a usemod clone). They have made it like this that they have some basic, general markup that you can also extend with plugins. They are not distributed with the core file. What I like about the idea is that I found it to be difficult to patch the media-plugin (which gives a bit of MediaWiki flavor to MoinMoin) so that it supports more of this Media syntax. I think it is unneccessary to tie markup together. Especially I do not see any use of forcing users to switch their markup. Personally I think the MediaWiki markup has won the competition of the most popular markup and i think it would be nice if I could choose the best wiki engine but could have the same markup in every wiki. I do see some benefit for developers to tie things together if they want to make some things possible quick. but if it would be more abstract you could use an engine with many different styles. Oddmuse also uses much more MediaWiki kind of markup styles. I think the worst differences are:
lists are always wrong if you mix. You can not use both styles, either In MediaWiki you do not have to type space to make lists, which seems to be faster.
links are different [[Mediawiki]] and ["Mediawiki"] - I think what makes mediawiki style nicer is that you can press one key twice instead of two different keys. That makes it also much quicker.
I don't expect anybody to agree, but I think I would like to be see the basic styles in the most popular wikis would be the same. I also think that is a a bit against the wiki thinking (interwiki directions) if a wiki software project follows its own path without trying to be as compatible with the others. I think some markups can and will be different. We already do have plugins that change the markup. But it is hard and maybe also not possible to switch the whole MediaWiki solution into Moin. I really think some things are much better solved in Moin, except for the very basic markup. I think it would be easier for users if we would seperate basic markupand advanced markup. So maybe we could make it very easy for a MediaWiki user to write in Moin - but that he would have to learn to handle some technics like how images are uploaded in Moin. I think it would not be more confusing if users would only have to switch some usages as if they would have to switch EVERYTHING when they switch the system. I know: If I would be a real good programmer I could write the perfect plugin myself or just submit the right patches. But as I am not I try to convince you and others to switch the approach. Personally I really only have problems with the bot points are mentioned above (lists and links) where I am getting confused regullary and i think i will continue to get confused as long as every wiki machine is wanting me to switch to its style. -- ThiloPfennig 2006-07-09 16:04:24
( see also UnifyMarkup ? )