-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WordPress allows to include markup on titles and we want to get rid of them.
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
from HTMLParser import HTMLParser | ||
|
||
|
||
class MLStripper(HTMLParser): | ||
|
||
"""Taken from: http://stackoverflow.com/a/925630/644075 | ||
Why don't you use RegEx? http://stackoverflow.com/a/1732454/644075 | ||
""" | ||
|
||
def __init__(self): | ||
self.reset() | ||
self.fed = [] | ||
|
||
def handle_data(self, d): | ||
self.fed.append(d) | ||
|
||
def get_data(self): | ||
return ''.join(self.fed) | ||
|
||
|
||
def strip_tags(html): | ||
"""Remove HTML tags from a string.""" | ||
s = MLStripper() | ||
s.feed(html) | ||
return s.get_data() |