Пример #1
0
def render_post(context, post):
    if post.type == Post.TYPE_WEEKLY_DIGEST:
        # never render digests again to preserve their original state
        return post.html

    if not post.html or settings.DEBUG:
        new_html = markdown_text(post.text)
        if new_html != post.html:
            # to not flood into history
            post.html = new_html
            post.save()

    return mark_safe(post.html or "")
Пример #2
0
def render_comment(context, comment):
    if comment.is_deleted:
        if comment.deleted_by == comment.author_id:
            by_who = " его автором"
        elif comment.deleted_by == comment.post.author_id:
            by_who = " автором поста"
        else:
            by_who = " модератором"

        return mark_safe(
            f"""<p class="comment-text-deleted">😱 Комментарий удален{by_who}...</p>"""
        )

    if not comment.html or settings.DEBUG:
        new_html = markdown_text(comment.text)
        if new_html != comment.html:
            # to not flood into history
            comment.html = new_html
            comment.save()

    return mark_safe(comment.html or "")
Пример #3
0
def markdown(text):
    return mark_safe(markdown_text(text))