diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2011-04-23 08:23:52 +0200 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2011-04-23 08:23:52 +0200 |
commit | 327a952a2f36f3a4eef2d76c3671a1737e550ce5 (patch) | |
tree | c29f42e629e2604c5bc1aa8fbb6186796aedc77f /sonar-markdown/src | |
parent | af9f6dfcd3732b97cc7b441c88778f9a765709ba (diff) | |
download | sonarqube-327a952a2f36f3a4eef2d76c3671a1737e550ce5.tar.gz sonarqube-327a952a2f36f3a4eef2d76c3671a1737e550ce5.zip |
SONAR-2384 Complete the support of emphasis
Diffstat (limited to 'sonar-markdown/src')
-rw-r--r-- | sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java | 6 | ||||
-rw-r--r-- | sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java | 9 |
2 files changed, 13 insertions, 2 deletions
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 |