Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions blog/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def datetimeformat(data):
@register.filter()
@stringfilter
def custom_markdown(content):
"""
通用markdown过滤器,应用文章内容插件
主要用于文章内容处理
"""
html_content = CommonMarkdown.get_markdown(content)

# 然后应用插件过滤器优化HTML
Expand All @@ -61,6 +65,13 @@ def custom_markdown(content):
return mark_safe(optimized_html)


@register.filter()
@stringfilter
def sidebar_markdown(content):
html_content = CommonMarkdown.get_markdown(content)
return mark_safe(html_content)


@register.simple_tag(takes_context=True)
def render_article_content(context, article, is_summary=False):
"""
Expand Down
2 changes: 1 addition & 1 deletion templates/blog/tags/sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<aside class="widget_text widget widget_custom_html"><p class="widget-title">
{{ sidebar.name }}</p>
<div class="textwidget custom-html-widget">
{{ sidebar.content|custom_markdown|safe }}
{{ sidebar.content|sidebar_markdown|safe }}
</div>
</aside>
{% endfor %}
Expand Down