r9798 - helma-ng/trunk/src/org/helma/util

[email protected] Sat, 16 May 2009 21:45:48 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090516194548.D8AF83D0D6@mia>
Author: hannes
Date: 2009-05-16 21:45:48 +0200 (Sat, 16 May 2009)
New Revision: 9798

Modified:
   helma-ng/trunk/src/org/helma/util/MarkdownProcessor.java
Log:
Follow quirks of official markdown implementation: Allow one space character between [linktext] [target], but not in [linktext](http://target)

Details at http://dev.helma.org/trac/helma/changeset/9798

Modified: helma-ng/trunk/src/org/helma/util/MarkdownProcessor.java
===================================================================
--- helma-ng/trunk/src/org/helma/util/MarkdownProcessor.java	2009-05-16 19:15:30 UTC (rev 9797)
+++ helma-ng/trunk/src/org/helma/util/MarkdownProcessor.java	2009-05-16 19:45:48 UTC (rev 9798)
@@ -595,9 +595,13 @@
         String linkId;
         int k = j;
         j += 1;
-        /* if (j < length && isSpace(chars[j])) {
+        // this is weird, bug we follow the official markup implementation here:
+        // only accept space between link text and link target for [][], not for []()
+        boolean extraSpace = false;
+        if (j < length && isSpace(chars[j])) {
             j += 1;
-        } */
+            extraSpace = true;
+        }
         c = chars[j++];
         if (c == '[') {
             while (j < length && chars[j] != ']') {
@@ -620,7 +624,7 @@
                     return false;
                 }
             }
-        } else if (c == '(') {
+        } else if (c == '(' && !extraSpace) {
             link = new String[2];
             while (j < length && chars[j] != ')' && !isSpace(chars[j])) {
                 if (chars[j] == '\n') {