A contract that separates text from structure. Mark your HTML with data-sync, edit the .md, run one command — only content changes.
Benefits
Predictability is the feature. No magic, no heuristics, no invisible regressions.
textContent or innerHTML on marked nodes. Nothing else is touched.data-sync attribute in HTML. One # key section in Markdown. That’s it..md to the model. HTML stays protected. Run push to apply safely.push, pull, init. Three commands to cover your workflow. Zero mandatory config.pull. Use it as a backup before iterating with AI.How it works
Mapping is deterministic. What you write in .md goes exactly where you marked in HTML.
data-syncAdd data-sync="key" to any element. Use data-sync-mode="html" when you need rich HTML content.
<h1 data-sync="hero-title"> Original Title </h1> <p data-sync="hero-desc"> Original description. </p> <div data-sync="features" data-sync-mode="html"> <!-- Rich HTML here --> </div>
Create sections with # key matching the HTML data-sync values. Hand this file to the language model for copy edits.
# hero-title The Future of AI Orchestration # hero-desc Turn briefs into functional MVPs in 48 hours. # features <ul> <li>Fast</li> <li>Secure</li> </ul>
Use push to apply Markdown to HTML or pull to extract HTML to Markdown. Layout remains untouched.
html-md-sync push # apply .md to .html
html-md-sync pull # extract HTML to .md
Installation
Install globally or as a project devDependency:
npm i -g html-md-sync
npm i -D html-md-sync npx html-md-sync init
# create sync-config.json html-md-sync init # apply MD → HTML html-md-sync push # extract HTML → MD html-md-sync pull
Command reference:
| help | Show help and available commands |
| version | Installed CLI version |
| init [--config] | Create a default sync-config.json |
| push [--config] | Apply content from .md into .html |
| pull [--config] | Extract content from .html to .md |
Configuration
sync-config.json defines which files to sync and how.
{
"mappings": [
{
"html": "./src/index.html",
"md": "./content/home.md",
"strategy": "data-attribute"
}
],
"options": {
"preserveAttributes": true,
"minifyOutput": false
}
}
| mappings[].html | Path to the HTML file |
| mappings[].md | Path to the Markdown file |
| strategy | Reserved — MVP uses data-attribute |
| preserveAttributes | Keep all HTML attributes intact |
| minifyOutput | Minify HTML output (reserved) |
↑ Contract guarantees
FAQ
Yes. Point mappings[].html to the final HTML or to the templates that produce HTML. The tool is framework‑agnostic — it operates directly on the HTML file.
No. Only the content of nodes marked with data-sync is changed. Classes, IDs, event handlers, scripts and any other attributes remain untouched.
Version all three: .md, .html and sync-config.json. Before iterating with AI, run pull to capture the current HTML state in Markdown — a clean snapshot.
Yes. Mark the node with data-sync-mode="html" and write HTML directly in the corresponding Markdown section. The tool uses innerHTML instead of textContent.
It’s silently ignored during push. No error is thrown and HTML remains unaffected. The opposite — a key in HTML with no match in MD — keeps the original content unchanged.
Give only the .md to the language model for copy edits. HTML stays protected. After editing, run html-md-sync push to safely apply the content. For a backup of the current state, run pull before iterating.
Ready to start?
One line in the terminal. Content updated. Layout untouched. Exactly as it should be.