A more sensible error when markdown fails

This commit is contained in:
Kovid Goyal 2009-06-01 20:49:30 -07:00
parent e3fabe843a
commit 3fecb610dc

View File

@ -23,7 +23,11 @@ class TXTInput(InputFormatPlugin):
ienc = options.input_encoding
txt = stream.read().decode(ienc)
html = txt_to_markdown(txt)
try:
html = txt_to_markdown(txt)
except RuntimeError:
raise ValueError('This txt file has malformed markup, it cannot be'
'converted by calibre. See http://daringfireball.net/projects/markdown/syntax')
with open('index.html', 'wb') as index:
index.write(html.encode('utf-8'))