django-markdown不能支持粗体还是斜体?

时间:2018-01-27 09:43:55

标签: javascript python django markdown

我使用django-markdown模块使注释支持markdown,但是存在问题。不支持粗体和斜体。其他的,如pre,title等,效果很好。为什么呢?

django user-define templatetags

from django import template

import markdown

register = template.Library()
@register.filter
def markdown_change(content):
    content = markdown.markdown(content,extensions=['markdown.extensions.extra','markdown.extensions.codehilite','markdown.extensions.toc',])
    return content

模板

<p>{{comment.content|markdown_change|safe}}</p>

views.py

def contact(request): 
    if request.method == 'POST':
        if request.user.username:
            form = CommentForm(request.POST)
            if form.is_valid():
                form.save()
                form = CommentForm()
                comment_list = Comment.objects.all().filter(public = True).order_by('id').reverse()
                if len(comment_list) > 5:
                    data,comment_list=comment_paginator(request,comment_list)
                else:
                    data=''
                response = True
                context = {'form':form,'comment_list':comment_list,'response':response,'data':data}
                return render(request,'contact.html',context=context)
    else:
        form = CommentForm()
    comment_list = Comment.objects.all().filter(public = True).order_by('id').reverse()
    if len(comment_list) > 5:
        (data,comment_list)=comment_paginator(request,comment_list)
    else:
        data=''
    context = {'form':form,'comment_list':comment_list,'data':data}
    return render(request,'contact.html',context=context)

0 个答案:

没有答案