Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrizio Iannetti2017-03-15 20:29:28 +0000
committerFabrizio Iannetti2017-03-15 20:31:12 +0000
commitf8309daf600f08c97740dde8d7fbfab2ac1de680 (patch)
tree2e157186dcc16c0307d2515a84d61c79b2fde363
parent54aee613b3ac27e05b3e3e32d1e845493e0acbe9 (diff)
downloadorg.eclipse.mylyn.docs-f8309daf600f08c97740dde8d7fbfab2ac1de680.tar.gz
org.eclipse.mylyn.docs-f8309daf600f08c97740dde8d7fbfab2ac1de680.tar.xz
org.eclipse.mylyn.docs-f8309daf600f08c97740dde8d7fbfab2ac1de680.zip
512066: [asciidoc] support list style as positional parameter
Style can be specified as the first positional parameter, e.g.: [lowerroman] . item . item Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=512066 Change-Id: I0ed4e29855ce1f7bcca9e447e3d71ff803ded873 Signed-off-by: Fabrizio Iannetti <fabrizio.iannetti@gmail.com>
-rw-r--r--wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/main/java/org/eclipse/mylyn/wikitext/asciidoc/internal/block/ListBlock.java15
-rw-r--r--wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/test/java/org/eclipse/mylyn/internal/wikitext/asciidoc/tests/AsciiDocLanguageListTest.java85
2 files changed, 96 insertions, 4 deletions
diff --git a/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/main/java/org/eclipse/mylyn/wikitext/asciidoc/internal/block/ListBlock.java b/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/main/java/org/eclipse/mylyn/wikitext/asciidoc/internal/block/ListBlock.java
index c854fea0f..5ff3e55b3 100644
--- a/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/main/java/org/eclipse/mylyn/wikitext/asciidoc/internal/block/ListBlock.java
+++ b/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/main/java/org/eclipse/mylyn/wikitext/asciidoc/internal/block/ListBlock.java
@@ -11,7 +11,7 @@
package org.eclipse.mylyn.wikitext.asciidoc.internal.block;
-import java.util.Collections;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Stack;
@@ -33,6 +33,10 @@ import com.google.common.collect.ImmutableList;
*/
public class ListBlock extends Block {
+ private static final String PARAM_NAME_START = "start";
+
+ private static final String PARAM_NAME_STYLE = "style";
+
private static final String ANY_CHAR = "\\s+(.*+)"; //$NON-NLS-1$
private static final List<String> TYPE_ORDER = ImmutableList.of("arabic", "loweralpha", "lowerroman", "upperalpha",
@@ -89,14 +93,17 @@ public class ListBlock extends Block {
BlockType type = calculateType(listSpec);
if (type == BlockType.NUMERIC_LIST) {
- Map<String, String> lastProperties = getAsciiDocState().getLastProperties(Collections.emptyList());
+
+ List<String> positionalParameters = new ArrayList<>();
+ positionalParameters.add(PARAM_NAME_STYLE);
+ Map<String, String> lastProperties = getAsciiDocState().getLastProperties(positionalParameters);
getAsciiDocState().setLastPropertiesText("");
- String startProperty = lastProperties.get("start"); //$NON-NLS-1$
+ String startProperty = lastProperties.get(PARAM_NAME_START);
if (startProperty != null) {
attributes.setStart(startProperty);
}
- String styleProperty = lastProperties.get("style"); //$NON-NLS-1$
+ String styleProperty = lastProperties.get(PARAM_NAME_STYLE);
updateStyleAttribute(attributes, listSpec, styleProperty);
}
// first line of the block could be "** " or more
diff --git a/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/test/java/org/eclipse/mylyn/internal/wikitext/asciidoc/tests/AsciiDocLanguageListTest.java b/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/test/java/org/eclipse/mylyn/internal/wikitext/asciidoc/tests/AsciiDocLanguageListTest.java
index 439519fd5..7476cdaff 100644
--- a/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/test/java/org/eclipse/mylyn/internal/wikitext/asciidoc/tests/AsciiDocLanguageListTest.java
+++ b/wikitext/core/org.eclipse.mylyn.wikitext.asciidoc/src/test/java/org/eclipse/mylyn/internal/wikitext/asciidoc/tests/AsciiDocLanguageListTest.java
@@ -439,6 +439,91 @@ public class AsciiDocLanguageListTest extends AsciiDocLanguageTestBase {
}
@Test
+ public void testListWithStyleArabicAsPositionalParam() {
+ String html = parseToHtml("[arabic]\n" //
+ + ". item\n" //
+ + ".. item\n" //
+ + "\n" //
+ + "another\n" //
+ + ". item");
+ assertEquals("<ol style=\"list-style-type:decimal;\">" //
+ + "<li>item<ol style=\"list-style-type:lower-alpha;\">" //
+ + "<li>item</li>" //
+ + "</ol></li></ol><p>another</p>\n" //
+ + "<ol style=\"list-style-type:decimal;\">" //
+ + "<li>item</li></ol>", //
+ html);
+ }
+
+ @Test
+ public void testListWithStyleLoweralphaAsPositionalParam() {
+ String html = parseToHtml("[loweralpha]\n" //
+ + ". item\n" //
+ + ".. item\n" //
+ + "\n" //
+ + "another\n" //
+ + ". item");
+ assertEquals("<ol style=\"list-style-type:lower-alpha;\">" //
+ + "<li>item<ol style=\"list-style-type:lower-alpha;\">" //
+ + "<li>item</li>" //
+ + "</ol></li></ol><p>another</p>\n" //
+ + "<ol style=\"list-style-type:decimal;\">" //
+ + "<li>item</li></ol>", //
+ html);
+ }
+
+ @Test
+ public void testListWithStyleUpperalphaAsPositionalParam() {
+ String html = parseToHtml("[upperalpha]\n" //
+ + ". item\n" //
+ + ".. item\n" //
+ + "\n" //
+ + "another\n" //
+ + ". item");
+ assertEquals("<ol style=\"list-style-type:upper-alpha;\">" //
+ + "<li>item<ol style=\"list-style-type:lower-alpha;\">" //
+ + "<li>item</li>" //
+ + "</ol></li></ol><p>another</p>\n" //
+ + "<ol style=\"list-style-type:decimal;\">" //
+ + "<li>item</li></ol>", //
+ html);
+ }
+
+ @Test
+ public void testListWithStyleLowerromanAsPositionalParam() {
+ String html = parseToHtml("[lowerroman]\n" //
+ + ". item\n" //
+ + ".. item\n" //
+ + "\n" //
+ + "another\n" //
+ + ". item");
+ assertEquals("<ol style=\"list-style-type:lower-roman;\">" //
+ + "<li>item<ol style=\"list-style-type:lower-alpha;\">" //
+ + "<li>item</li>" //
+ + "</ol></li></ol><p>another</p>\n" //
+ + "<ol style=\"list-style-type:decimal;\">" //
+ + "<li>item</li></ol>", //
+ html);
+ }
+
+ @Test
+ public void testListWithStyleUpperromanAsPositionalParam() {
+ String html = parseToHtml("[upperroman]\n" //
+ + ". item\n" //
+ + ".. item\n" //
+ + "\n" //
+ + "another\n" //
+ + ". item");
+ assertEquals("<ol style=\"list-style-type:upper-roman;\">" //
+ + "<li>item<ol style=\"list-style-type:lower-alpha;\">" //
+ + "<li>item</li>" //
+ + "</ol></li></ol><p>another</p>\n" //
+ + "<ol style=\"list-style-type:decimal;\">" //
+ + "<li>item</li></ol>", //
+ html);
+ }
+
+ @Test
public void testListWithExplicitNumbering() {
String html = parseToHtml("\n" //
+ "MDCLXIV) level 1\n" //

Back to the top