Difference between revisions of "Dokuwiki"

From ThorstensHome
Jump to: navigation, search
(program)
 
(14 intermediate revisions by one user not shown)
Line 1: Line 1:
This describes my patches to adapt Dokuwiki for my needs
+
This page is here for historic reasons. You can browse through its versions by selecting the tab "history". The page used to describe how I adapt Dokuwiki for my needs, but I can do this now entirely using the [[mediasyntax]] plugin for dokuwiki.
  
= allow h6 headings =
+
= Where do you want to go? =
This is a little patch for dokuwiki to allow h6 headings.
+
* you want to install dokuwiki => go to [http://linuxintro.org/wiki/dokuwiki LinuxIntro]
 +
* you want to learn more about the mediasyntax plugin => go to [[mediasyntax]]
 +
* you want to help developing the mediasyntax plugin => go to [[developing mediasyntax]]
  
<pre>
+
= program =
/srv/www/htdocs/dokuwiki/inc/parser # diff -rup parser-org.php parser.php
+
--- parser-org.php      2009-10-20 15:49:57.000000000 +0200
+
+++ parser.php  2009-10-20 15:48:25.000000000 +0200
+
@@ -223,7 +223,7 @@ class Doku_Parser_Mode_header extends Do
+
    function preConnect() {
+
        //we're not picky about the closing ones, two are enough
+
        $this->Lexer->addSpecialPattern(
+
-                            '[ \t]*={2,}[^\n]+={2,}[ \t]*(?=\n)',
+
+                            '[ \t]*={1,}[^\n]+={1,}[ \t]*(?=\n)',
+
                            'base',
+
                            'header'
+
                        );
+
</pre>
+
{{{
+
//This// does **not** get [[formatted]]
+
}}}
+
  
= redirects =
+
== editsections ==
With this patches I have the problem that they only work on new pages, i.e. pages that I viewed/created after I applied the patches. Seems the rendered pages are cached.  
+
inc/parser/xhtml.php
  
This uses the [http://www.dokuwiki.org/plugin:goto DokuWiki Goto Plugin]
+
The header of a section is defined in xhtml's function header().
  
Replace GOTO with REDIRECT:
+
xhtml.php contains finishSectionEdit($pos). This creates a line like
<pre>
+
<!-- EDIT1 SECTION "heading 1"[1-59] -->
/srv/www/htdocs/dokuwiki/lib/plugins/goto # diff -rup syntax.php.org syntax.php
+
--- syntax.php.org      2010-01-16 21:48:26.000000000 +0100
+
+++ syntax.php  2010-01-16 21:47:36.000000000 +0100
+
@@ -28,7 +28,7 @@ class  syntax_plugin_goto extends DokuWi
+
                }
+
  
                function connectTo($mode) {
+
$this->sectionedits[] filled by inc/parser/xhtml.php's startSectionEdit().
-                      $this->Lexer->addSpecialPattern('(?i)~~GOTO>.+?~~',$mode,'plugin_goto');
+
+                      $this->Lexer->addSpecialPattern('(?i)#REDIRECT [[.+?]]',$mode,'plugin_goto');
+
                        }
+
  
                        function getSort() {
+
html_secedit replaces
@@ -45,7 +45,7 @@ class syntax_plugin_goto extends DokuWi
+
  <!-- EDIT(\d+) ([A-Z_]+) (?:"([^"]*)" )?\[(\d+-\d*)\] -->
                                $message = "<strong>You will be redirected to %d in approximately %s seconds.</strong>";
+
by some text
 
+
                                global $ID;
+
-                               $matches = explode("?", substr($match,7,-2));
+
+                              $matches = explode("?", substr($match,12,-2));
+
                                if (is_numeric($matches[1])){ $seconds = $matches[1]; }
+
                                if ($seconds < $minSeconds){ $seconds = $minSeconds; }//Check that seconds is greater than $minSeconds.
+
                                resolve_pageid(getNS($ID), $matches[0], $exists);
+
</pre>
+
 
+
= use mediawiki syntax in dokuwiki =
+
Take a look at inc/parser/handler.php, function header().
+
 
+
== preformatted ==
+
@@ -522,12 +523,13 @@ class Doku_Parser_Mode_html extends Doku
+
  class Doku_Parser_Mode_preformatted extends Doku_Parser_Mode {
+
+
      function connectTo($mode) {
+
+    echo "hi";
+
          // Has hard coded awareness of lists...
+
-        $this->Lexer->addEntryPattern('\n  (?![\*\-])',$mode,'preformatted');
+
+       $this->Lexer->addEntryPattern('\n (?![\*\-])',$mode,'preformatted');
+
          $this->Lexer->addEntryPattern('\n\t(?![\*\-])',$mode,'preformatted');
+
+
          // How to effect a sub pattern with the Lexer!
+
-        $this->Lexer->addPattern('\n  ','preformatted');
+
+        $this->Lexer->addPattern('\n ','preformatted');
+
          $this->Lexer->addPattern('\n\t','preformatted');
+
+
      }
+
 
+
== unordered list items ==
+
<pre>
+
diff -rup ../../../dokuwiki-org/inc//parser/handler.php ../../../dokuwiki/inc//parser/handler.php
+
--- ../../../dokuwiki-org/inc//parser/handler.php      2010-03-20 12:06:55.542759536 +0100
+
+++ ../../../dokuwiki/inc//parser/handler.php  2010-03-20 12:58:04.250509934 +0100
+
@@ -1000,7 +1000,7 @@ class Doku_Handler_List {
+
        }
+
        // Is the +1 needed? It used to be count(explode(...))
+
        // but I don't think the number is seen outside this handler
+
-        return substr_count(str_replace("\t",'  ',$match), '  ') + 1;
+
+        return substr_count(str_replace("\t",'  ',$match), '*') + 1;
+
    }
+
}
+
 
+
diff -rup ../../../dokuwiki-org/inc//parser/parser.php ../../../dokuwiki/inc//parser/parser.php
+
--- ../../../dokuwiki-org/inc//parser/parser.php        2010-03-20 12:06:55.543759723 +0100
+
+++ ../../../dokuwiki/inc//parser/parser.php    2010-03-20 13:00:31.737537661 +0100
+
@@ -413,11 +413,11 @@ class Doku_Parser_Mode_listblock extends
+
    }
