Skip to content

Commit 60967c1

Browse files
authored
ignore script and style content (such as css and javascript) (#112)
1 parent c7718b6 commit 60967c1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

markdownify/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,12 @@ def convert_pre(self, el, text, convert_as_inline):
350350

351351
return '\n```%s\n%s\n```\n' % (code_language, text)
352352

353+
def convert_script(self, el, text, convert_as_inline):
354+
return ''
355+
356+
def convert_style(self, el, text, convert_as_inline):
357+
return ''
358+
353359
convert_s = convert_del
354360

355361
convert_strong = convert_b

tests/test_conversions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ def test_pre():
198198
assert md('<pre><span>\t\tthis should\t\tnot normalize</span></pre>') == '\n```\n\t\tthis should\t\tnot normalize\n```\n'
199199

200200

201+
def test_script():
202+
assert md('foo <script>var foo=42;</script> bar') == 'foo bar'
203+
204+
205+
def test_style():
206+
assert md('foo <style>h1 { font-size: larger }</style> bar') == 'foo bar'
207+
208+
201209
def test_s():
202210
inline_tests('s', '~~')
203211

0 commit comments

Comments
 (0)