From d6bcc16d72c2084dac48582bc9a6f4fd7c6ab042 Mon Sep 17 00:00:00 2001 From: Anita Stanisz <106669481+anita-stanisz-sonarsource@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:05:35 +0200 Subject: [PATCH] SONAR-22162 Support empty quote line in issue comment (#11048) --- .../sonar/markdown/HtmlBlockquoteChannel.java | 6 +++--- .../java/org/sonar/markdown/MarkdownTest.java | 20 ++++++++++++++++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlBlockquoteChannel.java b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlBlockquoteChannel.java index 8cc0045ebbd..3dac71ad6eb 100644 --- a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlBlockquoteChannel.java +++ b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlBlockquoteChannel.java @@ -63,7 +63,7 @@ class HtmlBlockquoteChannel extends Channel { private class QuotedLineElementChannel extends RegexChannel { private QuotedLineElementChannel() { - super(">\\s[^\r\n]*+"); + super(">[^\r\n]*+"); } @Override @@ -82,15 +82,15 @@ class HtmlBlockquoteChannel extends Channel { if (token.charAt(index) == '&') { index += 4; while (index < token.length()) { - index ++; if (token.charAt(index) != ' ') { return index; } + index ++; } } index ++; } - return token.length() - 1; + return token.length(); } } 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 1f56839134f..22baae61acb 100644 --- a/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java +++ b/sonar-markdown/src/test/java/org/sonar/markdown/MarkdownTest.java @@ -43,7 +43,6 @@ public class MarkdownTest { .isEqualTo("For more details, please check online documentation."); } - @Test public void shouldDecorateEndOfLine() { assertThat(Markdown.convertToHtml("1\r2\r\n3\n")).isEqualTo("1
2
3
"); @@ -123,4 +122,23 @@ public class MarkdownTest { assertThat(Markdown.convertToHtml("My text is $123 ''")).isEqualTo("My text is $123 ''"); } + @Test + public void shouldSupportEmptyQuoteLineWithAndWithoutLeadingSpace() { + assertThat(Markdown.convertToHtml(""" + >just some quotation without leading space + > + > + > continue quotation""" + )).isEqualTo(""" +
just some quotation without leading space
+
+
+ continue quotation
"""); + } + + @Test + public void shouldConvertSingleGreaterThanChar() { + assertThat(Markdown.convertToHtml(">")).isEqualTo("

"); + } + } -- 2.39.5