Menu

Why a Markdown scanner should blank code spans, not delete them
📰

Why a Markdown scanner should blank code spans, not delete them

DEV Community: go·polycratia·4 days ago
#ow7Pke1b
#devtogo#devto#dev#line#rewrite
Reading 0:00
15s threshold

A link into a repository is worth reading only if it names a commit that cannot move underneath it. Checking that is the easy half: read the file, find the links, print a file:line for every ref that is not forty lowercase hex characters. The hard half starts when the same tool has to turn a branch link into a pinned one. Now it needs to write forty characters into a byte range of the file it just read, and every shortcut the reader took with positions is a bug waiting in the writer.

That pressure is what shaped srcproof , a small Go tool I wrote to keep repository links in prose honest. Two subcommands sit on one extractor. check reports links whose ref is not a full commit. pin resolves the branch and tag links of an article against a local clone and, with --write , rewrites them in place and records what it resolved in srcproof.lock . Both commands read the same Markdown through the same code.…

Continue reading — create a free account

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