commonmark4j

CommonMark transform library for Java

License

License

Categories

Categories

Net
GroupId

GroupId

net.arnx
ArtifactId

ArtifactId

commonmark4j
Last Version

Last Version

0.21.0
Release Date

Release Date

Type

Type

jar
Description

Description

commonmark4j
CommonMark transform library for Java
Project URL

Project URL

http://hidekatsu-izuno.github.io/commonmark4j/
Source Code Management

Source Code Management

https://github.com/hidekatsu-izuno/commonmark4j.git

Download commonmark4j

How to add to project

<!-- https://jarcasting.com/artifacts/net.arnx/commonmark4j/ -->
<dependency>
    <groupId>net.arnx</groupId>
    <artifactId>commonmark4j</artifactId>
    <version>0.21.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.arnx/commonmark4j/
implementation 'net.arnx:commonmark4j:0.21.0'
// https://jarcasting.com/artifacts/net.arnx/commonmark4j/
implementation ("net.arnx:commonmark4j:0.21.0")
'net.arnx:commonmark4j:jar:0.21.0'
<dependency org="net.arnx" name="commonmark4j" rev="0.21.0">
  <artifact name="commonmark4j" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.arnx', module='commonmark4j', version='0.21.0')
)
libraryDependencies += "net.arnx" % "commonmark4j" % "0.21.0"
[net.arnx/commonmark4j "0.21.0"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework : spring Optional jar [2.5,3)
com.google.inject : guice Optional jar [2.0,4.0)
org.seasar.container » s2-framework Optional jar [2.4,2.5)
commons-beanutils : commons-beanutils Optional jar [1.8,)

provided (1)

Group / Artifact Type Version
javax.servlet : servlet-api jar [2.4,)

Project Modules

There are no modules declared in this project.

commonmark4j

Commonmark4j is a CommonMark transformer.

The specification of this implementaion is defined by CommonMark Spec.

The official reference implementation was written in C and JavaScript. Commonmark4j is ported from commonmark.js.

Requirements

  • Java SE 8+
  • Zero Dependencies

Command Line

Commonmark4j can run from command line.

Usage: java -jar commonmark4j-[version].jar [options] [source] [dest]
Options:
  -help               print this help message.
  -safe               remove dangerous code.
  -smart              use smart characters.
  -softbreak <text>   set softbreak characters. (default: \n)
  -sourcepos          include source position information.
  -time               print total time.");
  -format {html,xml}  output as specified format. (default: html)

API Description

You can find the classes of this library in net.arnx.commonmark4j package.

The basic usage, use a CMarkTransformer class.

CMarkTransformer transformer = CMarkTransformer.newTransformer();

try (BufferedReader in = Files.newBufferedReader(Paths.get("..."));
    BufferedWriter out = Files.newBufferedWriter(Paths.get("..."))) {

    transformer.transform(in, out);
}

If you want to use in same way as commonmark.js, you can use CMarkParser and CMarkRenderer.

CmarkNode node;

CMarkParser parser = CMarkParser.newParser();
try (BufferedReader in = Files.newBufferedReader(Paths.get("...")) {
    node = parser.parse(in);
}

CMarkRenderer renderer = CMarkRenderer.newHtmlRenderer();
try (BufferedWriter out = Files.newBufferedWriter(Paths.get("..."))) {
    renderer.render(out);
}

Maven Repository

Commonmark4j is available in Maven central repository.

<groupId>net.arnx</groupId>
<artifactId>commonmark4j</artifactId>

License

Commonmark4j is licensed by The 2 clause BSD License, see LICENSE.

Versions

Version
0.21.0