From 38b3cc5a1332ad9871c4f7f189a23724d774a1ea Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 5 May 2011 15:19:52 +0200 Subject: Rename the class MarkdownEngine to Markdown --- .../src/main/java/org/sonar/markdown/Markdown.java | 63 ++++++++++++++++++++++ .../java/org/sonar/markdown/MarkdownEngine.java | 63 ---------------------- 2 files changed, 63 insertions(+), 63 deletions(-) create mode 100644 sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java delete mode 100644 sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java (limited to 'sonar-markdown/src/main') diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java b/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java new file mode 100644 index 00000000000..9e7522cd692 --- /dev/null +++ b/sonar-markdown/src/main/java/org/sonar/markdown/Markdown.java @@ -0,0 +1,63 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +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 + */ +public final class Markdown { + + private ChannelDispatcher dispatcher; + + private Markdown() { + List markdownChannels = Arrays.asList( + new HtmlUrlChannel(), + new HtmlEndOfLineChannel(), + new HtmlEmphasisChannel(), + new HtmlListChannel(), + new HtmlCodeChannel(), + new IdentifierAndNumberChannel(), + new BlackholeChannel()); + dispatcher = new ChannelDispatcher(markdownChannels); + } + + private String convert(String input) { + CodeReader reader = new CodeReader(input); + try { + MarkdownOutput output = new MarkdownOutput(); + dispatcher.consume(reader, output); + return output.toString(); + + } finally { + reader.close(); + } + } + + public static String convertToHtml(String input) { + return new Markdown().convert(input); + } +} diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java b/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java deleted file mode 100644 index 13c80ce39ff..00000000000 --- a/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Sonar, open source software quality management tool. - * Copyright (C) 2008-2011 SonarSource - * mailto:contact AT sonarsource DOT com - * - * Sonar is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * Sonar is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with Sonar; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 - */ -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 - */ -public final class MarkdownEngine { - - private ChannelDispatcher dispatcher; - - private MarkdownEngine() { - List markdownChannels = Arrays.asList( - new HtmlUrlChannel(), - new HtmlEndOfLineChannel(), - new HtmlEmphasisChannel(), - new HtmlListChannel(), - new HtmlCodeChannel(), - new IdentifierAndNumberChannel(), - new BlackholeChannel()); - dispatcher = new ChannelDispatcher(markdownChannels); - } - - private String convert(String input) { - CodeReader reader = new CodeReader(input); - try { - MarkdownOutput output = new MarkdownOutput(); - dispatcher.consume(reader, output); - return output.toString(); - - } finally { - reader.close(); - } - } - - public static String convertToHtml(String input) { - return new MarkdownEngine().convert(input); - } -} -- cgit v1.2.3