aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-markdown/src
diff options
context:
space:
mode:
authorGuillaume Jambet <guillaume.jambet@sonarsource.com>2017-11-29 15:23:30 +0100
committerGuillaume Jambet <guillaume.jambet@gmail.com>2017-12-06 00:37:59 +0100
commit79f9c59c24977943bc5ae8d34bffcce9a4d6ba38 (patch)
tree0a56e1c44fb759b4981a7ad4895c8af5f53a7377 /sonar-markdown/src
parentdc6d1e96ddada06d60cbb7ab0e0a4d5ee0929317 (diff)
downloadsonarqube-79f9c59c24977943bc5ae8d34bffcce9a4d6ba38.tar.gz
sonarqube-79f9c59c24977943bc5ae8d34bffcce9a4d6ba38.zip
SONAR-9857 fixing regexp to allow short emphasised string
Diffstat (limited to 'sonar-markdown/src')
-rw-r--r--sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java4
-rw-r--r--sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java17
2 files changed, 11 insertions, 10 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 7a5621aafee..d35a9c008a3 100644
--- a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
+++ b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
@@ -28,8 +28,8 @@ import org.sonar.channel.RegexChannel;
*/
class HtmlEmphasisChannel extends RegexChannel<MarkdownOutput> {
- public HtmlEmphasisChannel() {
- super("\\*[^\\s\\*][^\n\r]+?[^\\s\\*]\\*");
+ HtmlEmphasisChannel() {
+ super("\\*[^\\s\\*]\\*|\\*[^\\s\\*][^\n\r]*?[^\\s\\*]\\*");
}
@Override
diff --git a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java
index 794b86821f5..fb92e1de643 100644
--- a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java
+++ b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java
@@ -100,15 +100,16 @@ public class MarkdownTest {
}
@Test
- public void shouldEmphaseText() {
- assertThat(Markdown.convertToHtml("This is *important*")).isEqualTo("This is <strong>important</strong>");
- assertThat(Markdown.convertToHtml("This should not be * \n emphase")).isEqualTo("This should not be * <br/> emphase");
+ public void shouldEmphasisText() {
+ assertThat(Markdown.convertToHtml("This is *Sparta !!!*")).isEqualTo("This is <strong>Sparta !!!</strong>");
+ assertThat(Markdown.convertToHtml("This is *A*")).isEqualTo("This is <strong>A</strong>");
+ assertThat(Markdown.convertToHtml("This should not be * \n emphasized")).isEqualTo("This should not be * <br/> emphasized");
assertThat(Markdown.convertToHtml("This is *very* very *important*")).isEqualTo("This is <strong>very</strong> very <strong>important</strong>");
- assertThat(Markdown.convertToHtml("Not * emphase * because of whitespaces")).isEqualTo("Not * emphase * because of whitespaces");
- assertThat(Markdown.convertToHtml("Not *emphase * because of whitespace")).isEqualTo("Not *emphase * because of whitespace");
- assertThat(Markdown.convertToHtml("Not * emphase* because of whitespace")).isEqualTo("Not * emphase* because of whitespace");
- assertThat(Markdown.convertToHtml("emphase*inside*word")).isEqualTo("emphase<strong>inside</strong>word");
- assertThat(Markdown.convertToHtml("*Emphase many words*")).isEqualTo("<strong>Emphase many words</strong>");
+ assertThat(Markdown.convertToHtml("Not * emphasized * because of whitespaces")).isEqualTo("Not * emphasized * because of whitespaces");
+ assertThat(Markdown.convertToHtml("Not *emphasized * because of whitespace")).isEqualTo("Not *emphasized * because of whitespace");
+ assertThat(Markdown.convertToHtml("Not * emphasized* because of whitespace")).isEqualTo("Not * emphasized* because of whitespace");
+ assertThat(Markdown.convertToHtml("emphasized*inside*word")).isEqualTo("emphasized<strong>inside</strong>word");
+ assertThat(Markdown.convertToHtml("*Emphasize many words*")).isEqualTo("<strong>Emphasize many words</strong>");
}
@Test