Background
#139 fixes StorageWalker.cleanup() so it no longer strips leading whitespace and collapses inline multi-space inside fenced code blocks. The same regex pipeline still exists on the legacy path:
lib/html-to-markdown.js:146 — markdown.replace(/^[ \t]+(?!([\>]|[*+-] |\d+[.)] ))/gm, '')`
- and the surrounding cleanup chain (trailing-whitespace strip, blank-line collapse, multi-space collapse)
This path is still reachable: confluence-client.js:1203 exposes htmlToMarkdown(html) as a public method on the client.
Reproduction
const { htmlToMarkdown } = require('./lib/html-to-markdown');
const html = '<pre><code class="language-python">def foo():\n return 1</code></pre>';
console.log(htmlToMarkdown(html));
Expected: indented body preserved.
Actual: leading 4 spaces stripped (same shape of corruption as #139).
Why now
#139 already proved out the fix shape (split on triple-backtick fences, apply cleanup only to non-fenced segments). Porting the same approach over to html-to-markdown.js is a small, contained follow-up so the legacy path doesn't silently corrupt code that round-trips through confluenceClient.htmlToMarkdown().
Source
Background
#139 fixes
StorageWalker.cleanup()so it no longer strips leading whitespace and collapses inline multi-space inside fenced code blocks. The same regex pipeline still exists on the legacy path:lib/html-to-markdown.js:146—markdown.replace(/^[ \t]+(?!([\>]|[*+-] |\d+[.)] ))/gm, '')`This path is still reachable:
confluence-client.js:1203exposeshtmlToMarkdown(html)as a public method on the client.Reproduction
Expected: indented body preserved.
Actual: leading 4 spaces stripped (same shape of corruption as #139).
Why now
#139 already proved out the fix shape (split on triple-backtick fences, apply cleanup only to non-fenced segments). Porting the same approach over to
html-to-markdown.jsis a small, contained follow-up so the legacy path doesn't silently corrupt code that round-trips throughconfluenceClient.htmlToMarkdown().Source
lib/html-to-markdown.js— the cleanup chain around line 146StorageWalker.cleanup()post-Walker cleanup() strips leading whitespace inside fenced code blocks #139