fix(export): stop Obsidian hiding leading-dot note names - #2242
Open
SyedFahad7 wants to merge 2 commits into
Open
fix(export): stop Obsidian hiding leading-dot note names#2242SyedFahad7 wants to merge 2 commits into
SyedFahad7 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.
Comment on lines
+446
to
+450
| 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 |
Contributor
Author
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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