+
 
+
    function connectTo($mode) {
+
-        $this->Lexer->addEntryPattern('\n {2,}[\-\*]',$mode,'listblock');
+
-        $this->Lexer->addEntryPattern('\n\t{1,}[\-\*]',$mode,'listblock');
+
+        $this->Lexer->addEntryPattern('\n {0,}[\-\*]+',$mode,'listblock');
+
+        $this->Lexer->addEntryPattern('\n\t{0,}[\-\*]+',$mode,'listblock');
+
 
+
-        $this->Lexer->addPattern('\n {2,}[\-\*]','listblock');
+
-        $this->Lexer->addPattern('\n\t{1,}[\-\*]','listblock');
+
+        $this->Lexer->addPattern('\n {0,}[\-\*]+','listblock');
+
+        $this->Lexer->addPattern('\n\t{0,}[\-\*]+','listblock');
+
 
+
    }
+
</pre>
+
 
+
== Headings ==
+
Headings in dokuwiki are different from headings in mediawiki. While ====== means Heading 1 in Dokuwiki, it means Heading 6 in mediawiki. The following patch changes this:
+
<pre>
+
--- dokuwiki-org/inc/parser/xhtml.php  2010-03-20 10:42:34.000000000 +0100
+
+++ dokuwiki/inc/parser/xhtml.php      2010-03-20 14:37:38.000000000 +0100
+
@@ -100,8 +100,8 @@ class Doku_Renderer_xhtml extends Doku_R
+
        global $conf;
+
 
+
        //handle TOC
+
-        if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
+
-            $this->toc[] = html_mktocitem($id, $text, $level-$conf['toptoclevel']+1);
+
+        if($level >= $conf['toptoclevel'] && (7-$level) <= $conf['maxtoclevel']){
+
+            $this->toc[] = html_mktocitem($id, $text, (7-$level)-$conf['toptoclevel']+1);
+
        }
+
    }
+
 
+
@@ -123,7 +123,7 @@ class Doku_Renderer_xhtml extends Doku_R
+
        $this->lastlevel = $level;
+
 
+
        // write the header
+
-        $this->doc .= DOKU_LF.'<h'.$level.'><a name="'.$hid.'" id="'.$hid.'">';
+
+        $this->doc .= DOKU_LF.'<h'.(7-$level).'><a name="'.$hid.'" id="'.$hid.'">';
+
        $this->doc .= $this->_xmlEntities($text);
+
        $this->doc .= "</a></h$level>".DOKU_LF;
+
    }
+
</pre>
+
 
