Add ignore comment tags

This commit is contained in:
Bruno Miguens
2021-02-05 19:38:24 +00:00
parent 77d1e99bd5
commit 321e9eb5f6
2 changed files with 12 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
from bs4 import BeautifulSoup, NavigableString
from bs4 import BeautifulSoup, NavigableString, Comment
import re
import six
@@ -75,7 +75,9 @@ class MarkdownConverter(object):
# Convert the children first
for el in node.children:
if isinstance(el, NavigableString):
if isinstance(el, Comment):
continue
elif isinstance(el, NavigableString):
text += self.process_text(six.text_type(el))
else:
text += self.process_tag(el, convert_children_as_inline)