diff options
author | Anita Stanisz <106669481+anita-stanisz-sonarsource@users.noreply.github.com> | 2024-04-29 17:05:35 +0200 |
---|---|---|
committer | Matteo Mara <matteo.mara@sonarsource.com> | 2024-04-30 10:59:03 +0200 |
commit | d6bcc16d72c2084dac48582bc9a6f4fd7c6ab042 (patch) | |
tree | b77d22a284a3af13eaeacaf7ba51e7bd791c6064 /sonar-markdown | |
parent | ff98ac8245d237e3905258ab5187be1eeaf07c4e (diff) | |
download | sonarqube-d6bcc16d72c2084dac48582bc9a6f4fd7c6ab042.tar.gz sonarqube-d6bcc16d72c2084dac48582bc9a6f4fd7c6ab042.zip |
SONAR-22162 Support empty quote line in issue comment (#11048)
Diffstat (limited to 'sonar-markdown')
-rw-r--r-- | sonar-markdown/src/main/java/org/sonar/markdown/HtmlBlockquoteChannel.java | 6 | ||||
-rw-r--r-- | sonar-markdown/src/test/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<MarkdownOutput> { private class QuotedLineElementChannel extends RegexChannel<MarkdownOutput> { private QuotedLineElementChannel() { - super(">\\s[^\r\n]*+"); + super(">[^\r\n]*+"); } @Override @@ -82,15 +82,15 @@ class HtmlBlockquoteChannel extends Channel<MarkdownOutput> { 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 <a href=\"http://docs.sonarsource.com/sonarqube/display/SONAR\" target=\"_blank\" rel=\"noopener noreferrer\">check online documentation</a>."); } - @Test public void shouldDecorateEndOfLine() { assertThat(Markdown.convertToHtml("1\r2\r\n3\n")).isEqualTo("1<br/>2<br/>3<br/>"); @@ -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(""" + <blockquote>just some quotation without leading space<br/> + <br/> + <br/> + continue quotation<br/></blockquote>"""); + } + + @Test + public void shouldConvertSingleGreaterThanChar() { + assertThat(Markdown.convertToHtml(">")).isEqualTo("<blockquote><br/></blockquote>"); + } + } |