Skip to content

Commit

Permalink
Implement initial plugin version
Browse files Browse the repository at this point in the history
  • Loading branch information
pathob committed Jul 30, 2020
1 parent 1aeef59 commit b343716
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target/

.idea/
*.iml
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Flexmark (Markdown) Formatter for Jenkins
=========================================

This Jenkins plugin adds a Markup Formatter that can process Markdown
using Flexmark.
56 changes: 56 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.2</version>
</parent>

<groupId>de.aservo</groupId>
<artifactId>flexmark-formatter-jenkins-plugin</artifactId>
<version>0.1</version>
<packaging>hpi</packaging>

<developers>
<developer>
<name>Patrick Hobusch</name>
<email>[email protected]</email>
<organization>ASERVO Software GmbH</organization>
<organizationUrl>https://www.aservo.com</organizationUrl>
</developer>
</developers>

<properties>
<java.level>8</java.level>
</properties>

<dependencies>
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark</artifactId>
<version>0.62.2</version>
</dependency>
<dependency>
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-util</artifactId>
<version>0.62.2</version>
</dependency>
</dependencies>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

</project>
46 changes: 46 additions & 0 deletions src/main/java/de/aservo/jenkins/FlexmarkFormatter.java
Original file line number Diff line number Diff line change
@@ -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)";
}

}

}
4 changes: 4 additions & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
This plugin adds a Markup Formatter than can process Markdown using Flexmark
</div>

0 comments on commit b343716

Please sign in to comment.