diff --git a/content/templates/jinja2/page.html b/content/templates/jinja2/page.html index f155370..d829a40 100644 --- a/content/templates/jinja2/page.html +++ b/content/templates/jinja2/page.html @@ -1,2 +1,2 @@ {% extends "base.html" %} -{% block content %}{{ object.content_md|safe }}{% endblock %} +{% block content %}{{ object.content|safe }}{% endblock %} diff --git a/content/templates/jinja2/post.html b/content/templates/jinja2/post.html index 1bf8c69..804119a 100644 --- a/content/templates/jinja2/post.html +++ b/content/templates/jinja2/post.html @@ -4,5 +4,5 @@ PubliƩ le {{ object.timestamp.strftime("%Y-%m-%d") }}.

{{ object.title }}

-{{ object.content_md|safe }} +{{ object.content|safe }} {% endblock %} diff --git a/jssg/models.py b/jssg/models.py index a41f524..a94f450 100644 --- a/jssg/models.py +++ b/jssg/models.py @@ -44,13 +44,13 @@ def __init__(self, content: str, **metadata: Mapping[str, str]) -> None: :param content: The content (body) of the document :param metadata: Associated metadata """ - self.content = content + self.body = content self.metadata = dict(metadata) self.path = metadata["path"] self.data = {} @property - def content_md(self) -> str: + def content(self) -> str: """Render the content as markdown to html. Note: the content will be processed by the django template engine @@ -68,9 +68,6 @@ def content_md(self) -> str: # multiline text # easy to read" # }}} - def convert_case(match_obj): - return match_obj.group(2).replace("\n", " ") - self.content = re.sub("({{{TO-1-LINE)(((?!TO-1-LINE}}}).)*)(TO-1-LINE}}})", convert_case, self.content, flags=re.DOTALL) # INFO - D.A. - Original code is below and is returned a markdown-based processed content # this works only with unindented HTML templates because markdown interprets indentation @@ -78,7 +75,7 @@ def convert_case(match_obj): # Expected: allow to process both HTML and markdown content types # # return markdown2.markdown( - # Template(self.content).render( + # Template(self.body).render( # Context( # { # "posts": sorted( @@ -92,7 +89,7 @@ def convert_case(match_obj): # ) if "engine" in self.metadata.keys() and self.metadata["engine"] == "jinja2" : - return engines["jinja2"].from_string(self.content).render( + return engines["jinja2"].from_string(self.body).render( { "posts": sorted( Post.load_glob(), key=lambda p: p.timestamp, reverse=True @@ -101,7 +98,7 @@ def convert_case(match_obj): } ) else : - return Template(self.content).render( + return Template(self.body).render( Context( { "posts": sorted( diff --git a/jssg/views.py b/jssg/views.py index e58963e..ead7530 100644 --- a/jssg/views.py +++ b/jssg/views.py @@ -37,7 +37,7 @@ def item_title(self, post: Post) -> str: return post.title def item_description(self, item: Post): - return item.content_md + return item.content def item_link(self, post: Post) -> str: return reverse("post", args=(post.slug,))