From cb7d0ffc0a45a23674064a956414763372dba86d Mon Sep 17 00:00:00 2001
From: Freddy Mallet <freddy.mallet@gmail.com>
Date: Tue, 26 Apr 2011 16:21:59 +0200
Subject: SONAR-2384 Fix a bug on HtmlListChannel which was due to
 CodeBuffer.length() method and make the HtmlEmphasisChannel handle sentence

---
 .../src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java       | 2 +-
 .../src/test/java/org/sonar/markdown/MarkdownEngineTest.java        | 6 ++----
 2 files changed, 3 insertions(+), 5 deletions(-)

(limited to 'sonar-markdown')

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 392a37aa345..d59b3f3adb2 100644
--- a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
+++ b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlEmphasisChannel.java
@@ -29,7 +29,7 @@ import org.sonar.channel.RegexChannel;
 class HtmlEmphasisChannel extends RegexChannel<MarkdownOutput> {
 
   public HtmlEmphasisChannel() {
-    super("\\*[^\n\r\\*\\s]++\\*");
+    super("\\*[^\\s\\*][^\n\r]+?[^\\s\\*]\\*");
   }
 
   @Override
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 9579828af9b..cf4a0f1b726 100644
--- a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java
+++ b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java
@@ -39,6 +39,7 @@ public class MarkdownEngineTest {
   @Test
   public void shouldDecorateList() {
     assertThat(MarkdownEngine.convertToHtml("  * one\r* two\r\n* three\n * \n *five"), is("<ul><li>one</li>\r<li>two</li>\r\n<li>three</li>\n<li> </li>\n</ul> *five"));
+    assertThat(MarkdownEngine.convertToHtml("  * one\r* two"), is("<ul><li>one</li>\r<li>two</li></ul>"));
   }
 
   @Test
@@ -56,10 +57,7 @@ public class MarkdownEngineTest {
     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\\*"));
-
+    assertThat(MarkdownEngine.convertToHtml("*Emphase many words*"), is("<em>Emphase many words</em>"));
   }
 
   @Test
-- 
cgit v1.2.3