Update of /var/cvs/src/org/mmbase/util/transformers
In directory james.mmbase.org:/tmp/cvs-serv19440

Modified Files:
      Tag: MMBase-1_8
        XmlField.java 
Log Message:
fixed failing test-case:   MMB-1654


See also: http://cvs.mmbase.org/viewcvs/src/org/mmbase/util/transformers
See also: http://www.mmbase.org/jira/browse/MMB-1654


Index: XmlField.java
===================================================================
RCS file: /var/cvs/src/org/mmbase/util/transformers/XmlField.java,v
retrieving revision 1.46.2.3
retrieving revision 1.46.2.4
diff -u -b -r1.46.2.3 -r1.46.2.4
--- XmlField.java       3 Jun 2008 11:18:45 -0000       1.46.2.3
+++ XmlField.java       4 Jun 2008 14:31:52 -0000       1.46.2.4
@@ -20,7 +20,7 @@
  * XMLFields in MMBase. This class can encode such a field to several other 
formats.
  *
  * @author Michiel Meeuwissen
- * @version $Id: XmlField.java,v 1.46.2.3 2008/06/03 11:18:45 michiel Exp $
+ * @version $Id: XmlField.java,v 1.46.2.4 2008/06/04 14:31:52 michiel Exp $
  * @todo   THIS CLASS NEEDS A CONCEPT! It gets a bit messy.
  */
 
@@ -234,6 +234,27 @@
         obj.replace("_", sch);
     }
 
+
+    /**
+     * Makes sure that lines indicating headers (starting with $), are 
followed by at least 2
+     * newlines, if followed by some list.
+     * @since MMBase-1.8.6
+     */
+    static void preHandleHeaders(StringObject obj) {
+
+        int pos = obj.charAt(0) == '$' ? 0 : obj.indexOf("\n$");
+        while (pos >= 0) {
+            // search newline
+            pos++;
+            int nextLine = obj.indexOf("\n", pos);
+            char firstChar = obj.charAt(nextLine + 1);
+            if (isListChar(firstChar)) {
+                obj.insert(nextLine, "\n");
+                pos++;
+            }
+            pos = obj.indexOf("\n$", pos);
+        }
+    }
     /**
      * Some paragraphs are are really \sections. So this handler can
      * be done after handleParagraphs. It will search the paragraphs
@@ -689,6 +710,9 @@
 
     protected static void handleRich(StringObject obj, boolean sections, 
boolean leaveExtraNewLines, boolean surroundingP, boolean placeListsInsideP) {
         // the order _is_ important!
+        if (sections) {
+            preHandleHeaders(obj);
+        }
         handleList(obj);
         handleTables(obj);
         handleParagraphs(obj, leaveExtraNewLines, surroundingP, 
placeListsInsideP);
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to