feat: support markdown in content
This commit is contained in:
parent
1a8ef81e0e
commit
fa7f820171
3 changed files with 10 additions and 1 deletions
|
@ -30,7 +30,7 @@ Show off your favorite public threads!
|
|||
$ . .venv/bin/activate
|
||||
|
||||
# install dependencies
|
||||
(.venv)$ python -m pip install flask requests
|
||||
(.venv)$ python -m pip install flask requests markdown
|
||||
|
||||
# rejoice!
|
||||
```
|
||||
|
|
|
@ -64,6 +64,13 @@
|
|||
|
||||
& .body {
|
||||
|
||||
& code {
|
||||
background: rgb(245, 242, 240);
|
||||
padding: 0.25em 0.3em;
|
||||
border-radius: 5px;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
& .media, & .link_card {
|
||||
border: 1px solid rgba(34, 34, 34, 0.15);
|
||||
border-radius: 5px;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from flask import Blueprint, render_template
|
||||
import requests
|
||||
import datetime
|
||||
import markdown
|
||||
|
||||
threads = Blueprint('threads', __name__, template_folder='template')
|
||||
|
||||
|
@ -85,6 +86,7 @@ def clean_author(account):
|
|||
def clean_status(status):
|
||||
clean = clean_dict(status, ['id', 'content', 'created_at', 'url', 'media_attachments', 'card'])
|
||||
clean['account'] = clean_author(status['account'])
|
||||
clean['content'] = markdown.markdown("<section markdown='block'>"+ clean['content'] +"<section>", extensions=['md_in_html'])
|
||||
for emoji in status['emojis']:
|
||||
clean['content'] = clean['content'].replace(":" + emoji['shortcode'] + ":", '<img alt="' + emoji['shortcode'] + ' emoji" class="emoji" src="'+emoji['url']+'" />')
|
||||
return clean
|
||||
|
|
Loading…
Reference in a new issue