Add markdown support to post body
Implemented markdown support in the post body to enhance the editor's functionality. The main blog view now renders markdown content as HTML. This change allows users to format their posts using markdown syntax, providing a richer text editing experience. - Imported the markdown module in blog.py. - Converted post bodies from markdown to HTML in the index view. - Updated templates to indicate markdown support in the post body field. - Ensured safe rendering of HTML content in the blog index view. Fixes #FLAS-29
This commit is contained in:
parent
56009a2934
commit
1d2f1348a4
4 changed files with 7 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ from flask import render_template
|
|||
from flask import request
|
||||
from flask import url_for
|
||||
from werkzeug.exceptions import abort
|
||||
import markdown
|
||||
|
||||
from .auth import login_required
|
||||
from .db import get_db
|
||||
|
|
@ -22,6 +23,9 @@ def index():
|
|||
" FROM post p JOIN user u ON p.author_id = u.id"
|
||||
" ORDER BY created DESC"
|
||||
).fetchall()
|
||||
# Convert markdown to HTML for each post body
|
||||
for post in posts:
|
||||
post['body'] = markdown.markdown(post['body'])
|
||||
return render_template("blog/index.html", posts=posts)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue