Skip to content
This repository was archived by the owner on Apr 25, 2024. It is now read-only.

Fixed undesired line breaks and Markdown syntax for Links. #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion geeknote/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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), " ")
Expand Down Expand Up @@ -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 <http://someurl.com>, 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)

Expand Down