Skip to content
/ enml4j Public

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

Notifications You must be signed in to change notification settings

pvdlg/enml4j

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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