Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e9d3584f3
|
No files matched your search
@@ -6,6 +6,9 @@ on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -36,14 +36,21 @@ function extractFullText(htmlPath) {
|
||||
const html = fs.readFileSync(htmlPath, "utf-8");
|
||||
|
||||
// Strip HTML tags, decode entities, normalize whitespace
|
||||
return html
|
||||
.replace(/<script[\s\S]*?<\/script>/gi, "")
|
||||
.replace(/<style[\s\S]*?<\/style>/gi, "")
|
||||
.replace(/<[^>]+>/g, " ")
|
||||
// Repeat each removal until stable so nested or split tags cannot survive,
|
||||
// and decode & last so encoded entities are not double-decoded.
|
||||
let text = html;
|
||||
for (let previous = null; previous !== text;) {
|
||||
previous = text;
|
||||
text = text
|
||||
.replace(/<script\b[\s\S]*?<\/script\b[^>]*>/gi, "")
|
||||
.replace(/<style\b[\s\S]*?<\/style\b[^>]*>/gi, "")
|
||||
.replace(/<[^>]+>/g, " ");
|
||||
}
|
||||
return text
|
||||
.replace(/ /g, " ")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user