diff --git a/jweb/extensions/markdown.py b/jweb/extensions/markdown.py index 93171b3..76d9cf1 100644 --- a/jweb/extensions/markdown.py +++ b/jweb/extensions/markdown.py @@ -10,7 +10,7 @@ def load_extension(context: Context) -> None: context.add_filters(markdown=_MarkdownDocument) -class _MarkdownDocument: +class _MarkdownDocument(Content[str]): def __init__(self, content: Content[Any]) -> None: if not isinstance(content, Content) or not isinstance(content.data, (str, bytes)): raise ValueError("markdown filter can only accept byte or string content") @@ -23,11 +23,7 @@ class _MarkdownDocument: self.__content = content self.__markdown = Markdown(extensions=["full_yaml_metadata"]) - self.__html = self.__markdown.convert(data) - - @property - def html(self) -> str: - return self.__html + super().__init__(content.path, self.__markdown.convert(data), content.language) @property def meta(self) -> Any: diff --git a/tests/extensions/test_markdown/src/test-load.html b/tests/extensions/test_markdown/src/test-load.html index a0a3802..728bca7 100644 --- a/tests/extensions/test_markdown/src/test-load.html +++ b/tests/extensions/test_markdown/src/test-load.html @@ -1,4 +1,4 @@ {% with document = content | markdown %} - {{- document.html }} + {{- document }} {%- endwith -%} diff --git a/tests/test_context/locale/fr/LC_MESSAGES/tests.po b/tests/test_context/locale/fr/LC_MESSAGES/tests.po index 8af53fc..1069f84 100644 --- a/tests/test_context/locale/fr/LC_MESSAGES/tests.po +++ b/tests/test_context/locale/fr/LC_MESSAGES/tests.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2024-05-21 23:32+0200\n" +"POT-Creation-Date: 2024-05-21 23:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language: fr\n"