The markdown content negotiation edge function mangles every fenced code block and table it touches.
Repro
curl -H 'Accept: text/markdown' https://project-hami.io/docs/get-started/deploy-with-helm
The Pod manifest comes back as:
apiVersion : v1
kind : Pod
metadata :
name : gpu - pod
spec :
containers :
- name : ubuntu - container
image : ubuntu : 22.04
Indentation is gone and every token is space-separated, so it no longer parses as YAML. Tables flatten the same way, /docs/userguide/device-supported comes back as one long line.
Cause is in netlify/edge-functions/markdown-negotiation.js: htmlToMarkdown() has no case for <pre>, <code> or <table>, so they hit the catch-all .replace(/<[^>]+>/g, " ") on L64. Prism puts each token in its own span, so that inserts a space between all of them, and L66 collapses what's left of the indentation.
Only affects clients that send Accept: text/markdown, so nothing looks broken in a browser. It's a 200 with silently wrong content though, which seems worse than not supporting the header at all.
Simplest fix is probably serving the source .md instead of converting the HTML. Happy to open a PR !
The markdown content negotiation edge function mangles every fenced code block and table it touches.
Repro
curl -H 'Accept: text/markdown' https://project-hami.io/docs/get-started/deploy-with-helmThe Pod manifest comes back as:
Indentation is gone and every token is space-separated, so it no longer parses as YAML. Tables flatten the same way,
/docs/userguide/device-supportedcomes back as one long line.Cause is in
netlify/edge-functions/markdown-negotiation.js:htmlToMarkdown()has no case for<pre>,<code>or<table>, so they hit the catch-all.replace(/<[^>]+>/g, " ")on L64. Prism puts each token in its own span, so that inserts a space between all of them, and L66 collapses what's left of the indentation.Only affects clients that send
Accept: text/markdown, so nothing looks broken in a browser. It's a 200 with silently wrong content though, which seems worse than not supporting the header at all.Simplest fix is probably serving the source
.mdinstead of converting the HTML. Happy to open a PR !