enml4j

Simple utility classes to handle ENML (Evernote Markup Language) in Java

License

License

GroupId

GroupId

com.syncthemall
ArtifactId

ArtifactId

enml4j
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

enml4j
Simple utility classes to handle ENML (Evernote Markup Language) in Java
Project URL

Project URL

https://github.com/vanduynslagerp/enml4j
Source Code Management

Source Code Management

https://github.com/vanduynslagerp/enml4j

Download enml4j

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
commons-codec : commons-codec jar 1.9

provided (2)

Group / Artifact Type Version
com.evernote : evernote-api jar 1.25.1
javax.xml.stream : stax-api jar 1.0

Project Modules

There are no modules declared in this project.

ENML4j

Simple utility classes to handle ENML (Evernote Markup Language) in Java.

Overview

ENML4j provide a convenient way to:

  • Convert a Note ENML content to an HTML file referencing Resources as configurable URL
  • Convert a Note ENML content to an HTML file with inline Resources as Data URI
  • Replace Resource references in Note ENML content with new Resources
  • Delete Resource references in Note ENML content
  • Add Resource references in Note ENML content

ENML4j is design to be simple, customizable and to produce valid XHTML. ENML4j uses stAX to parse ENML and write XHTML.

Getting started

Converting a Notes ENML content to XHTML is as simple as:

    ENMLProcessor = new ENMLProcessor();
    FileOutputStream fos = new FileOutputStream("/path/to/file.html");
    ENMLProcessor.noteToInlineHTML(note, fos);

The best way to start is to look at enml4j-sample

Including the SDK in your project

The easiest way to incorporate the SDK into your Java project is to use Maven. If you're using Maven already, simply add a new dependency to your pom.xml:

<dependency>
	<groupId>com.syncthemall</groupId>
	<artifactId>enml4j</artifactId>
	<version>1.1.0</version>
</dependency>

If you'd prefer to build the jar yourself, it's as simple as running

$ mvn package

You'll find enml4j-1.1.0.jar in the target directory after the build completes. This single JAR contains everything needed to use the API.

Dependencies

You'll also need to be sure to include in your classpath a stAX implementation and evernote-sdk-java

User Guide

ENMLProcessor

This is the entry point of ENML4j. This class should be instantiated and kept in reference (as a static for example) for better performances. When converting a Note to HTML the Evernote DTD has to be parsed the first time, then stays in memory. Parsing the DTD the first time is time-consuming.

This class rely on stAX to convert ENML to HTML. ENML4j will uses the default stAX implementation on the platform. Implementation can be easily chosen : [StAX Factory Classes] (http://docs.oracle.com/javaee/5/tutorial/doc/bnbem.html#bnbeo)

This class is thread-safe as long as the stAX implementation of XMLInputFactory, XMLOutputFactory, XMLEventFactory are thread-safe. Almost all implementation of this classes are thread-safe.

Customize the conversion

ENML4j rely on Converters classes to convert specifics ENML tags to an HTML equivalent. Default Converters are provided and instantiated by default.

  • DefaultNoteTagConverter
  • DefaultInlineMediaTagConverter
  • DefaultTodoTagConverter
  • DefaultCryptTagConverter
  • DefaultInlineMediaTagConverter

For specifics needs BaseConverter and MediaConverter can be implemented and set with ENMLProcessor#setConverters(BaseConverter, MediaConverter, BaseConverter, BaseConverter) and ENMLProcessor#setInlineConverters(BaseConverter, MediaConverter, BaseConverter, BaseConverter).

For more information on ENML see Understanding the Evernote Markup Language

Development

Any bug reported properly will be fixed. Any features request will be taken under consideration.

Potential future features:

  • Convert ENML to PDF with Flying Saucer
  • Convert ENML to Plain text
  • Convert valid XHTML to ENML
  • Convert "street HTML" to ENML (very unlikely considering the lack of Java HTML renderer)

Change log

1.1.0

  • Bug fixes
  • added method addNoteResources
  • Evernote DTD and it's dependencies are now embedded in the library

1.0.0

  • Bug fixes
  • Updated to Evernote SDK to version 1.25.1

0.2.1

  • New methods to update Resources in Note ENML content, based on their hash value
  • Minor code improvements

0.2.0

  • New methods to delete Resources from Note ENML content
  • Methods to update Resource in No ENML can now also delete
  • Minor code improvements

0.1.1

  • Mapping of external resources path now uses String instead of URL
  • Methods returning void now return the variable in parameter

License

MIT

Free Software, Fuck Yeah!

Bitdeli Badge

Versions

Version
1.1.0
1.0.0
0.2.1
0.2.0
0.1.1
0.1.0