Skip to content

Commit

Permalink
fix modal preview description text rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Miniapple8888 committed Jun 22, 2021
1 parent de4d076 commit 23956c8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions app/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -937,3 +937,7 @@ a > .fa-envelope:hover {
transform: translate(24px, 0);
}
}

.editor-toolbar .fa {
font-weight: 900 !important;
}
2 changes: 1 addition & 1 deletion app/templates/project_preview_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<div class="col-7" style="padding-left: 32px;float:none;">
<h3 class="">{{ project.name }}</h3>
<p class="grey">{{ project.description|truncatechars(100) }}</p>
<p class="grey">{{ project.description|truncatechars(100)|mistune|html_strip }}</p>

<a href="{{ url('user', username=project.creators.first().username) }}">
<div class="row" style="display: flex !important;">
Expand Down
22 changes: 22 additions & 0 deletions app/templatetags/html_parse.py
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())
1 change: 0 additions & 1 deletion app/templatetags/mistune.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django_jinja import library
from django.utils.safestring import mark_safe


@library.filter
def mistune_html_no_highlight(text):
return mark_safe(mistune.markdown(text))
1 change: 1 addition & 0 deletions stratus/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"lstrip_blocks": True,
"filters": {
'mistune': 'app.templatetags.mistune.mistune_html_no_highlight',
'html_strip': 'app.templatetags.html_parse.strip_tags',
'class_name': 'app.templatetags.class_name.get_class_name',
},
"context_processors": [
Expand Down

0 comments on commit 23956c8

Please sign in to comment.