diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index 9b2318ab0..48ee42a6c 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -889,13 +889,19 @@ export const removeDetails = (content, types) => { ); } return segment; - }); + }).trim(); }; export const removeAllDetails = (content) => { + // First pass: strip
blocks on the full string before code-fence + // splitting, so blocks whose body contains triple backticks are caught. + // (replaceOutsideCode splits on ``` fences, which breaks the
+ // regex when the opening and closing tags land in different segments.) + content = content.replace(/]*>[\s\S]*?<\/details>/gi, ''); + // Second pass: catch any remaining blocks that live outside code fences return replaceOutsideCode(content, (segment) => { return segment.replace(/]*>.*?<\/details>/gis, ''); - }); + }).trim(); }; export const processDetails = (content) => {