refactor: make _MarkdownDocument inherit from content
This commit is contained in:
parent
cb2d41d571
commit
35454bfc0f
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% with document = content | markdown %}
|
||||
{{- document.html }}
|
||||
{{- document }}
|
||||
{%- endwith -%}
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <EMAIL@ADDRESS>\n"
|
||||
"Language: fr\n"
|
||||
|
|
|
|||
Loading…
Reference in New Issue