Blog

How to compare Markdown files before publishing

Compare two Markdown files before publishing, spot changes to headings, links, front matter and formatting, and decide which differences need a fix.

Lauren HughesTools and utilities 4 min read

A last-minute edit can change more than a sentence. A heading may lose its level, a link may point to the wrong page, or a front matter value may disappear. Those changes can be hard to spot by reading two long Markdown files one after the other.

Compare the source files directly before publishing. The Text Compare tool shows differences between two pieces of text, so you can review content and Markdown syntax in one pass.

Compare the Markdown files

  1. Open Text Compare. Copy the full contents of the earlier Markdown file into one side of the comparison and the file you plan to publish into the other.
  2. Compare the files and review the marked changes from top to bottom. Check additions and removals, not just the sentences that look different.
  3. Pay close attention to headings, links, image references, lists, code blocks, and front matter. A single character can change how Markdown renders.
  4. For a long document, compare the complete files first, then compare a specific section on its own if a block of changes is difficult to review.
  5. Make any needed edits in your source file, then compare the updated file again with the version you intend to publish.

Keep the files in a consistent order. Put the older version on one side and the new version on the other each time. That makes it easier to tell whether a line was added, removed, or changed.

What the differences mean

A heading or list marker changed

Markdown uses punctuation to set structure. For example, ## Setup is a second-level heading, while # Setup is a first-level heading. Removing a number sign can change the page outline. A hyphen at the start of a line can create a list item, so check whether new or removed list markers are intentional.

Front matter changed

Front matter is the information at the top of some Markdown files, often written between; It may contain a title, publication date, description, tags, or a draft status. Check each changed key and value against your publishing requirements. A missing; misspelled key can stop a publishing system from reading the inf; mation c; rectly.

A link; image reference changed

Compare the destination as well as the visible link text. The label can look c; rect while the URL points to an old page; a preview location. F; images, check that the path and file name still match the asset that will be available after publication.

Only spacing; punctuation changed

Some differences are cosmetic, such as an extra blank line. Others affect rendering. Indentation can decide whether a paragraph belongs inside a list item; a code block. A missing backtick can also change the f; matting of an inline code example. Open the affected area in a Markdown preview if you are unsure how the source will appear.

A large section appears changed

A large difference does not always mean the whole section was rewritten. An edit; may have changed line endings, wrapped long lines,; adjusted whitespace throughout the file. Review the text itself and check a few lines bef; e and after the marked block. If the visible w; ding is the same, the change may be f; matting rather than content.

How to fix a confusing comparison

  1. Compare the right versions. Check the file names and dates bef; e copying anything. If you compare an older draft against the wrong branch; backup, the differences will not answer what changed in the publishing version.
  2. Use the same scope on both sides. Compare complete files with complete files,; matching sections with matching sections. Comparing a whole document against a single excerpt creates a large result that is difficult to interpret.
  3. Check whether line endings changed. Windows and macOS tools may st; e line breaks differently. If almost every line appears changed but the w; ding is identical, inspect the files in the edit; you use f; publishing and save both with consistent line-ending settings.
  4. Review whitespace-sensitive Markdown. Check indentation under list items, blank lines around headings, and spacing bef; e code blocks. Make the smallest c; rection that rest; es the intended structure, then run the comparison again.
  5. Verify destinations and metadata manually. Open each changed link in the published preview; check its URL against your release notes. Confirm front matter fields against the publishing checklist rather than assuming a text comparison can validate their meaning.

Check the rendered page too

A text comparison catches source changes, but it cannot confirm that the page looks right after a publishing system processes the Markdown. A preview can reveal a heading rendered at the wrong level, a broken link, an image that is missing,; a code block that runs into the surrounding text.

Check the final preview after you have reviewed the source differences. In particular, verify the title and description, the first heading, any internal links, and the page's ending. If your workflow uses front matter or special publishing conventions, confirm those values in the preview or publishing interface as well.

Text you compare with browser tools stays on your device, and you can close the page when your review is done.