tstaerk / mediasyntax

Mediasyntax is a plugin for Dokuwiki that enables Mediawiki syntax.
http://www.staerk.de/thorsten/Mediasyntax
GNU General Public License v2.0
10 stars 6 forks source link

code blocks dont work #34

Closed tstaerk closed 1 year ago

tstaerk commented 1 year ago

Code blocks used to work but don't seem to work any longer. Test code:

this is a

pre line

blablabla

tstaerk commented 1 year ago

I got it fixed with this patch:

root@mediasyntax-test:/var/www/html/dokuwiki/lib/plugins/mediasyntax/syntax# diff /home/thorsten/mediasyntax/syntax/codeblock.php codeblock.php 48,51c48 < for ($i = 1; $i < strlen($match); $i++) { < if ($match[$i - 1] == "\n" && $match[$i] == " ") {; < } else $match2 .= $match[$i]; < }

echo($match);

53a51 return false; 55a54 return false;

however I do not understand why

tstaerk commented 1 year ago

and again as a unified patch:

root@mediasyntax-test:/var/www/html/dokuwiki/lib/plugins/mediasyntax/syntax# diff -rup /home/thorsten/mediasyntax/syntax/codeblock.php codeblock.php --- /home/thorsten/mediasyntax/syntax/codeblock.php 2023-07-29 15:36:25.082485463 +0000 +++ codeblock.php 2023-07-29 15:33:45.254580493 +0000 @@ -45,14 +45,13 @@ class syntax_plugin_mediasyntax_codebloc { // $match2 = $match, but cut one blank at the beginning of every line. $match2 = $match;

tstaerk commented 1 year ago

and again in a codeblock: `root@mediasyntax-test:/var/www/html/dokuwiki/lib/plugins/mediasyntax/syntax# diff -rup /home/thorsten/mediasyntax/syntax/codeblock.php codeblock.php --- /home/thorsten/mediasyntax/syntax/codeblock.php 2023-07-29 15:36:25.082485463 +0000 +++ codeblock.php 2023-07-29 15:33:45.254580493 +0000 @@ -45,14 +45,13 @@ class syntax_plugin_mediasyntax_codebloc { // $match2 = $match, but cut one blank at the beginning of every line. $match2 = $match;

tstaerk commented 1 year ago

Or easier:

root@mediasyntax-test:/var/www/html/dokuwiki/lib/plugins/mediasyntax/syntax# diff -rup /home/thorsten/mediasyntax/syntax/codeblock.php codeblock.php 
--- /home/thorsten/mediasyntax/syntax/codeblock.php     2023-07-29 15:36:25.082485463 +0000
+++ codeblock.php       2023-07-29 15:45:42.610155230 +0000
@@ -44,14 +44,14 @@ class syntax_plugin_mediasyntax_codebloc
   function handle($match, $state, $pos, Doku_Handler $handler)
   {
     // $match2 = $match, but cut one blank at the beginning of every line.
-    $match2 = $match;
+    $match2 = "";
     for ($i = 1; $i < strlen($match); $i++) {
       if ($match[$i - 1] == "\n" && $match[$i] == " ") {;
       } else $match2 .= $match[$i];
     }
     switch ($state) {
       case DOKU_LEXER_ENTER:
-        return array($state, $match2);
+        return false;
       case DOKU_LEXER_MATCHED:
         return array($state, $match2);
       case DOKU_LEXER_UNMATCHED:

Now I don't understand how it could ever work before.