|
|
@@ -54,7 +54,24 @@ class MarkRenderer(mistune.HTMLRenderer): |
|
|
|
return "<mark>" + text + "</mark>" |
|
|
|
|
|
|
|
|
|
|
|
class ImgsWithSizesRenderer(MarkRenderer): |
|
|
|
class BlockquoteLanguageRenderer(MarkRenderer): |
|
|
|
"""Sets the English language attribute for blockquotes with `[en]` prefix.""" |
|
|
|
|
|
|
|
def _get_language(self, text): |
|
|
|
if text.startswith("<p>[en] "): |
|
|
|
return "en", text.replace("<p>[en] ", "<p>") |
|
|
|
else: |
|
|
|
return None, text |
|
|
|
|
|
|
|
def block_quote(self, text): |
|
|
|
language, text = self._get_language(text) |
|
|
|
if language: |
|
|
|
return f'\n<blockquote lang="{language}">\n{text}</blockquote>\n' |
|
|
|
else: |
|
|
|
return f"<blockquote>\n{text}</blockquote>\n" |
|
|
|
|
|
|
|
|
|
|
|
class ImgsWithSizesRenderer(BlockquoteLanguageRenderer): |
|
|
|
"""Renders images as <figure>s and add sizes (useful for lazy loading).""" |
|
|
|
|
|
|
|
def paragraph(self, text): |