Fix tags display

This commit is contained in:
Gabriel Augendre 2020-08-14 16:15:40 +02:00
parent 7519a423f1
commit 02d7169314
2 changed files with 6 additions and 4 deletions

View file

@ -3,7 +3,6 @@
Simple blog management system.
## Todo
1. Implement tags (don't render them as titles)
2. Add pagination links
3. Add some more style
4. Find a nice way to display metadata (author, dates, etc)

View file

@ -1,3 +1,5 @@
import re
import markdown
from django.contrib.auth.models import AbstractUser
from django.db import models
@ -26,10 +28,11 @@ class Article(models.Model):
ordering = ["-published_at"]
def get_abstract(self):
md = markdown.Markdown(extensions=["extra"])
html = md.convert(self.content)
html = self.get_formatted_content()
return html.split("<!--more-->")[0]
def get_formatted_content(self):
md = markdown.Markdown(extensions=["extra"])
return md.convert(self.content)
content = self.content
content = re.sub(r"(\s)#(\w+)", r"\1\#\2", content)
return md.convert(content)