diff --git a/main/trunk/build.xml b/main/trunk/build.xml index 2d2776f..6a6920f 100644 --- a/main/trunk/build.xml +++ b/main/trunk/build.xml @@ -16,6 +16,7 @@ + @@ -56,7 +57,7 @@ - + - + diff --git a/main/trunk/conf/radeox_markup.properties b/main/trunk/conf/radeox_markup.properties index 8eed820..9494ede 100644 --- a/main/trunk/conf/radeox_markup.properties +++ b/main/trunk/conf/radeox_markup.properties @@ -73,7 +73,7 @@ filter.wikilink.match=([A-Z][a-z]+([A-Z][a-z]+)+) filter.param.match=\\{\\$([^}]*)\\} -filter.list.match=(^[\\p{Space}]*([-#*]+|[-#*]*[iIaA1ghHkKj]+\\.)[\\p{Space}]+([^\r\n]+)[\r\n]*)+ +filter.list.match=(^[\\p{Space}]*([-#*]+|[-#*]*[iIaA1ghHkKj]+\\.)[ ]+([^\r\n]+)[\r\n]*)+ #filter.list.match=^[\\p{Space}]*([-#*]+[\\p{Space}]+|[-#*]?[iIaA1ghHkKj][-#*iIaA1ghHkKj]*\\.[\\p{Space}]+)(\r?\n[\\p{Space}]*(?:([-#*]+[\\p{Space}]+)|([-#*]?[iIaA1ghHkKj][-#*iIaA1ghHkKj]*\\.[\\p{Space}]+))|[^\\r\\n]+)*$ #filter.list.match=^[\\p{Space}]*([-#*]+[\\p{Space}]+|[iIaA1ghHkKj][iIaA1ghHkKj]*[.][\\p{Space}]+)(?:([-#*]+[\\p{Space}]+)|([iIaA1ghHkKj][iIaA1ghHkKj]*[.][\\p{Space}]+)|.+)*$ -filter.list.Creole.match=(^[\\p{Space}]*([#-]+)[\\p{Space}]+([^\r\n]+)[\r\n]*)+ +filter.list.Creole.match=(^[\\p{Space}]*([#-]+)[ ]+([^\r\n]+)[\r\n]*)+ diff --git a/main/trunk/src/java/org/radeox/filter/ListFilter.java b/main/trunk/src/java/org/radeox/filter/ListFilter.java index cdeb91c..8b81128 100644 --- a/main/trunk/src/java/org/radeox/filter/ListFilter.java +++ b/main/trunk/src/java/org/radeox/filter/ListFilter.java @@ -46,6 +46,9 @@ public class ListFilter extends LocaleRegexTokenFilter implements CacheFilter { private final static Map openList = new HashMap(); private final static Map closeList = new HashMap(); + private static final String NEWLINE = "\n"; + private static final String LI_OPEN = "
  • "; + private static final String LI_CLOSE = "
  • "; private static final String UL_CLOSE = ""; private static final String OL_CLOSE = ""; @@ -136,22 +139,38 @@ private void addList(StringBuffer buffer, BufferedReader reader) throws IOExcept for (int i = sharedPrefixEnd; i < lastBullet.length; i++) { //Logger.log("closing " + lastBullet[i]); + buffer.append(LI_CLOSE + NEWLINE); buffer.append(closeList.get(new Character(lastBullet[i]))).append("\n"); } for (int i = sharedPrefixEnd; i < bullet.length; i++) { //Logger.log("opening " + bullet[i]); + if(i > 0) + { + buffer.append(NEWLINE); + } buffer.append(openList.get(new Character(bullet[i]))).append("\n"); + buffer.append(LI_OPEN); + } + + if(lastBullet.length >= bullet.length) + { + buffer.append(LI_CLOSE + NEWLINE); + buffer.append(LI_OPEN); } - buffer.append("
  • "); + buffer.append(line.substring(line.indexOf(' ') + 1)); - buffer.append("
  • \n"); lastBullet = bullet; } for (int i = lastBullet.length - 1; i >= 0; i--) { //Logger.log("closing " + lastBullet[i]); + buffer.append(LI_CLOSE + NEWLINE); buffer.append(closeList.get(new Character(lastBullet[i]))); + if(i > 0) + { + buffer.append(NEWLINE); + } } } -} \ No newline at end of file +} diff --git a/main/trunk/src/test/org/radeox/filter/ListFilterTest.java b/main/trunk/src/test/org/radeox/filter/ListFilterTest.java index 4114f69..c86b5f6 100644 --- a/main/trunk/src/test/org/radeox/filter/ListFilterTest.java +++ b/main/trunk/src/test/org/radeox/filter/ListFilterTest.java @@ -1,10 +1,10 @@ package org.radeox.filter; /* - * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its + * Copyright 2001-2004 Fraunhofer Gesellschaft, Munich, Germany, for its * Fraunhofer Institute Computer Architecture and Software Technology * (FIRST), Berlin, Germany - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -27,23 +27,29 @@ public class ListFilterTest extends FilterTestSupport { private static final String RESULT_UNNUMBERED_2 = "
      \n
    • test
    • \n
    • test
    • \n
    "; private static final String RESULT_ORDERED = "
      \n
    1. test
    2. \n
    3. test
    4. \n
    5. test
    6. \n
    "; private static final String RESULT_NESTED_SIMPLE = "
      \n" + - "
    • test
    • \n" + + "
    • test\n" + "
        \n" + "
      • test
      • \n" + "
      • test
      • \n" + "
      \n" + - "
    • test
    • \n" + + "\n" + "
    "; private static final String RESULT_NESTED_LIST = "
      \n" + - "
    • test
    • \n" + + "
    • test\n" + + "
        \n" + + "
      1. \n" + "
          \n" + "
        1. test
        2. \n" + "
        3. test
        4. \n" + "
        \n" + + "
      2. \n" + + "
      \n" + + "
    • \n" + "
    • test
    • \n" + "
    "; - protected void setUp() throws Exception { + @Override +protected void setUp() throws Exception { filter = new ListFilter(); // context.getRenderContext().setRenderEngine((RenderEngine) // new MockWikiRenderEngine() @@ -59,6 +65,8 @@ public void testListsWithStrike() { assertEquals("
      \n" + "
    • test
    • \n" + "
    • test
    • \n" + + "
    -----\n" + + "
      \n" + "
    • test
    • \n" + "
    ", filter.filter("- test\n- test\n\n-----\n\n- test", context)); } @@ -90,15 +98,15 @@ public void testOrderedListCreole() { } public void testSimpleNestedList() { - assertEquals(RESULT_NESTED_SIMPLE, filter.filter("- test\r\n-- test\r\n-- test\r\n- test", context)); + assertEquals(RESULT_NESTED_SIMPLE, filter.filter("- test\r\n-- test\r\n-- test", context)); } public void testSimpleNestedListCreole() { - assertEquals(RESULT_NESTED_SIMPLE, filter.filter("- test\r\n-- test\r\n-- test\r\n- test", context)); + assertEquals(RESULT_NESTED_SIMPLE, filterCreole.filter("- test\r\n-- test\r\n-- test", context)); } public void testNestedList() { - assertEquals(RESULT_NESTED_LIST, filter.filter("- test\n-a. test\n-a. test\n- test", context)); + assertEquals(RESULT_NESTED_LIST, filter.filter("- test\n-aa. test\n-aa. test\n- test", context)); } public void testSequentialLists() { @@ -117,4 +125,22 @@ public void testListWithLinks() { "
  • [test test2]
  • \n" + "", filter.filter("- [test]\n- [test1]\n- [test test2]\n", context)); } + + public void testWrongListFormat() { + final String markup = "paragraph01\r\n"+ + "\r\n" + + // wrong list element mark (no content) + "--- \n" + + "\r\n" + + "paragraph02\r\n" + + "\r\n" + + // wrong list element mark (no space and no content) + "---\n" + + "\r\n" + + "paragraph03\r\n"; + final String out = filter.filter(markup, context); + // output should be the same as input + assertEquals(markup, out); + } + } diff --git a/pom.xml.tobefixed b/pom.xml.tobefixed new file mode 100644 index 0000000..d67e9a3 --- /dev/null +++ b/pom.xml.tobefixed @@ -0,0 +1,144 @@ + + 4.0.0 + radeox + radeox + 1.1-verbis + radeox + + main/trunk/src/java + main/trunk/src/test + + + main/trunk/src/java + + **/*.java + + + + main/trunk/conf + + **/*.java + + + + + + maven-compiler-plugin + 3.7.0 + + + default-compile + compile + + compile + + + true + 1.7 + 1.7 + + + + default-testCompile + test-compile + + testCompile + + + true + 1.7 + 1.7 + + + + + 1.7 + 1.7 + + + + maven-jar-plugin + 2.3.1 + + + default-jar + package + + jar + + + + + + + + iso-8859-1 + + + + commons-logging + commons-logging + 1.1 + + + org.jmock + jmock + 2.4.0 + test + + + org.jmock + jmock-junit3 + 2.4.0 + test + + + org.jmock + jmock-cglib + 1.0.0.RC1 + test + + + org.jmock + jmock-legacy + 2.4.0 + test + + + oro + oro + 2.0.8 + + + oro + oro + 2.0.8 + + + picocontainer + picocontainer + 1.1 + + + xstream + xstream + + + xpp3 + xpp3 + + + + + org.codehaus.groovy + groovy-all + 1.0-rc1-snapshot + + + junitperf + junitperf + 1.8 + test + + + \ No newline at end of file