From b34371674a8371c7ba83e50fb5b1950f781868d0 Mon Sep 17 00:00:00 2001 From: Patrick Hobusch Date: Thu, 30 Jul 2020 19:04:33 +0800 Subject: [PATCH] Implement initial plugin version --- .gitignore | 4 ++ README.md | 5 ++ pom.xml | 56 +++++++++++++++++++ .../de/aservo/jenkins/FlexmarkFormatter.java | 46 +++++++++++++++ src/main/resources/index.jelly | 4 ++ 5 files changed, 115 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/de/aservo/jenkins/FlexmarkFormatter.java create mode 100644 src/main/resources/index.jelly diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1dc4ab4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +target/ + +.idea/ +*.iml diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa142fa --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +Flexmark (Markdown) Formatter for Jenkins +========================================= + +This Jenkins plugin adds a Markup Formatter that can process Markdown +using Flexmark. diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..2679831 --- /dev/null +++ b/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + + + org.jenkins-ci.plugins + plugin + 4.2 + + + de.aservo + flexmark-formatter-jenkins-plugin + 0.1 + hpi + + + + Patrick Hobusch + phobusch@aservo.com + ASERVO Software GmbH + https://www.aservo.com + + + + + 8 + + + + + com.vladsch.flexmark + flexmark + 0.62.2 + + + com.vladsch.flexmark + flexmark-util + 0.62.2 + + + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + + + repo.jenkins-ci.org + http://repo.jenkins-ci.org/public/ + + + + diff --git a/src/main/java/de/aservo/jenkins/FlexmarkFormatter.java b/src/main/java/de/aservo/jenkins/FlexmarkFormatter.java new file mode 100644 index 0000000..7abad57 --- /dev/null +++ b/src/main/java/de/aservo/jenkins/FlexmarkFormatter.java @@ -0,0 +1,46 @@ +package de.aservo.jenkins; + +import com.vladsch.flexmark.html.HtmlRenderer; +import com.vladsch.flexmark.parser.Parser; +import com.vladsch.flexmark.util.ast.Node; +import com.vladsch.flexmark.util.data.MutableDataSet; +import hudson.Extension; +import hudson.markup.MarkupFormatter; +import hudson.markup.MarkupFormatterDescriptor; +import org.kohsuke.stapler.DataBoundConstructor; + +import javax.annotation.Nonnull; +import java.io.IOException; +import java.io.Writer; + +public class FlexmarkFormatter extends MarkupFormatter { + + @DataBoundConstructor + public FlexmarkFormatter() { + } + + @Override + public void translate( + final String markup, + final Writer output) throws IOException { + + final MutableDataSet options = new MutableDataSet(); + final Parser parser = Parser.builder(options).build(); + final HtmlRenderer renderer = HtmlRenderer.builder(options).build(); + + final Node document = parser.parse(markup); + output.write(renderer.render(document)); + } + + @Extension + public static class DescriptorImpl extends MarkupFormatterDescriptor { + + @Nonnull + @Override + public String getDisplayName() { + return "Flexmark (Markdown)"; + } + + } + +} diff --git a/src/main/resources/index.jelly b/src/main/resources/index.jelly new file mode 100644 index 0000000..6525f5f --- /dev/null +++ b/src/main/resources/index.jelly @@ -0,0 +1,4 @@ + +
+ This plugin adds a Markup Formatter than can process Markdown using Flexmark +