doxla 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@ interface IndexPageProps {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function getPreview(content: string): string {
|
|
17
|
-
// Strip the first heading and get the first non-empty paragraph
|
|
17
|
+
// Strip the first heading and get the first non-empty text paragraph
|
|
18
18
|
const lines = content.split("\n");
|
|
19
19
|
let foundHeading = false;
|
|
20
20
|
const previewLines: string[] = [];
|
|
@@ -29,7 +29,14 @@ function getPreview(content: string): string {
|
|
|
29
29
|
if (previewLines.length > 0) break;
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// Strip HTML tags in a loop to handle nested/malformed markup
|
|
33
|
+
let textOnly = trimmed;
|
|
34
|
+
while (/<[^>]+>/.test(textOnly)) {
|
|
35
|
+
textOnly = textOnly.replace(/<[^>]+>/g, "");
|
|
36
|
+
}
|
|
37
|
+
textOnly = textOnly.replace(/[<>]/g, "").trim();
|
|
38
|
+
if (textOnly === "") continue;
|
|
39
|
+
previewLines.push(textOnly);
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
const preview = previewLines.join(" ");
|