refac
This commit is contained in:
@@ -889,13 +889,19 @@ export const removeDetails = (content, types) => {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
return segment;
|
return segment;
|
||||||
});
|
}).trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const removeAllDetails = (content) => {
|
export const removeAllDetails = (content) => {
|
||||||
|
// First pass: strip <details> 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 <details>
|
||||||
|
// regex when the opening and closing tags land in different segments.)
|
||||||
|
content = content.replace(/<details[^>]*>[\s\S]*?<\/details>/gi, '');
|
||||||
|
// Second pass: catch any remaining blocks that live outside code fences
|
||||||
return replaceOutsideCode(content, (segment) => {
|
return replaceOutsideCode(content, (segment) => {
|
||||||
return segment.replace(/<details[^>]*>.*?<\/details>/gis, '');
|
return segment.replace(/<details[^>]*>.*?<\/details>/gis, '');
|
||||||
});
|
}).trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
export const processDetails = (content) => {
|
export const processDetails = (content) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user