A pacth to JSPWikiMarkupParser to permit line break in table definition :

This:

||Col A || Col B || Col C
| a | b | c
| aa\\aaaaa | bbb | cc
and this:
||Col A || Col B || Col C
| a | b | c
| aa\\
aaaaa | bbb | cc
Will now produce the same result:
Col A Col B Col C
a b c
aa
aaaaa
bbb cc
Index: src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java
===================================================================
RCS file: /p/cvs/JSPWiki/src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java,v
retrieving revision 1.18
diff -u -r1.18 JSPWikiMarkupParser.java
--- src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java	15 Nov 2005 19:54:18 -0000	1.18
+++ src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java	16 Nov 2005 14:59:18 -0000
@@ -90,6 +90,8 @@
 
 
     private boolean        m_isOpenParagraph = false;
+    private boolean        m_isLineBreak  = false;
+
 
     /** Keeps image regexp Patterns */
     private ArrayList      m_inlineImagePatterns;
@@ -1421,6 +1423,7 @@
 
         if( ch == '\\' )
         {
+            m_isLineBreak = true;
             int ch2 = nextToken();
 
             if( ch2 == '\\' )
@@ -2247,7 +2250,7 @@
                 m_plainTextBuf.append(unwindGeneralList());
             }
 
-            if( newLine && ch != '|' && m_istable )
+            if( newLine && ch != '|' && !m_isLineBreak && m_istable )
             {
                 el = popElement("table");
                 m_istable = false;
@@ -2272,8 +2275,8 @@
                 popElement("h2");
                 popElement("h3");
                 popElement("h4");
-                if( m_istable ) 
-                { 
+                if( m_istable && !m_isLineBreak)
+                {
                     popElement("tr");
                 }
                 
@@ -2323,6 +2326,10 @@
 
               case '\\':
                 el = handleBackslash();
+                if (m_isLineBreak) {
+                    continue;
+                }
+
                 break;
 
               case '_':
@@ -2391,7 +2398,7 @@
                 break;
 
               case '|':
-                el = handleBar( newLine );
+                el = handleBar( newLine && !m_isLineBreak );
                 break;
 
               case '~':
@@ -2419,17 +2426,21 @@
             if( el != null )
             {
                 newLine = false;
+                m_isLineBreak = false;
+
             }
             else
             {
                 m_plainTextBuf.append( (char) ch );
                 newLine = false;
+                m_isLineBreak = false;
             }
             
             if( s != null )
             {
                 m_plainTextBuf.append( s );
                 newLine = false;
+                m_isLineBreak = false;
             }
         }
         

Category Patches Laurent Courtin

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-2) was last changed on 16-Nov-2005 17:01 by LaurentCourtin