v7.6.2: 🔁 Lossless Markdown Round-Trips for Code Blocks, Inline Code, Line Breaks & Tables
I am pleased to announce the release of officeParser v7.6.2! This patch closes four Markdown/HTML round-trip fidelity bugs found while driving a real editor's save → load → save cycle through officeParser: a single-line code block losing its language, inline code losing its backticks, a raw <br> being escaped, and a table header emitting invalid HTML. Each was a case where officeParser's own output did not reparse into what produced it; all four now round-trip cleanly.
These are corrections, not new behavior to guard against: the only output that moves is content that was previously lost, escaped, or emitted as invalid markup, so upgrading fixes those cases rather than disturbing working ones. If you built a workaround for any of them, you can drop it.
🔧 What's Fixed
1. Single-line code blocks keep their language
MarkdownGenerator chose fenced-vs-inline purely by whether the code text contained a newline, ignoring the language, so a one-line code block (const x = 1; tagged js) or a one-line mermaid diagram collapsed to an inline `code` span. That silently dropped both the language and its block-ness, and re-imported as an inline code mark rather than a code block. A code node is always block-level (genuinely inline code is a monospace text node), so a code node with a language now always emits as a fenced block regardless of newlines. A tagged `const x = 1;` becomes a proper js block again.
2. Inline code keeps its backticks
Inline code parses to a monospace text node, but the generator's text-node path had no backtick emission for it, so every inline `code` (and inline <code> from HTML) degraded to plain text on md → md and html → md. Monospace text is now re-wrapped in backticks, fence-sized so an embedded backtick can't close the span early, with emphasis wrapping the span so **`code`** round-trips.
3. Raw <br> round-trips symmetrically
MarkdownGenerator emits a raw <br> for a line break inside a table cell (a GFM pipe cell cannot hold a newline), but MarkdownParser did not read it back. It escaped <br> to <br>, destroying the break on the md → html hop, in cells and paragraphs alike. The parser now recognises <br> / <br/> / <br /> as a hard line break, symmetric with what the generator writes, so a <br> survives the round trip. A table-cell line break, ubiquitous in Word-imported forms and exams, is now preserved.
4. Valid, self-idempotent table headers
generate('html') emitted a table's header cells directly under <thead> (<thead><th>…) with no wrapping <tr>, which is invalid HTML that officeParser's own HtmlParser could not read back as a table, so a md → HTML → md round trip lost the header (its cells came back empty). The header row is now wrapped in a <tr> (<thead><tr><th>…), which is valid and self-idempotent.
📝 Also
- Heading anchors are already toggleable.
generate('md')appends a kramdown/Pandoc{#slug}suffix to headings (# Title {#title}), which GFM/CommonMark render as literal text. The existing top-levelgenerateIds: falseomits it (and the HTML headingids). It is a generator-wide option, not undermdConfig, which made it easy to miss. Now documented in the README.
🛠 Getting Started
npm install officeparser@7.6.2🔗 Full Changelog: View v7.6.2 details
🔗 Documentation & Visualizer: officeparser.harshankur.com