summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java b/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java
index 9e7522cd692..f727d748e60 100644
--- a/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java
+++ b/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java
@@ -19,13 +19,9 @@
*/
package org.sonar.markdown;
-import org.sonar.channel.Channel;
import org.sonar.channel.ChannelDispatcher;
import org.sonar.channel.CodeReader;
-import java.util.Arrays;
-import java.util.List;
-
/**
* Entry point of the Markdown library
*/
@@ -34,15 +30,15 @@ public final class Markdown {
private ChannelDispatcher<MarkdownOutput> dispatcher;
private Markdown() {
- List<Channel> markdownChannels = Arrays.<Channel>asList(
- new HtmlUrlChannel(),
- new HtmlEndOfLineChannel(),
- new HtmlEmphasisChannel(),
- new HtmlListChannel(),
- new HtmlCodeChannel(),
- new IdentifierAndNumberChannel(),
- new BlackholeChannel());
- dispatcher = new ChannelDispatcher<MarkdownOutput>(markdownChannels);
+ dispatcher = ChannelDispatcher.builder()
+ .addChannel(new HtmlUrlChannel())
+ .addChannel(new HtmlEndOfLineChannel())
+ .addChannel(new HtmlEmphasisChannel())
+ .addChannel(new HtmlListChannel())
+ .addChannel(new HtmlCodeChannel())
+ .addChannel(new IdentifierAndNumberChannel())
+ .addChannel(new BlackholeChannel())
+ .build();
}
private String convert(String input) {
@@ -51,7 +47,7 @@ public final class Markdown {
MarkdownOutput output = new MarkdownOutput();
dispatcher.consume(reader, output);
return output.toString();
-
+
} finally {
reader.close();
}