diff options
author | Jeremie Bresson | 2012-09-19 16:58:46 +0000 |
---|---|---|
committer | Jeremie Bresson | 2012-09-19 16:58:46 +0000 |
commit | b73a9a5714c818dddcb2a1053b94ab9c425a819f (patch) | |
tree | 49a72362ceb8533ec313889d9aed1f46e311e6f3 | |
parent | e97a346472a084d296f707d80c33344facd87b7d (diff) | |
download | org.eclipse.mylyn.docs-b73a9a5714c818dddcb2a1053b94ab9c425a819f.tar.gz org.eclipse.mylyn.docs-b73a9a5714c818dddcb2a1053b94ab9c425a819f.tar.xz org.eclipse.mylyn.docs-b73a9a5714c818dddcb2a1053b94ab9c425a819f.zip |
389812: TracWiki rendered text does not match formatting of Trac's
native rendering
- Modification of the Trac List Bloc.
- Add tests.
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=389812
Change-Id: Ic23fdb163c3e1831bd72dddccc8cd30860cb1ae9
2 files changed, 37 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tracwiki/core/TracWikiLanguageTest.java b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tracwiki/core/TracWikiLanguageTest.java index c63e873fd..cfa989bf8 100644 --- a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tracwiki/core/TracWikiLanguageTest.java +++ b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/wikitext/tracwiki/core/TracWikiLanguageTest.java @@ -8,6 +8,7 @@ * Contributors: * David Green - initial API and implementation * Holger Voormann - tests for bug 279029 + * Jeremie Bresson - bug 389812 *******************************************************************************/ package org.eclipse.mylyn.wikitext.tracwiki.core; @@ -280,6 +281,22 @@ public class TracWikiLanguageTest extends TestCase { assertTrue(html.contains("<body><ul><li>a list</li><li>with two lines</li></ul></body>")); } + public void testListUnorderedWithoutSpacePrefix() throws Exception { + //bug 389812 + String html = parser.parseToHtml("* a list\n* with two lines"); + + TestUtil.println("HTML: \n" + html); + assertTrue(html.contains("<body><ul><li>a list</li><li>with two lines</li></ul></body>")); + } + + public void testListUnorderedBigSpacePrefix() throws Exception { + //bug 389812 + String html = parser.parseToHtml(" * a list\n * with two lines"); + + TestUtil.println("HTML: \n" + html); + assertTrue(html.contains("<body><ul><li>a list</li><li>with two lines</li></ul></body>")); + } + public void testListUnorderedWithHyphens() throws IOException { String html = parser.parseToHtml(" - a list\n - with two lines"); @@ -297,6 +314,14 @@ public class TracWikiLanguageTest extends TestCase { assertTrue(html.contains("</ol>")); } + public void testListOrderedWithoutSpacePrefix() throws Exception { + //bug 389812 + String html = parser.parseToHtml("1. a list\n1. with two lines"); + + TestUtil.println("HTML: \n" + html); + assertTrue(html.contains("<body><ol><li>a list</li><li>with two lines</li></ol></body>")); + } + public void testListOrderedStartAt2() throws IOException { String html = parser.parseToHtml(" 2. with two lines\n 3. three"); @@ -321,6 +346,14 @@ public class TracWikiLanguageTest extends TestCase { assertTrue(html.contains("</ol>")); } + public void testListNestedUnordered() throws Exception { + //bug 389812 + String html = parser.parseToHtml("* Apples\n * Sauce\n * Juice\n* Oranges\n* Grapes"); + + TestUtil.println("HTML: \n" + html); + assertTrue(html.contains("<ul><li>Apples<ul><li>Sauce</li><li>Juice</li></ul></li><li>Oranges</li><li>Grapes</li></ul>")); + } + public void testListNestedMixed() throws IOException { String html = parser.parseToHtml(" 1. a list\n * nested\n * nested2\n 1. level1\n\npara"); diff --git a/org.eclipse.mylyn.wikitext.tracwiki.core/src/org/eclipse/mylyn/internal/wikitext/tracwiki/core/block/ListBlock.java b/org.eclipse.mylyn.wikitext.tracwiki.core/src/org/eclipse/mylyn/internal/wikitext/tracwiki/core/block/ListBlock.java index ca96b1f7e..d2987d882 100644 --- a/org.eclipse.mylyn.wikitext.tracwiki.core/src/org/eclipse/mylyn/internal/wikitext/tracwiki/core/block/ListBlock.java +++ b/org.eclipse.mylyn.wikitext.tracwiki.core/src/org/eclipse/mylyn/internal/wikitext/tracwiki/core/block/ListBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 David Green and others. + * Copyright (c) 2007, 2012 David Green and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * David Green - initial API and implementation + * Jeremie Bresson - bug 389812 *******************************************************************************/ package org.eclipse.mylyn.internal.wikitext.tracwiki.core.block; @@ -15,8 +16,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.eclipse.mylyn.wikitext.core.parser.Attributes; -import org.eclipse.mylyn.wikitext.core.parser.ListAttributes; import org.eclipse.mylyn.wikitext.core.parser.DocumentBuilder.BlockType; +import org.eclipse.mylyn.wikitext.core.parser.ListAttributes; import org.eclipse.mylyn.wikitext.core.parser.markup.Block; /** @@ -28,7 +29,7 @@ public class ListBlock extends Block { private static final int LINE_REMAINDER_GROUP_OFFSET = 4; - static final Pattern startPattern = Pattern.compile("(?:(\\s+)(?:(\\*|-)|(?:(\\d+)\\.)))\\s+(.*+)"); //$NON-NLS-1$ + static final Pattern startPattern = Pattern.compile("(?:(\\s*)(?:(\\*|-)|(?:(\\d+)\\.)))\\s+(.*+)"); //$NON-NLS-1$ private int blockLineCount = 0; @@ -109,9 +110,6 @@ public class ListBlock extends Block { private int calculateLevel(String spaces) { int length = spaces.length(); - if (length == 0) { - throw new IllegalStateException(); - } int level = 1; for (int x = 1; x < listState.size(); ++x) { ListState state = listState.get(x); |