summaryrefslogtreecommitdiff
path: root/inc/parserutils.php
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-05-19 22:10:09 +0200
committerandi <andi@splitbrain.org>2005-05-19 22:10:09 +0200
commitee20e7d16637625e900f518b6b46a61bfa30fe6e (patch)
treef621ec424429d9dc9732a059ec0ca4bf83aab566 /inc/parserutils.php
parent64f50cdbe21d0b9ca2165749301e6f553f9b8f02 (diff)
downloadrpg-ee20e7d16637625e900f518b6b46a61bfa30fe6e.tar.gz
rpg-ee20e7d16637625e900f518b6b46a61bfa30fe6e.tar.bz2
first attempt of syntax plugins
The first version of the new plugin system. Syntax plugins only yet. A very simple example plugin called info (doing nothig useful yet) is included. Missing Features - Doku_Block_Handler needs work (doesn't honur plugins yet) - there is no way to specify the order of plugins and other modes yet - useful output from the info plugin - bug testing and fixing - code cleanup - documentation darcs-hash:20050519201009-9977f-f793dbfc6a39d8a9643b610927d93cd3288bdd6b.gz
Diffstat (limited to 'inc/parserutils.php')
-rw-r--r--inc/parserutils.php28
1 files changed, 23 insertions, 5 deletions
diff --git a/inc/parserutils.php b/inc/parserutils.php
index 802ae8a0d..9c0e4fd9c 100644
--- a/inc/parserutils.php
+++ b/inc/parserutils.php
@@ -11,6 +11,7 @@
require_once(DOKU_INC.'inc/confutils.php');
require_once(DOKU_INC.'inc/pageutils.php');
+ require_once(DOKU_INC.'inc/pluginutils.php');
/**
* Returns the parsed Wikitext in XHTML for the given id and revision.
@@ -155,14 +156,26 @@ function p_cached_instructions($file,$cacheonly=false){
function p_get_instructions($text){
global $conf;
+ //import parser classes and mode definitions
require_once DOKU_INC . 'inc/parser/parser.php';
-
+
+ // load syntax plugins
+ $pluginlist = plugin_list('syntax');
+ if(count($pluginlist)){
+ global $PARSER_MODES;
+ $plugins = array();
+ foreach($pluginlist as $p){
+ plugin_load('syntax',$p,$plugin[$p]); //load plugin into $plugin array
+ $PARSER_MODES[$plugin[$p]->getType()][] = "plugin_$p"; //register mode type
+ }
+ }
+
// Create the parser
$Parser = & new Doku_Parser();
// Add the Handler
$Parser->Handler = & new Doku_Handler();
-
+
// Load all the modes
$Parser->addMode('listblock',new Doku_Parser_Mode_ListBlock());
$Parser->addMode('preformatted',new Doku_Parser_Mode_Preformatted());
@@ -192,7 +205,7 @@ function p_get_instructions($text){
$Parser->addMode('smiley',new Doku_Parser_Mode_Smiley(array_keys(getSmileys())));
$Parser->addMode('acronym',new Doku_Parser_Mode_Acronym(array_keys(getAcronyms())));
- #$Parser->addMode('wordblock',new Doku_Parser_Mode_Wordblock(getBadWords()));
+ #$Parser->addMode('wordblock',new Doku_Parser_Mode_Wordblock($Modes,getBadWords()));
$Parser->addMode('entity',new Doku_Parser_Mode_Entity(array_keys(getEntities())));
$Parser->addMode('multiplyentity',new Doku_Parser_Mode_MultiplyEntity());
@@ -202,6 +215,11 @@ function p_get_instructions($text){
$Parser->addMode('camelcaselink',new Doku_Parser_Mode_CamelCaseLink());
}
+ //add plugins FIXME since order is important we, need to find a better way!
+ foreach ( array_keys($plugin) as $p ) {
+ $Parser->addMode("plugin_$p",$plugin[$p]);
+ }
+
$Parser->addMode('internallink',new Doku_Parser_Mode_InternalLink());
$Parser->addMode('rss',new Doku_Parser_Mode_RSS());
$Parser->addMode('media',new Doku_Parser_Mode_Media());
@@ -210,10 +228,10 @@ function p_get_instructions($text){
$Parser->addMode('windowssharelink',new Doku_Parser_Mode_WindowsShareLink());
//$Parser->addMode('filelink',new Doku_Parser_Mode_FileLink()); //FIXME ???
$Parser->addMode('eol',new Doku_Parser_Mode_Eol());
-
+
// Do the parsing
$p = $Parser->parse($text);
-# dbg($p);
+// dbg($p);
return $p;
}