Skip to content

Commit

Permalink
Add support for github style checklists
Browse files Browse the repository at this point in the history
Evernote has checkboxes to signify todo items but these are stripped out
when showing or editing the note.  Add support for todo items by using
'[ ]' for incomplete and '[x]' for complete todo items.  This is
consistent with github style markdown.
  • Loading branch information
Matt Hulse authored and Matt Hulse committed Oct 30, 2014
1 parent 5720fea commit 4d1f30a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions geeknote/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def ENMLtoText(contentENML):
else:
section.extract()

for section in soup.findAll('en-todo', checked='true'):
section.replace_with('[x]')

for section in soup.findAll('en-todo'):
section.replace_with('[ ]')

content = html2text.html2text(soup.prettify())
content = re.sub(r' *\n', os.linesep, content)
return content.encode('utf-8')
Expand Down Expand Up @@ -92,6 +98,10 @@ def textToENML(content, raise_ex=False, format='markdown'):
contentHTML = str(BeautifulSoup(contentHTML, 'html.parser'))
else:
contentHTML = Editor.HTMLEscape(content)

contentHTML = contentHTML.replace('[x]','<en-todo checked="true"></en-todo>')
contentHTML = contentHTML.replace('[ ]','<en-todo></en-todo>')

return Editor.wrapENML(contentHTML)
except:
if raise_ex:
Expand Down

0 comments on commit 4d1f30a

Please sign in to comment.