Regular expressions and text guides

Markdown and HTML conversion: what a round trip loses

Review formatting normalization, unsupported constructs and sanitization independently when converting documents.

Nav Tools ·

Expect data equivalence, not source equality

Several Markdown spellings produce the same HTML. Converting back may choose a different heading or emphasis style.

Use Text Diff to inspect changes, but judge whether the rendered meaning survives rather than expecting the original source bytes.

# Title

**strong**
→ <h1>Title</h1>
<p><strong>strong</strong></p>
Reverse conversion may choose another valid Markdown style.

Check extensions explicitly

Tables, task lists and custom containers depend on parser extensions and converter rules. CommonMark alone does not define every extension.

Test one example of each construct your document uses. Do not assume the HTML-to-Markdown tool has the exact inverse feature set.

Protect code blocks and whitespace

Code blocks, nested lists and line breaks can carry meaningful whitespace. An apparently cosmetic conversion can change a code example.

Compare code block contents separately and rerun any executable sample after conversion. Use fenced blocks with a deliberate language marker.

Sanitize before using generated HTML

Markdown conversion and HTML sanitization are different operations. Raw HTML or unsafe links can remain depending on the parser configuration.

The site shows generated code rather than executing user HTML. If your application renders it, apply a maintained sanitizer with an explicit policy.

References

← Regular expressions and text guides