This is a plugin for commonmark-java that allows to create notifications paragraphs in markdown like the following (taken from Isabel Castillo blog)
using a very simple syntax
! This is an info message.
!v This is a success message.
!! Consider this a warning.
!x This is an error message.
Simply add the extension to the Parser & Renderer objects.
Extension notificationExtension = NotificationsExtension.create();
Parser parser = Parser
.builder()
.extensions(Collections.singleton(notificationExtension))
.build();
Node document = parser.parse("! Use Notifications Extension !!!");
HtmlRenderer renderer = HtmlRenderer
.builder()
.extensions(Collections.singleton(notificationExtension))
.build();
renderer.render(document);
/*
<div class="notification_info">
<p>Use Notifications Extension !!!</p>
</div>
*/If you want specific rendering to adapt to an existing CSS framework you can define which HTML node will be rendered (see NotificationsExtension.withDomElementMapper) or which CSS classes (see NotificationsExtension.withClassMapper) will be applied.
For exemple to render Boostrap Alerts, you could use:
Extension notificationExtension = NotificationsExtension.create()
.withClassMapper(n -> n == Notification.ERROR ? "alert alert-danger" : "alert alert-" + n.name().toLowerCase());
Parser parser = Parser
.builder()
.extensions(Collections.singleton(notificationExtension))
.build();
Node document = parser.parse("! Use Notifications Extension !!!");
HtmlRenderer renderer = HtmlRenderer
.builder()
.extensions(Collections.singleton(notificationExtension))
.build();
renderer.render(document);
/*
<div class="alert alert-info">
<p>Use Notifications Extension !!!</p>
</div>
*/You will find the latest version of the extension in maven central.
<dependency>
<groupId>fr.brouillard.oss</groupId>
<artifactId>commonmark-ext-notifications</artifactId>
<version>1.1.0</version>
</dependency>
mvn clean install
mvn -Poss clean install: this will simulate a full build for oss delivery (javadoc, source attachement, GPG signature, ...)git tag -a -s -m "release X.Y.Z, additionnal reason" X.Y.Z: tag the current HEAD with the given tag name. The tag is signed by the author of the release. Adapt with gpg key of maintainer.- Matthieu Brouillard command:
git tag -a -s -u 2AB5F258 -m "release X.Y.Z, additionnal reason" X.Y.Z - Matthieu Brouillard public key
- Matthieu Brouillard command:
mvn -Poss,release -DskipTests deploygit push --follow-tags origin master
