maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject [maven-doxia] 01/03: [DOXIA-577] Handle whitespace in tables properly in ConfluenceSink. Line breaks within a table are removed. Any whitespace-only content is trimmed.
Date Thu, 22 Nov 2018 12:06:43 GMT
This is an automated email from the ASF dual-hosted git repository.

dennisl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 41ad6cd454dcd6fed8d61e1ed712bdb23cc42286
Author: Dennis Lundberg <dennisl@apache.org>
AuthorDate: Thu Nov 22 12:47:08 2018 +0100

    [DOXIA-577] Handle whitespace in tables properly in ConfluenceSink.
    Line breaks within a table are removed.
    Any whitespace-only content is trimmed.
---
 .../doxia/module/confluence/ConfluenceSink.java     | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
b/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
index 17e6000..6516dbc 100644
--- a/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
+++ b/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceSink.java
@@ -61,6 +61,9 @@ public class ConfluenceSink
     /** An indication on if we're in verbatim box mode. */
     private boolean verbatimBoxedFlag;
 
+    /** An indication on if we're in table mode. */
+    private boolean tableFlag;
+
     /** An indication on if we're in table header mode. */
     private boolean tableHeaderFlag;
 
@@ -819,6 +822,7 @@ public class ConfluenceSink
     public void table()
     {
         // nop
+        tableFlag = true;
         writeEOL( true );
         writeEOL();
     }
@@ -832,6 +836,7 @@ public class ConfluenceSink
     /** {@inheritDoc} */
     public void table_()
     {
+        tableFlag = false;
         writeEOL( true );
         writeEOL();
     }
@@ -964,7 +969,21 @@ public class ConfluenceSink
             write( LINK_START_MARKUP );
         }
 
-        content( text );
+        if ( tableFlag )
+        {
+            // Remove line breaks, because it interferes with the table syntax
+            String strippedText = StringUtils.replace( text, "\n", "" );
+            // Trim if only whitespace, to handle ignorable whitespace from xdoc documents
+            if ( StringUtils.isWhitespace( strippedText ) )
+            {
+                strippedText = StringUtils.trim( strippedText );
+            }
+            content( strippedText );
+        }
+        else
+        {
+            content( text );
+        }
 
         if ( linkName != null )
         {


Mime
View raw message