mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-13 21:02:08 +08:00
* fix(api): decouple api from curriculum This reverts commit8f0e441644and introduces the implementations from #40703. * fix(gitpod): add curriculum build to GitPod This reverts commit706d70f58dand introduces implementations from #41234. * docs: update DevOps manual for api change (#41259) Co-authored-by: Oliver Eyton-Williams <[email protected]>
31 lines
717 B
JavaScript
31 lines
717 B
JavaScript
// Refer : http://stackoverflow.com/a/430240/1932901
|
|
function trimTags(value) {
|
|
const tagBody = '(?:[^"\'>]|"[^"]*"|\'[^\']*\')*';
|
|
const tagOrComment = new RegExp(
|
|
'<(?:' +
|
|
// Comment body.
|
|
'!--(?:(?:-*[^->])*--+|-?)' +
|
|
// Special "raw text" elements whose content should be elided.
|
|
'|script\\b' +
|
|
tagBody +
|
|
'>[\\s\\S]*?</script\\s*' +
|
|
'|style\\b' +
|
|
tagBody +
|
|
'>[\\s\\S]*?</style\\s*' +
|
|
// Regular name
|
|
'|/?[a-z]' +
|
|
tagBody +
|
|
')>',
|
|
'gi'
|
|
);
|
|
let rawValue;
|
|
do {
|
|
rawValue = value;
|
|
value = value.replace(tagOrComment, '');
|
|
} while (value !== rawValue);
|
|
|
|
return value.replace(/</g, '<');
|
|
}
|
|
|
|
export { trimTags };
|