summaryrefslogtreecommitdiff
path: root/inc/parser/action.php
diff options
context:
space:
mode:
authorandi <andi@splitbrain.org>2005-03-31 16:57:49 +0200
committerandi <andi@splitbrain.org>2005-03-31 16:57:49 +0200
commit0cecf9d507451346a32ddf45a85b425784fbb0f8 (patch)
tree076dd2d128f55022792b4bfab42c1d2d2bec4fb8 /inc/parser/action.php
parentc53ea5f2d3d1019fd4e1956796bc329af499a86d (diff)
downloadrpg-0cecf9d507451346a32ddf45a85b425784fbb0f8.tar.gz
rpg-0cecf9d507451346a32ddf45a85b425784fbb0f8.tar.bz2
new parser added (define DOKU_USENEWPARSER to use it)
darcs-hash:20050331145749-9977f-f011ea6c65a278197e9087b685c635c60a204cd2.gz
Diffstat (limited to 'inc/parser/action.php')
-rw-r--r--inc/parser/action.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/inc/parser/action.php b/inc/parser/action.php
new file mode 100644
index 000000000..34d71d3ae
--- /dev/null
+++ b/inc/parser/action.php
@@ -0,0 +1,83 @@
+<?php
+if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
+
+function parse_to_instructions($text){
+ require_once DOKU_INC . 'inc/parser/parser.php';
+
+ // 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());
+ $Parser->addMode('notoc',new Doku_Parser_Mode_NoToc());
+ $Parser->addMode('header',new Doku_Parser_Mode_Header());
+ $Parser->addMode('table',new Doku_Parser_Mode_Table());
+
+ $formats = array (
+ 'strong', 'emphasis', 'underline', 'monospace',
+ 'subscript', 'superscript', 'deleted',
+ );
+ foreach ( $formats as $format ) {
+ $Parser->addMode($format,new Doku_Parser_Mode_Formatting($format));
+ }
+
+ $Parser->addMode('linebreak',new Doku_Parser_Mode_Linebreak());
+ $Parser->addMode('footnote',new Doku_Parser_Mode_Footnote());
+ $Parser->addMode('hr',new Doku_Parser_Mode_HR());
+
+ $Parser->addMode('unformatted',new Doku_Parser_Mode_Unformatted());
+ $Parser->addMode('php',new Doku_Parser_Mode_PHP());
+ $Parser->addMode('html',new Doku_Parser_Mode_HTML());
+ $Parser->addMode('code',new Doku_Parser_Mode_Code());
+ $Parser->addMode('file',new Doku_Parser_Mode_File());
+ $Parser->addMode('quote',new Doku_Parser_Mode_Quote());
+
+ // FIXME These need data files...
+ #$Parser->addMode('acronym',new Doku_Parser_Mode_Acronym(array_keys(getAcronyms())));
+ #$Parser->addMode('wordblock',new Doku_Parser_Mode_Wordblock(getBadWords()));
+ #$Parser->addMode('smiley',new Doku_Parser_Mode_Smiley(array_keys(getSmileys())));
+ #$Parser->addMode('entity',new Doku_Parser_Mode_Entity(array_keys(getEntities())));
+
+ $Parser->addMode('multiplyentity',new Doku_Parser_Mode_MultiplyEntity());
+ $Parser->addMode('quotes',new Doku_Parser_Mode_Quotes());
+
+ $Parser->addMode('camelcaselink',new Doku_Parser_Mode_CamelCaseLink());
+ $Parser->addMode('internallink',new Doku_Parser_Mode_InternalLink());
+ $Parser->addMode('media',new Doku_Parser_Mode_Media());
+ $Parser->addMode('externallink',new Doku_Parser_Mode_ExternalLink());
+ $Parser->addMode('email',new Doku_Parser_Mode_Email());
+ $Parser->addMode('windowssharelink',new Doku_Parser_Mode_WindowsShareLink());
+ $Parser->addMode('filelink',new Doku_Parser_Mode_FileLink());
+ $Parser->addMode('eol',new Doku_Parser_Mode_Eol());
+
+ // Do the parsing
+ return $Parser->parse($text);
+}
+
+function render_as_xhtml($instructions){
+
+ // Create the renderer
+ require_once DOKU_INC . 'inc/parser/xhtml.php';
+ $Renderer = & new Doku_Renderer_XHTML();
+
+ //FIXME add data
+ #$Renderer->smileys = getSmileys();
+ #$Renderer->entities = getEntities();
+ #$Renderer->acronyms = getAcronyms();
+ #$Renderer->interwiki = getInterwiki();
+ #$Renderer->badwords = getBadWords();
+
+ // Loop through the instructions
+ foreach ( $instructions as $instruction ) {
+ // Execute the callback against the Renderer
+ call_user_func_array(array(&$Renderer, $instruction[0]),$instruction[1]);
+ }
+ // Return the output
+ return $Renderer->doc;
+}
+
+?>