fix: keep inline images in Micropub articles (v2.16.0)

- Content sent as both html and text is stored as the HTML; the text is
  usually a plain fallback, so images, links and headings were lost.
- Images embedded from other sites are copied into the media library
  (SSRF-checked fetcher, best effort, max 20) and the text points at the
  copies, on create and on content replace.
- HTML content is sanitized as is instead of going through Markdown, which
  added stray <br>s and empty paragraphs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PhilandClaude Opus 5.5 committed 2026-11-11 17:11:46 -07:00
1 parent 978c13358b
commit ccb9f6dce2
5 files changed
+117 -14

No files matched your search

+7 -2
View File
@@ -298,8 +298,13 @@ class Note:
<p>This is my note content...</p>
"""
if self._cached_html is None:
# Render markdown to sanitized HTML (v2.9.0)
html = render_markdown(self.content) # triggers lazy load of content
if self.content_format == "html":
# Sent as HTML via Micropub: sanitize it as is. Through Markdown
# it picked up stray <br>s and empty paragraphs (v2.16.0)
html = nh3.clean(self.content, tags=ALLOWED_TAGS, attributes=ALLOWED_ATTRIBUTES)
else:
# Render markdown to sanitized HTML (v2.9.0)
html = render_markdown(self.content) # triggers lazy load of content
# Cache it
object.__setattr__(self, "_cached_html", html)