kopia lustrzana https://github.com/learn-awesome/learndb
trying another way to simplify
rodzic
e6b9cfc6dd
commit
5145b0fe3e
|
@ -25,13 +25,19 @@ function simplifyContent(content) {
|
|||
simplifiedContent = simplifiedContent.replace(/<style.*?>.*?<\/style>/gms, '');
|
||||
// Remove all remaining HTML tags, leaving the inner text
|
||||
simplifiedContent = simplifiedContent.replace(/<[^>]+>/g, '');
|
||||
// Decode HTML entities - for a Node.js environment, consider using a library like 'he'
|
||||
simplifiedContent = simplifiedContent.replace(/&[a-z]+;/gi, match => {
|
||||
// This part is for browser environments, adjust for Node.js if necessary
|
||||
const span = document.createElement('span');
|
||||
span.innerHTML = match;
|
||||
return span.textContent || span.innerText;
|
||||
});
|
||||
// // Decode HTML entities - for a Node.js environment, consider using a library like 'he'
|
||||
// simplifiedContent = simplifiedContent.replace(/&[a-z]+;/gi, match => {
|
||||
// // This part is for browser environments, adjust for Node.js if necessary
|
||||
// const span = document.createElement('span');
|
||||
// span.innerHTML = match;
|
||||
// return span.textContent || span.innerText;
|
||||
// });
|
||||
simplifiedContent = simplifiedContent
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'");
|
||||
// Remove inline CSS and JavaScript event handlers
|
||||
simplifiedContent = simplifiedContent.replace(/style\s*=\s*'.*?'/gi, '');
|
||||
simplifiedContent = simplifiedContent.replace(/on\w+\s*=\s*".*?"/gi, '');
|
||||
|
|
Ładowanie…
Reference in New Issue