diff --git a/geeknote/editor.py b/geeknote/editor.py index fcdd7b4..e551180 100644 --- a/geeknote/editor.py +++ b/geeknote/editor.py @@ -157,7 +157,12 @@ def ENMLtoText(contentENML, format='default', imageOptions={'saveImages': False} # content = html2text.html2text(soup.prettify()) # content = html2text.html2text(str(soup)) # content = html2text.html2text(unicode(soup)) - content = html2text.html2text(str(soup).decode('utf-8'), '') +# content = h.html2text(str(soup).decode('utf-8'), '') + + # Prevent undesired line breaks + h = html2text.HTML2Text() + h.body_width = 0 + content = h.handle(str(soup).decode('utf-8')) content = re.sub(r' *\n', os.linesep, content) content = content.replace(unichr(160), " ") @@ -239,6 +244,11 @@ def textToENML(content, raise_ex=False, format='markdown', rawmd=False): storage = Storage() extras = storage.getUserprop('markdown2_extras') + # markdown for links of type [http://someurl.com](http://someurl.com) + # can be expressed as , so we have to tell the + # markdown processor to handle it like such. + content = re.sub(r'(?:<)(http[^>]+)>', r'[\1](\1)', content) + if not rawmd: content = Editor.HTMLEscapeTag(content)