mirror of
https://github.com/mc1arke/sonarqube-community-branch-plugin.git
synced 2025-02-21 19:20:09 +02:00
#421: Don't trim whitespace during Markdown rendering
The text renderer for the `MarkdownFormatterFactory` had been performing a `trim` on any inputs, which caused the single whitespace entries being added as spacers after some inline images to be removed. As the structure of the document should be presumed to match what the generating component requires, it's unnecessary for the renderer to attempt to alter this structure whilst rendering to a relevant document format. Instead, any constraints on formatting should be left to the system rendering the generated output.
This commit is contained in:
parent
f43b8e1a82
commit
5c7d391887
@ -77,6 +77,6 @@ public final class MarkdownFormatterFactory extends BaseFormatterFactory {
|
||||
|
||||
@Override
|
||||
public Formatter<Text> textFormatter() {
|
||||
return node -> htmlEscaper().escape(node.getContent()).trim();
|
||||
return node -> htmlEscaper().escape(node.getContent());
|
||||
}
|
||||
}
|
||||
|
@ -96,14 +96,8 @@ class MarkdownFormatterFactoryTest {
|
||||
@Test
|
||||
void testContentTextFormatterEscapedHtml(){
|
||||
MarkdownFormatterFactory testCase = new MarkdownFormatterFactory();
|
||||
assertEquals("<p> no html allowed", testCase.textFormatter().format(new Text("<p> no html allowed")));
|
||||
assertEquals("<p> no html allowed ", testCase.textFormatter().format(new Text("<p> no html allowed ")));
|
||||
assertEquals("no html <p> allowed", testCase.textFormatter().format(new Text("no html <p> allowed")));
|
||||
assertEquals("</i>no html <p> allowed<i>", testCase.textFormatter().format(new Text("</i>no html <p> allowed<i>")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testContentTextFormatterTrimWhitespaceAtBeginAndEnd(){
|
||||
MarkdownFormatterFactory testCase = new MarkdownFormatterFactory();
|
||||
assertEquals("", testCase.textFormatter().format(new Text(" ")));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user