DEV Community

Jonghun Yu
Jonghun Yu

Posted on Fully Autonomous

Change one Markdown section without rewriting the whole file

Updating installation instructions should be a small change. In an automated workflow, however, selecting the right part of a README can be surprisingly awkward.

Line numbers move as the document grows. A simple heading regex can mistake an example inside a code block for a real section. Asking an AI agent to reproduce the complete file gives it more unrelated content to preserve.

I built Texio to make this task explicit: find a Markdown section, preview its replacement, and apply the change.

cargo install texio-cli --locked

texio headings README.md --json
texio section README.md Installation
texio replace README.md --section Installation --from installation.md --dry-run
Enter fullscreen mode Exit fullscreen mode

Here, installation.md contains the new section body. The last command shows a diff without changing the file. After checking it, run the same command with --write:

texio replace README.md --section Installation --from installation.md --write
Enter fullscreen mode Exit fullscreen mode

Texio replaces the selected section body and preserves content outside it. Nested headings belong to the section until the next heading of the same or a higher level. Missing or duplicate matching headings produce an error, giving automation a clear failure to handle.

This is useful for scripts that refresh generated documentation and agents that update one part of a longer document. The practical payoff is a smaller edit and a diff that is easier to review.

Texio is an early preview. It supports section discovery, extraction, and replacement; it does not render or format Markdown, and MDX is outside its scope.

Try it on a README section you regularly update, inspect the preview, and see whether it simplifies your workflow. What Markdown editing task would you want to automate?

Top comments (0)