See Ash Code logo See Ash Code

A revision history needs more than a pile of old Markdown

Ashlynn Antrobus
• • 3 min read

Keeping old Markdown gives me previous text. A useful revision feature also needs to tell me which text I’m viewing, what changed, and what will happen if I restore it.

The February revision-tracking snapshot connects stored revisions, commit identities, a diff service, and the editing interface. It follows the file-and-database content lifecycle, with another distinction to preserve: restoring a draft isn’t the same operation as publishing it.

Give each version an identity

A revision records its Markdown content with a commit SHA, author, timestamp, and message. The timeline can show those details while the selected SHA identifies the text to retrieve or compare.

These are revisions of an article. They are separate from the application-repository commits that implemented the revision feature itself.

For a teaching walkthrough, suppose an article goes through this sequence:

EventArticle text
OriginalUse one worker.
Edit AUse two workers.
Edit BUse three workers.
Restore Edit AUse two workers.

The last row needs a new identity. It has the same text as Edit A, but it represents a later decision to restore that text. Edit B remains part of the history.

Compare the intended pair

DiffService compares old and new content and produces lines marked as additions, deletions, or context, with their corresponding line numbers.

Wikipedia's Android app shows two selected edits in a revision history for comparison.

An example from the Wikipedia Android app, by HNordeen (WMF), CC0. This is a different interface from my blog.

Comparing Edit A with Edit B in this example should show:

-Use two workers.
+Use three workers.

Reversing the inputs reverses that description. A viewer needs to make the selected versions clear; red and green alone don’t identify which version is earlier.

The service normalizes line endings before comparing and marks inputs above its line-count threshold as large files. Its HTML output escapes the displayed line content. A Markdown diff should display the source text, not accidentally interpret it as the page’s HTML.

Restoring creates another change

The revert handler checks the acting user’s ownership or administrator role, loads the target revision, and writes its content into the current draft. It then creates a new GitHub commit and records a revision with is_revert=True.

It doesn’t rewrite the old commits out of the article’s history. That preserves both the intervening edit and the decision to undo it.

There are still failure boundaries. The handler writes the draft before requesting the GitHub commit. If that commit fails, the handler raises an error; a local write has already happened. Calling the operation a revert doesn’t make those stores one atomic transaction.

It also doesn’t run the publication handler. In this revision, restoring the draft and replacing the published HTML are separate operations. The interface needs to make that distinction understandable rather than suggest that every restore immediately changes what readers see.

AA

Written by Ashlynn Antrobus

Software developer, author, and builder. Sharing technical lessons learned from building tools like Ebook2Text, IndexedDict, and rag-mcp, and navigating life as a programmer with dyslexia.