aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-markdown
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-04-23 08:23:52 +0200
committersimonbrandhof <simon.brandhof@gmail.com>2011-04-23 08:23:52 +0200
commit327a952a2f36f3a4eef2d76c3671a1737e550ce5 (patch)
treec29f42e629e2604c5bc1aa8fbb6186796aedc77f /sonar-markdown
parentaf9f6dfcd3732b97cc7b441c88778f9a765709ba (diff)
downloadsonarqube-327a952a2f36f3a4eef2d76c3671a1737e550ce5.tar.gz
sonarqube-327a952a2f36f3a4eef2d76c3671a1737e550ce5.zip
SONAR-2384 Complete the support of emphasis
Diffstat (limited to 'sonar-markdown')
-rw-r--r--sonar-markdown/pom.xml4
-rw-r--r--sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java6
-rw-r--r--sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java9
3 files changed, 13 insertions, 6 deletions
diff --git a/sonar-markdown/pom.xml b/sonar-markdown/pom.xml
index 76e2a7c3aef..ed1672cfe65 100644
--- a/sonar-markdown/pom.xml
+++ b/sonar-markdown/pom.xml
@@ -17,10 +17,6 @@
<artifactId>sonar-channel</artifactId>
</dependency>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
index 146797ed7e4..48d42b1114b 100644
--- a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
+++ b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
@@ -24,11 +24,13 @@ import org.sonar.channel.RegexChannel;
class HtmlEmphasisChannel extends RegexChannel<MarkdownOutput> {
public HtmlEmphasisChannel() {
- super("\\*[^\n\r]*\\*");
+ super("\\*\\S[^\n\r\\*\\s]*\\*");
}
@Override
protected void consume(CharSequence token, MarkdownOutput output) {
- output.append("<em>" + token.subSequence(1, token.length() - 1) + "</em>");
+ output.append("<em>");
+ output.append(token.subSequence(1, token.length() - 1));
+ output.append("</em>");
}
}
diff --git a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java
index e90b45a093f..f3669cd0181 100644
--- a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java
+++ b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java
@@ -40,6 +40,15 @@ public class MarkdownEngineTest {
public void shouldEmphaseText() {
assertThat(MarkdownEngine.convertToHtml("This is *important*"), is("This is <em>important</em>"));
assertThat(MarkdownEngine.convertToHtml("This should not be * \n emphase"), is("This should not be * <br/> emphase"));
+ assertThat(MarkdownEngine.convertToHtml("This is *very* very *important*"), is("This is <em>very</em> very <em>important</em>"));
+ assertThat(MarkdownEngine.convertToHtml("Not * emphase * because of whitespaces"), is("Not * emphase * because of whitespaces"));
+ assertThat(MarkdownEngine.convertToHtml("Not *emphase * because of whitespace"), is("Not *emphase * because of whitespace"));
+ assertThat(MarkdownEngine.convertToHtml("Not * emphase* because of whitespace"), is("Not * emphase* because of whitespace"));
+ assertThat(MarkdownEngine.convertToHtml("emphase*inside*word"), is("emphase<em>inside</em>word"));
+
+ // not supported yet
+ //assertThat(MarkdownEngine.convertToHtml("\\*surrounded by literal asterisks\\*"), is("\\*surrounded by literal asterisks\\*"));
+
}
@Test