Update of /var/cvs/src/org/mmbase/util/transformers
In directory james.mmbase.org:/tmp/cvs-serv19376
Modified Files:
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.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- XmlField.java 3 Jun 2008 11:18:31 -0000 1.54
+++ XmlField.java 4 Jun 2008 14:30:25 -0000 1.55
@@ -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.54 2008/06/03 11:18:31 michiel Exp $
+ * @version $Id: XmlField.java,v 1.55 2008/06/04 14:30:25 michiel Exp $
*/
public class XmlField extends ConfigurableStringTransformer implements
CharTransformer {
@@ -232,6 +232,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
@@ -361,7 +382,7 @@
int pos = 0;
// we should actually test if the first bit is a list, and if so, skip
it
if (surroundingP) {
- if (!placeListsInsideP && containsListTag(obj,pos)) {
+ if (!placeListsInsideP && containsListTag(obj, pos)) {
//note: this does not take into account nested lists
int posEnd = obj.indexOf("</" + obj.charAt(pos + 1)+ "l>", pos
+ 1);
// only continue this if this is a balanced list
@@ -703,6 +724,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