Skip to content

Commit

Permalink
* Fix beautiful soups automatic surrounding with <html> and <body> tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christoph Lassner authored and Christoph Lassner committed Oct 31, 2014
1 parent 91717a2 commit 4adf75a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion better_code_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
This plugin:
- Adds a div wrapper around all tables with class name 'codehilitetable'
- The surrounding div is of class 'hilitewrapper' and can be used to
- The surrounding div is of class 'hilitewrapper' and can be used to
add an appropriate style to the code samples, e.g. for making them
scrollable.
"""
Expand All @@ -50,6 +50,9 @@ def content_object_init(instance):
wrapper_tag['class'] = 'hilitewrapper'
ctbl.wrap(wrapper_tag)
instance._content = soup.decode()
# If beautiful soup appended html tags.
if instance._content.startswith('<html>'):
instance._content = instance._content[12:-14]

def register():
signals.content_object_init.connect(content_object_init)

0 comments on commit 4adf75a

Please sign in to comment.