mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Comments editor: Strip HTML comments from markup
This commit is contained in:
parent
f8d96fb9d4
commit
e59d0037f1
@ -62,6 +62,8 @@ class EditorWidget(QWebView): # {{{
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
QWebView.__init__(self, parent)
|
QWebView.__init__(self, parent)
|
||||||
|
|
||||||
|
self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)
|
||||||
|
|
||||||
for wac, name, icon, text, checkable in [
|
for wac, name, icon, text, checkable in [
|
||||||
('ToggleBold', 'bold', 'format-text-bold', _('Bold'), True),
|
('ToggleBold', 'bold', 'format-text-bold', _('Bold'), True),
|
||||||
('ToggleItalic', 'italic', 'format-text-italic', _('Italic'),
|
('ToggleItalic', 'italic', 'format-text-italic', _('Italic'),
|
||||||
@ -213,6 +215,7 @@ class EditorWidget(QWebView): # {{{
|
|||||||
raw = unicode(self.page().mainFrame().toHtml())
|
raw = unicode(self.page().mainFrame().toHtml())
|
||||||
raw = xml_to_unicode(raw, strip_encoding_pats=True,
|
raw = xml_to_unicode(raw, strip_encoding_pats=True,
|
||||||
resolve_entities=True)[0]
|
resolve_entities=True)[0]
|
||||||
|
raw = self.comments_pat.sub('', raw)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
root = html.fromstring(raw)
|
root = html.fromstring(raw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user