From bcfde49188a15611d6be5bee15cb392e9540da3b Mon Sep 17 00:00:00 2001 From: nightmarejam <42326244+Nightmarejam@users.noreply.github.com> Date: Wed, 20 Aug 2025 20:27:17 -0700 Subject: [PATCH] fix: correct newline handling in archive index --- docs/archive/index.md | 2 ++ scripts/sync_chat_archive.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 docs/archive/index.md diff --git a/docs/archive/index.md b/docs/archive/index.md new file mode 100644 index 0000000..ce09424 --- /dev/null +++ b/docs/archive/index.md @@ -0,0 +1,2 @@ +# Archive Index +- [Archive](README.md) diff --git a/scripts/sync_chat_archive.py b/scripts/sync_chat_archive.py index d2fca5c..45b83bf 100644 --- a/scripts/sync_chat_archive.py +++ b/scripts/sync_chat_archive.py @@ -8,7 +8,8 @@ def main(): ARCHIVE_DIR.mkdir(parents=True, exist_ok=True) files = sorted([p for p in ARCHIVE_DIR.glob("**/*") if p.is_file() and p.suffix.lower() in (".md",".txt") and p.name != "index.md"]) - lines = ["# Archive Index\\n"] + # Start the index with a proper header line; no extra backslash needed + lines = ["# Archive Index"] for p in files: rel = p.relative_to(ARCHIVE_DIR) # extract top-level header if present @@ -22,7 +23,8 @@ def main(): pass display = title or rel.as_posix() lines.append(f"- [{display}]({rel.as_posix()})") - INDEX.write_text("\\n".join(lines), encoding="utf-8") + # Join lines with actual newlines and write out the index file + INDEX.write_text("\n".join(lines) + "\n", encoding="utf-8") print(f"[OK] Indexed {len(files)} items to {INDEX}") if __name__ == "__main__":