This is a python library for converting ENML (Evernote Markup Language, http://dev.evernote.com/start/core/enml.php) to/from HTML and plain text.
>>> import ENML_PY as enml
>>> note = "<en-note>hello world</en-note>"
>>> html = enml.ENMLToHTML(note)
>>> print html
<html>
<body>
hello world
</body>
</html>
>>> import ENML_PY as enml
>>> note = "<en-note>hello world</en-note>"
>>> html = enml.ENMLToHTML(note, pretty=False)
>>> print html
<html><body>hello world</body></html>
>>> import ENML_PY as enml
>>> note = "<en-note>hello world</en-note>"
>>> text = enml.ENMLToText(note, pretty=False)
>>> print text
hello world
>>> client = EvernoteClient(token=dev_token)
>>> noteStore = client.get_note_store()
>>> mediaStore = enml.FileMediaStore(noteStore, note.guid, 'resources/')
>>> content = noteStore.getNoteContent(note.guid)
>>> html = enml.ENMLToHTML(content, False, media_store=mediaStore)
This will convert ENML to HTML, and save all the resource files related to the note in 'resources/' path, and replace all media inserted in ENML with according HTML tags with link pointing to the resource with 'file://' protocol.
from ENML_PY import MediaStore, MIME_TO_EXTENSION_MAPPING
class MyMediaStore(MediaStore):
def __init__ (self, note_store, note_guid):
super(MyMediaStore, self).__init__(note_store, note_guid)
def save(self, hash_str, mime_type):
# hash_str is the hash digest string of the resource file
# mime_type is the mime_type of the resource that is about to be saved
# you can get the mime type to file extension mapping by accessing the dict MIME_TO_EXTENSION_MAPPING
# retrieve the binary data
data = self._get_resource_by_hash(hash_str)
# some saving operation
...
# return the URL of the resource that has just been saved
return some_url
- Map other media types to the corresponding HTML tags (Only Image tag currently)
- Convert from HTML to ENML