mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
Another fix for markdown update breakage
This commit is contained in:
parent
5b578f8ecd
commit
f9a9f01dab
@ -12,7 +12,7 @@ from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag, NavigableString, \
|
|||||||
CData, Comment, Declaration, ProcessingInstruction
|
CData, Comment, Declaration, ProcessingInstruction
|
||||||
from calibre import prepare_string_for_xml
|
from calibre import prepare_string_for_xml
|
||||||
from calibre.utils.html2text import html2text
|
from calibre.utils.html2text import html2text
|
||||||
from calibre.ebooks.markdown import markdown
|
from calibre.ebooks.markdown import Markdown
|
||||||
|
|
||||||
# Hackish - ignoring sentences ending or beginning in numbers to avoid
|
# Hackish - ignoring sentences ending or beginning in numbers to avoid
|
||||||
# confusion with decimal points.
|
# confusion with decimal points.
|
||||||
@ -69,7 +69,6 @@ def comments_to_html(comments):
|
|||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return u'<p></p>'
|
return u'<p></p>'
|
||||||
|
|
||||||
|
|
||||||
# Explode lost CRs to \n\n
|
# Explode lost CRs to \n\n
|
||||||
comments = lost_cr_exception_pat.sub(lambda m: m.group().replace('.',
|
comments = lost_cr_exception_pat.sub(lambda m: m.group().replace('.',
|
||||||
'.\r'), comments)
|
'.\r'), comments)
|
||||||
@ -134,9 +133,8 @@ def comments_to_html(comments):
|
|||||||
|
|
||||||
def sanitize_comments_html(html):
|
def sanitize_comments_html(html):
|
||||||
text = html2text(html)
|
text = html2text(html)
|
||||||
md = markdown.Markdown(safe_mode=True)
|
md = Markdown(safe_mode='remove')
|
||||||
cleansed = re.sub('\n+', '', md.convert(text))
|
cleansed = re.sub('\n+', '', md.convert(text))
|
||||||
cleansed = cleansed.replace(markdown.HTML_REMOVED_TEXT, '')
|
|
||||||
return cleansed
|
return cleansed
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user