Skip to content

Latest commit

 

History

History
100 lines (73 loc) · 3.46 KB

README.md

File metadata and controls

100 lines (73 loc) · 3.46 KB

commonmark-ext-notifications

Maven Central status Java CI with Maven

This is a plugin for commonmark-java that allows to create notifications paragraphs in markdown like the following (taken from Isabel Castillo blog)

image

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.

Usage

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>
 */

Configuration

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>
 */

Maven coordinates

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>    

Build & release

Normal build

  • mvn clean install

Release

  • 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
  • mvn -Poss,release -DskipTests deploy
  • git push --follow-tags origin master