+
= All =
+
tweedleburg:/srv/www/htdocs/dokuwiki/inc # diff -rup parser.org/ parser                 
+
diff -rup parser.org//parser.php parser/parser.php                                       
+
--- parser.org//parser.php      2009-10-23 08:44:18.000000000 +0200                     
+
+++ parser/parser.php  2009-10-23 09:42:24.000000000 +0200                             
+
@@ -221,7 +221,7 @@ class Doku_Parser_Mode_header extends Do                             
+
      function preConnect() {                                                             
+
          //we're not picky about the closing ones, two are enough                       
+
          $this->Lexer->addSpecialPattern(                                               
+
-                            '[ \t]*={2,}[^\n]+={2,}[ \t]*(?=\n)',                       
+
+                            '[ \t]*={1,}[^\n]+={1,}[ \t]*(?=\n)',                       
+
                              'base',                                                     
+
                              'header'                                                   
+
                          );                                                             
+
@@ -523,11 +523,11 @@ class Doku_Parser_Mode_preformatted exte                           
+
                                                                                         
+
      function connectTo($mode) {                                                         
+
          // Has hard coded awareness of lists...                                         
+
-       $this->Lexer->addEntryPattern('\n  (?![\*\-])',$mode,'preformatted');           
+
+        $this->Lexer->addEntryPattern('\n (?![\*\-])',$mode,'preformatted');           
+
          $this->Lexer->addEntryPattern('\n\t(?![\*\-])',$mode,'preformatted');
+
+
          // How to effect a sub pattern with the Lexer!
+
-        $this->Lexer->addPattern('\n  ','preformatted');
+
+        $this->Lexer->addPattern('\n ','preformatted');
+
          $this->Lexer->addPattern('\n\t','preformatted');
+
+
      }
+
@@ -545,11 +545,11 @@ class Doku_Parser_Mode_preformatted exte
+
  class Doku_Parser_Mode_code extends Doku_Parser_Mode {
+
+
      function connectTo($mode) {
+
-        $this->Lexer->addEntryPattern('<code(?=.*</code>)',$mode,'code');
+
+        $this->Lexer->addEntryPattern('<pre(?=.*</pre>)',$mode,'code');
+
      }
+
+
      function postConnect() {
+
-        $this->Lexer->addExitPattern('</code>','code');
+
+        $this->Lexer->addExitPattern('</pre>','code');
+
      }
+
+
      function getSort() {
+
Only in parser: parser.php~
+
diff -rup parser.org//xhtml.php parser/xhtml.php
+
--- parser.org//xhtml.php      2009-10-23 08:44:18.000000000 +0200
+
+++ parser/xhtml.php    2009-10-23 09:38:15.000000000 +0200
+
@@ -99,7 +99,7 @@ class Doku_Renderer_xhtml extends Doku_R
+
+
          //handle TOC
+
          if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
+
-            $this->toc[] = html_mktocitem($id, $text, $level-$conf['toptoclevel']+1);
+
+            $this->toc[] = html_mktocitem($id, $text, (7-$level)-$conf['toptoclevel']+1);
+
          }
+
      }
+
+
@@ -112,7 +112,7 @@ class Doku_Renderer_xhtml extends Doku_R
+
          $this->toc_additem($hid, $text, $level);
+
+
          // write the header
+
-        $this->doc .= DOKU_LF.'<h'.$level.'><a name="'.$hid.'" id="'.$hid.'">';
+
+        $this->doc .= DOKU_LF.'<h'.(7-$level).'><a name="'.$hid.'" id="'.$hid.'">';
+
          $this->doc .= $this->_xmlEntities($text);
+
          $this->doc .= "</a></h$level>".DOKU_LF;
+
      }
+
Only in parser: xhtml.php~
+
 
+
= See also =
+
* http://johbuc6.coconia.net/mediawiki2dokuwiki.php
+
* http://www.dokuwiki.org/devel:parser?s[]=wiki&s[]=parser
+

Latest revision as of 20:01, 10 July 2011

This page is here for historic reasons. You can browse through its versions by selecting the tab "history". The page used to describe how I adapt Dokuwiki for my needs, but I can do this now entirely using the mediasyntax plugin for dokuwiki.

Where do you want to go?

program

editsections

inc/parser/xhtml.php

The header of a section is defined in xhtml's function header().

xhtml.php contains finishSectionEdit($pos). This creates a line like

$this->sectionedits[] filled by inc/parser/xhtml.php's startSectionEdit().

html_secedit replaces by some text