[dokuwiki] Greedy brackets for footnote syntax

  • From: Dmitry Katsubo <dma_k@xxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Thu, 08 Oct 2009 20:50:04 +0200

Dear dokuwiki users!

Recently I have discovered the following fact:

- By syntax definition, footnote starts with first occurrence of double
opening bracket '(('
- footnote also ends with first occurrence of closing double bracket '))'

and here comes the problem, when I want to use (1) brackets in footnote
or (2) footnote is itself in brackets:

1. ((Some footnote text (also [[see here]]))).
2. (I am sure bug was found before((Have a look at [[this bug]]))).
3. (((possibly true) This is obvious!)).
4. (((TODO: contact him)) the author is wrong).

Current implementation will display (1) not correctly, while (2) will be
fine. Cases (3) and (4) are also fine.

In order to fix (1) one should write:

1. ((Some footnote text (also [[see here]])) ).

notice a space before a bracket, which will appear after a footnote
reference.

I personally think, that closing brackets should be greedy and that
solves (1) but makes (2) a problem unless you trick with a space.

I wonder, if there any universal solution?

Index: inc/parser/parser.php
===================================================================
--- inc/parser/parser.php       (revision 139)
+++ inc/parser/parser.php       (working copy)
@@ -208,7 +208,7 @@
 
     function postConnect() {
         $this->Lexer->addExitPattern(
-            '\x29\x29','footnote'
+            '\x29\x29(?!\x29)','footnote'
             );
     }
 

Other related posts: