Skip to content

Commit 129c4ef

Browse files
committed
ignore doctype tag, test cdata tag
fixes #45
1 parent 9cb940c commit 129c4ef

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

markdownify/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from bs4 import BeautifulSoup, NavigableString, Comment
1+
from bs4 import BeautifulSoup, NavigableString, Comment, Doctype
22
import re
33
import six
44

@@ -124,7 +124,7 @@ def is_nested_node(el):
124124

125125
# Convert the children first
126126
for el in node.children:
127-
if isinstance(el, Comment):
127+
if isinstance(el, Comment) or isinstance(el, Doctype):
128128
continue
129129
elif isinstance(el, NavigableString):
130130
text += self.process_text(el)

tests/test_advanced.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,8 @@ def test_code_with_tricky_content():
2121
assert md('<code>/home/</code><b>username</b>') == "`/home/`**username**"
2222
assert md('First line <code>blah blah<br />blah blah</code> second line') \
2323
== "First line `blah blah \nblah blah` second line"
24+
25+
26+
def test_special_tags():
27+
assert md('<!DOCTYPE html>') == ''
28+
assert md('<![CDATA[foobar]]>') == 'foobar'

0 commit comments

Comments
 (0)