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, '');
|
simplifiedContent = simplifiedContent.replace(/<style.*?>.*?<\/style>/gms, '');
|
||||||
// Remove all remaining HTML tags, leaving the inner text
|
// Remove all remaining HTML tags, leaving the inner text
|
||||||
simplifiedContent = simplifiedContent.replace(/<[^>]+>/g, '');
|
simplifiedContent = simplifiedContent.replace(/<[^>]+>/g, '');
|
||||||
// Decode HTML entities - for a Node.js environment, consider using a library like 'he'
|
// // Decode HTML entities - for a Node.js environment, consider using a library like 'he'
|
||||||
simplifiedContent = simplifiedContent.replace(/&[a-z]+;/gi, match => {
|
// simplifiedContent = simplifiedContent.replace(/&[a-z]+;/gi, match => {
|
||||||
// This part is for browser environments, adjust for Node.js if necessary
|
// // This part is for browser environments, adjust for Node.js if necessary
|
||||||
const span = document.createElement('span');
|
// const span = document.createElement('span');
|
||||||
span.innerHTML = match;
|
// span.innerHTML = match;
|
||||||
return span.textContent || span.innerText;
|
// return span.textContent || span.innerText;
|
||||||
});
|
// });
|
||||||
|
simplifiedContent = simplifiedContent
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, "'");
|
||||||
// Remove inline CSS and JavaScript event handlers
|
// Remove inline CSS and JavaScript event handlers
|
||||||
simplifiedContent = simplifiedContent.replace(/style\s*=\s*'.*?'/gi, '');
|
simplifiedContent = simplifiedContent.replace(/style\s*=\s*'.*?'/gi, '');
|
||||||
simplifiedContent = simplifiedContent.replace(/on\w+\s*=\s*".*?"/gi, '');
|
simplifiedContent = simplifiedContent.replace(/on\w+\s*=\s*".*?"/gi, '');
|
||||||
|
|
Ładowanie…
Reference in New Issue