fix(export): stop Obsidian hiding leading-dot note names - #2242
fix(export): stop Obsidian hiding leading-dot note names#2242SyedFahad7 wants to merge 2 commits into
Conversation
safe_name left stems like .env intact, so the vault wrote .env.md which Obsidian treats as a hidden file — invisible in the explorer and as unresolved wikilinks. Prefix with dot- (shared _obsidian_safe_stem for vault + canvas). True label stays in the note body. Fixes Graphify-Labs#2205
There was a problem hiding this comment.
Pull request overview
This PR fixes Obsidian exports for nodes whose labels begin with a leading dot (e.g. .env, .gitignore) by ensuring the generated note/canvas filename stems don’t start with . (which Obsidian treats as hidden). It centralizes Obsidian-safe filename logic into a shared helper so both the vault exporter (to_obsidian) and canvas exporter (to_canvas) stay consistent.
Changes:
- Add
_obsidian_safe_stem()to generate Obsidian-safe filename stems (includingdot-prefix for leading-dot labels) and keep the existing punctuation-only fallback (unnamed). - Replace duplicated inline
safe_name()implementations into_obsidianandto_canvaswith the shared helper. - Apply the shared helper consistently to community note filenames and cross-community wikilinks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cleaned = re.sub(r"\.(md|mdx|qmd|markdown)$", "", cleaned, flags=re.IGNORECASE) | ||
| # Obsidian treats a leading-dot filename as a hidden file (#2205). | ||
| if cleaned.startswith("."): | ||
| cleaned = "dot-" + cleaned.lstrip(".") | ||
| # A stem of only punctuation (e.g. "@", "*", "#") survives the unsafe-char |
There was a problem hiding this comment.
good call — pushed a regression test for .env / .gitignore stems on both the vault notes and the canvas file nodes.
Assert .env / .gitignore become dot-env / dot-gitignore on disk and in the canvas file nodes, so Obsidian cannot hide them again (Graphify-Labs#2205).
….example regression test (#2205, #2184) Follow-ups on the cherry-picked #2242/#2232: an all-dots label ('...') no longer produces an empty 'dot-' Obsidian stem (falls back to 'unnamed'), and the .env.example carve-out gets the regression test it shipped without (templates graphable, real .env still sensitive, secrets/.env.example still dropped). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @SyedFahad7. Shipped in v0.9.29 (cherry-picked to v8), with a follow-up so an all-dots label falls back to 'unnamed'. Closed-unmerged here, but it's in the release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.29 |
Summary
Fixes #2205.
Obsidian hides any note whose filename starts with
., so nodes labeled.env/.gitignorewere written to the vault but never showed up (and wikilinks to them looked broken).safe_namenow turns a leading-dot stem intodot-…via a shared_obsidian_safe_stemused by both the vault and canvas exporters. H1 / frontmatter still have the real label.Test plan
.env/.gitignorenodes — notes appear asdot-env.mdetc. in Obsidianunnamed(to_obsidian: all-punctuation labels emit punctuation-only filenames (e.g. @.md) that break downstream slug/indexers (qmd handelize crash) #1409)uv run pytest tests/test_export.py -q -k obsidian