retypeset-odyssey 0.1.3 → 0.1.4
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 +1 -1
- package/src/utils/description.ts +12 -3
package/package.json
CHANGED
package/src/utils/description.ts
CHANGED
|
@@ -34,10 +34,19 @@ const htmlEntityMap: Record<string, string> = {
|
|
|
34
34
|
' ': ' ',
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// Cleans text by removing HTML tags and normalizing whitespace
|
|
37
|
+
// Cleans text by removing HTML tags and normalizing whitespace.
|
|
38
|
+
// Before stripping tags, inserts a middle-dot separator between adjacent
|
|
39
|
+
// list items so excerpts of pre-`<!-- more -->` lists still read as a list
|
|
40
|
+
// once flattened to a single paragraph. Without this, `<li>A</li><li>B</li>`
|
|
41
|
+
// flattens to whitespace-joined `A B` and the excerpt loses its structure.
|
|
38
42
|
function cleanTextContent(text: string): string {
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
let cleanText = text
|
|
44
|
+
// Adjacent list items → middle-dot separator
|
|
45
|
+
.replace(/<\/li>\s*<li[^>]*>/gi, '</li> · <li>')
|
|
46
|
+
// <br /> behaves like a space
|
|
47
|
+
.replace(/<br\s*\/?>/gi, ' ')
|
|
48
|
+
// Remove HTML tags
|
|
49
|
+
.replace(/<[^>]*>/g, '')
|
|
41
50
|
|
|
42
51
|
// Decode HTML entities
|
|
43
52
|
Object.entries(htmlEntityMap).forEach(([entity, char]) => {
|