]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2384 append target='_blank' when building an hyperlink
authorFreddy Mallet <freddy.mallet@gmail.com>
Wed, 27 Apr 2011 21:58:01 +0000 (23:58 +0200)
committerFreddy Mallet <freddy.mallet@gmail.com>
Wed, 27 Apr 2011 21:58:01 +0000 (23:58 +0200)
sonar-markdown/src/main/java/org/sonar/markdown/HtmlUrlChannel.java
sonar-markdown/src/test/java/org/sonar/markdown/MarkdownEngineTest.java

index 2158c428f00eb7bb8f39495ec0d5e48637ceea1e..5a8522399ea00d62861b0be4288dc037540acc48 100644 (file)
@@ -33,6 +33,6 @@ class HtmlUrlChannel extends RegexChannel<MarkdownOutput> {
 
   @Override
   protected void consume(CharSequence token, MarkdownOutput output) {
-    output.append("<a href=\"" + token + "\">" + token + "</a>");
+    output.append("<a href=\"" + token + "\" target=\"_blank\">" + token + "</a>");
   }
 }
index 123c64c9360a7caa165a49d7f8b469714dae66a4..b1979254828733bab0afcd4bff052fc7a1c59c53 100644 (file)
@@ -28,17 +28,19 @@ public class MarkdownEngineTest {
 
   @Test
   public void shouldDecorateUrl() {
-    assertThat(MarkdownEngine.convertToHtml("http://google.com"), is("<a href=\"http://google.com\">http://google.com</a>"));
+    assertThat(MarkdownEngine.convertToHtml("http://google.com"),
+        is("<a href=\"http://google.com\" target=\"_blank\">http://google.com</a>"));
   }
 
   @Test
   public void shouldDecorateEndOfLine() {
     assertThat(MarkdownEngine.convertToHtml("1\r2\r\n3\n"), is("1<br/>2<br/>3<br/>"));
   }
-  
+
   @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\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>"));
   }