Menu

Why parse-and-stringify rewrites your Obsidian notes, and how specgit keeps the bytes you didn't touch
📰

Why parse-and-stringify rewrites your Obsidian notes, and how specgit keeps the bytes you didn't touch

#devcommunity#dev#file#obsidian#specgit
Reading 0:00
15s threshold

By the specgit team

Most of us have written this pipeline at least once. You parse a Markdown file into a syntax tree with remark, change one node, and stringify the tree back to text. For a .canvas file the move is even shorter: JSON.parse , mutate one object, JSON.stringify . Then someone points it at a real Obsidian vault in GitHub, and the first pull request arrives as a wall of red and green.

The reason is that a syntax tree records what a document means, not how it was typed. One document can be written many ways: a bullet can start with -, * or +, and emphasis can use asterisks or underscores. Once the parser has thrown those choices away, the stringifier has to make them again, and it makes them its own way on every save. Obsidian raises the stakes, because a vault is full of syntax a general Markdown tool has never heard of: callouts, wikilinks, block references, custom task statuses like [/] , Dataview fields and Templater tags.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.