@salesforcedevs/docs-components 1.14.8-alpha100 → 1.14.8-alpha101
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
|
@@ -6,7 +6,7 @@ import Button from "dx/button";
|
|
|
6
6
|
import { highlightTerms } from "dxUtils/highlight";
|
|
7
7
|
import ContentCallout from "doc/contentCallout";
|
|
8
8
|
import ContentMedia from "doc/contentMedia";
|
|
9
|
-
import { normalizeHtmlEntities } from "docUtils/
|
|
9
|
+
import { normalizeHtmlEntities } from "docUtils/utils";
|
|
10
10
|
|
|
11
11
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
12
12
|
"p",
|
|
@@ -30,3 +30,23 @@ export function logCoveoPageView(
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
export function normalizeHtmlEntities(str: string): string {
|
|
35
|
+
if (typeof str !== 'string') {
|
|
36
|
+
return str;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// First decode any double-encoded entities
|
|
40
|
+
const tempDiv = document.createElement('div');
|
|
41
|
+
tempDiv.innerHTML = str;
|
|
42
|
+
const decoded = tempDiv.textContent || tempDiv.innerText;
|
|
43
|
+
|
|
44
|
+
// Then properly encode special characters
|
|
45
|
+
return decoded
|
|
46
|
+
.replace(/&/g, '&')
|
|
47
|
+
.replace(/</g, '<')
|
|
48
|
+
.replace(/>/g, '>')
|
|
49
|
+
.replace(/"/g, '"')
|
|
50
|
+
.replace(/'/g, ''')
|
|
51
|
+
.replace(/\u00A0/g, ' '); // Handle non-breaking space
|
|
52
|
+
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalizes HTML entities in a string by first decoding any double-encoded entities
|
|
3
|
-
* and then properly encoding special characters
|
|
4
|
-
* @param str The string to normalize
|
|
5
|
-
* @returns The normalized string with properly encoded HTML entities
|
|
6
|
-
*/
|
|
7
|
-
export const normalizeHtmlEntities = (str: string): string => {
|
|
8
|
-
if (typeof str !== 'string') {
|
|
9
|
-
return str;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// First decode any double-encoded entities
|
|
13
|
-
const tempDiv = document.createElement('div');
|
|
14
|
-
tempDiv.innerHTML = str;
|
|
15
|
-
const decoded = tempDiv.textContent || tempDiv.innerText;
|
|
16
|
-
|
|
17
|
-
// Then properly encode special characters
|
|
18
|
-
return decoded
|
|
19
|
-
.replace(/&/g, '&')
|
|
20
|
-
.replace(/</g, '<')
|
|
21
|
-
.replace(/>/g, '>')
|
|
22
|
-
.replace(/"/g, '"')
|
|
23
|
-
.replace(/'/g, ''')
|
|
24
|
-
.replace(/\u00A0/g, ' '); // Handle non-breaking space
|
|
25
|
-
};
|