2

Port enml library from javascript (enml.js)

ENML.PlainTextOfENML for evernote-sdk-js works good for me and I would like to find a good port of this tool for Python.

I tried to use these library's, but got an errors:

https://github.com/CarlLee/ENML_PY
ImportError: No module named bs4

https://github.com/wanasit/enml-py
Feb 2013, without the documentations,
ImportError: No module named internals

For example
I would like to get:

any sort of liquid damage to an Apple product will void your warranty.

from

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>any sort of liquid damage to an Apple product will void your warranty.</en-note>

The part of code in which I want to use enml:
views.py

title_contents = {}
for note in result_list.notes:
    content = note_store.getNoteContent(auth_token, 
                                        note_store.getNote(note.guid, 
                                        True,False, False, False).guid)
    title_contents[note.title] = content

enter code herereturn render_to_response('oauth/callback.html', {'notebooks': notebooks, 
                                                  'result_list': result_list, 
                                                  'title_contents': title_contents})

callback.html

    .....
    <ul>
      {% for title, content in title_contents.items %}
        <li><b>{{ title }}</b><br>{{ content }}</li>
      {% endfor %}
    </ul>
lvcpp
  • 169
  • 1
  • 3
  • 16
  • I've never used it before, but those import error is due the fact you didn't install their dependencies `bs4`: http://stackoverflow.com/questions/11783875/importerror-no-module-named-bs4-beautifulsoup and `NLTK` http://stackoverflow.com/questions/24653957/getting-an-error-no-module-named-internals-on-running-a-python-code-on-window – Shang Wang Feb 06 '16 at 15:56
  • thanks, the first link helped to me. – lvcpp Feb 08 '16 at 00:10

1 Answers1

0

This combination accomplish all the things needed:

from fenml import ENMLToHTML
# the fenml.py is my internal fork of the 
# https://github.com/CarlLee/ENML_PY/blob/master/__init__.py 
# with slightly modified code. 
from bs4 import BeautifulSoup
import html2text
....
title_contents[note.title] = html2text.html2text(BeautifulSoup(ENMLToHTML(content)).prettify())
lvcpp
  • 169
  • 1
  • 3
  • 16