summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremie Bresson2012-07-09 11:22:01 (EDT)
committerDavid Green2012-07-09 11:22:01 (EDT)
commit05c5e055561361f3af8b2fdedf3c82fe97147746 (patch)
tree2f3bec11ad099add9bcb9769222c38f2421551e7
parent06dad7631296413db2294f81c0ae6bbd6ee1224a (diff)
downloadorg.eclipse.mylyn.docs-05c5e055561361f3af8b2fdedf3c82fe97147746.zip
org.eclipse.mylyn.docs-05c5e055561361f3af8b2fdedf3c82fe97147746.tar.gz
org.eclipse.mylyn.docs-05c5e055561361f3af8b2fdedf3c82fe97147746.tar.bz2
bug 380052: [WikiText] Support digits in MediaWiki Template name.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=380052 modify template matching to include digits
-rw-r--r--org.eclipse.mylyn.wikitext.mediawiki.core/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessor.java2
-rw-r--r--org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessorTest.java39
2 files changed, 40 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.wikitext.mediawiki.core/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessor.java b/org.eclipse.mylyn.wikitext.mediawiki.core/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessor.java
index a4789aa..d2b2c8a 100644
--- a/org.eclipse.mylyn.wikitext.mediawiki.core/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessor.java
+++ b/org.eclipse.mylyn.wikitext.mediawiki.core/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessor.java
@@ -28,7 +28,7 @@ import org.eclipse.mylyn.wikitext.mediawiki.core.TemplateResolver;
public class TemplateProcessor {
- private static final Pattern templatePattern = Pattern.compile("(?:^|(?<!\\{))(\\{\\{(#?[a-zA-Z_ :]+)\\s*(\\|[^\\}]*)?\\}\\})"); //$NON-NLS-1$
+ private static final Pattern templatePattern = Pattern.compile("(?:^|(?<!\\{))(\\{\\{(#?[a-zA-Z0-9_ :]+)\\s*(\\|[^\\}]*)?\\}\\})"); //$NON-NLS-1$
private static final Pattern templateParameterPattern = Pattern.compile("\\{\\{\\{([a-zA-Z0-9]+)\\}\\}\\}"); //$NON-NLS-1$
diff --git a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessorTest.java b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessorTest.java
index fe8b287..1a3f9e4 100644
--- a/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessorTest.java
+++ b/org.eclipse.mylyn.wikitext.tests/src/org/eclipse/mylyn/internal/wikitext/mediawiki/core/TemplateProcessorTest.java
@@ -271,6 +271,45 @@ public class TemplateProcessorTest extends TestCase {
markup);
}
+ public void testBasicTemplateDidgitInTheName() {
+ //Bug 380052
+ Template template = new Template();
+ template.setName("1stTest");
+ template.setTemplateMarkup("first test");
+ markupLanguage.getTemplates().add(template);
+
+ TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
+
+ String markup = templateProcessor.processTemplates("This is a {{1stTest}}.");
+ assertEquals("This is a first test.", markup);
+ }
+
+ public void testBasicTemplateDidgitInTheName2() {
+ //Bug 380052
+ Template template = new Template();
+ template.setName("Item2");
+ template.setTemplateMarkup("second item");
+ markupLanguage.getTemplates().add(template);
+
+ TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
+
+ String markup = templateProcessor.processTemplates("This is the {{Item2}}.");
+ assertEquals("This is the second item.", markup);
+ }
+
+ public void testBasicTemplateDidgitInTheName3() {
+ //Bug 380052
+ Template template = new Template();
+ template.setName("foo999bar");
+ template.setTemplateMarkup("foo-bar");
+ markupLanguage.getTemplates().add(template);
+
+ TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
+
+ String markup = templateProcessor.processTemplates("foo{{foo999bar}}bar");
+ assertEquals("foofoo-barbar", markup);
+ }
+
private void assertContains(Set<String> strings, String string) {
assertTrue(String.format("Expected %s but got %s", string, strings), strings.contains(string));
}