]> danix's work - publisher.git/commitdiff
fix: preserve article body when saving frontmatter
authorDanilo M. <redacted>
Sun, 3 May 2026 14:14:09 +0000 (16:14 +0200)
committerDanilo M. <redacted>
Sun, 3 May 2026 14:14:09 +0000 (16:14 +0200)
FrontmatterEditor._save was passing empty string as body to
write_frontmatter, erasing all content below the +++ delimiter.
Now reads body via parse_frontmatter before writing back.

Co-Authored-By: Claude Sonnet 4.6 <redacted>
ui/frontmatter_editor.py

index ce7035596c78ee7f9c150b59a47b9873bf777c07..6c53ac3e5c4cc626c2186a84e5ea39c4488c7399 100644 (file)
@@ -7,7 +7,7 @@ from PyQt6.QtWidgets import (
 from PyQt6.QtCore import Qt
 from pathlib import Path
 from core.models import Article, ARTICLE_TYPES
-from core.frontmatter import write_frontmatter
+from core.frontmatter import parse_frontmatter, write_frontmatter
 from core.taxonomy import load_taxonomy
 
 class MultiTokenCompleter(QCompleter):
@@ -109,7 +109,8 @@ class FrontmatterEditor(QDialog):
                 else:
                     updated[key] = val
         try:
-            write_frontmatter(self._article.path, updated, "")
+            _, body = parse_frontmatter(self._article.path)
+            write_frontmatter(self._article.path, updated, body)
             self._article.frontmatter.update(updated)
             self.accept()
         except Exception as e: