diff --git a/src/calibre/ebooks/html.py b/src/calibre/ebooks/html.py
index 1c15973d3b..1f1e6b94b1 100644
--- a/src/calibre/ebooks/html.py
+++ b/src/calibre/ebooks/html.py
@@ -331,7 +331,8 @@ class PreProcessor(object):
# Convert all entities, since lxml doesn't handle them well
(re.compile(r'&(\S+?);'), convert_entities),
# Remove the ]*>'), lambda match: ''),
+ (re.compile(r'{0,1}!\[(end){0,1}if\]{0,1}>', re.IGNORECASE),
+ lambda match: ''),
]
# Fix pdftohtml markup