-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix modal preview description text rendering
- Loading branch information
1 parent
de4d076
commit 23956c8
Showing
5 changed files
with
28 additions
and
2 deletions.
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
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,22 @@ | ||
from django_jinja import library | ||
from django.utils.safestring import mark_safe | ||
from io import StringIO | ||
from html.parser import HTMLParser | ||
|
||
class MLStripper(HTMLParser): | ||
def __init__(self): | ||
super().__init__() | ||
self.reset() | ||
self.strict = False | ||
self.convert_charrefs= True | ||
self.text = StringIO() | ||
def handle_data(self, d): | ||
self.text.write(d) | ||
def get_data(self): | ||
return self.text.getvalue() | ||
|
||
@library.filter | ||
def strip_tags(html): | ||
s = MLStripper() | ||
s.feed(html) | ||
return mark_safe(s.get_data()) |
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