diff --git a/scripts/sync-general-content.sh b/scripts/sync-general-content.sh
index 715817f..622c3a2 100755
--- a/scripts/sync-general-content.sh
+++ b/scripts/sync-general-content.sh
@@ -125,12 +125,14 @@ fi
rm -rf "$ROOT_DIR/content/docs/figures"
rm -rf "$ROOT_DIR/content/docs/specification/figures"
-# Fix invalid 'https' language in code blocks
-if [[ "$OSTYPE" == "darwin"* ]]; then
- find "$ROOT_DIR/content/docs" -type f -name "*.md" -exec sed -i '' 's/
//g' {} +
-else
- find "$ROOT_DIR/content/docs" -type f -name "*.md" -exec sed -i 's/
//g' {} +
-fi
+# Self-close
inside fenced code so mermaid keeps its line breaks; strip it
+# elsewhere. A bare
in a heading crashes fumadocs' rehypeToc.
+find "$ROOT_DIR/content/docs" -type f -name "*.md" -print0 | while IFS= read -r -d '' f; do
+ awk '
+ /^[[:space:]]*```/ { fence = !fence }
+ { if (fence) gsub(/
/, "
"); else gsub(/
/, ""); print }
+ ' "$f" > "$f.tmp" && mv "$f.tmp" "$f"
+done
echo "Generating SwaggerUI MDX files..."
rm -f "$ROOT_DIR/content/docs/specification/margo-management-interface/management-interface-swagger.md"