@stackql/provider-utils 0.4.3 → 0.4.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/docgen/helpers.js +29 -3
package/package.json
CHANGED
package/src/docgen/helpers.js
CHANGED
|
@@ -23,18 +23,44 @@ export function getIndefiniteArticle(resourceName) {
|
|
|
23
23
|
return article;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Sanitizes HTML with special handling for allowed tags and backticked content
|
|
28
|
+
* @param {string} text - The text to sanitize
|
|
29
|
+
* @return {string} - The sanitized text
|
|
30
|
+
*/
|
|
26
31
|
export function sanitizeHtml(text) {
|
|
27
|
-
return
|
|
32
|
+
if (!text) return '';
|
|
33
|
+
|
|
34
|
+
// First apply the general sanitization
|
|
35
|
+
let result = text
|
|
28
36
|
.replace(/{/g, '{')
|
|
29
37
|
.replace(/}/g, '}')
|
|
30
38
|
.replace(/>/g, '>')
|
|
31
39
|
.replace(/</g, '<')
|
|
32
40
|
// edge case
|
|
33
41
|
.replace(/}_{/g, '}_{')
|
|
34
|
-
.replace(/\n/g, '<br />')
|
|
42
|
+
.replace(/\n/g, '<br />');
|
|
43
|
+
|
|
44
|
+
// Fix 1: Replace <br>, <br/>, <p>, </p> back to their literal HTML tags
|
|
45
|
+
// Make sure <br> is always self-closing for MDX compatibility
|
|
46
|
+
result = result
|
|
47
|
+
.replace(/<br\s*\/?>/gi, '<br />')
|
|
48
|
+
.replace(/<p>/gi, '<p>')
|
|
49
|
+
.replace(/<\/p>/gi, '</p>');
|
|
50
|
+
|
|
51
|
+
// Fix 2: Find any < or > inside backticks and convert them back to < and >
|
|
52
|
+
// We need to handle the backtick content by finding pairs of backticks
|
|
53
|
+
result = result.replace(/`([^`]*)`/g, (match, content) => {
|
|
54
|
+
// Convert < and > back to < and > only within backticked content
|
|
55
|
+
const fixedContent = content
|
|
56
|
+
.replace(/</g, '<')
|
|
57
|
+
.replace(/>/g, '>');
|
|
58
|
+
return '`' + fixedContent + '`';
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return result;
|
|
35
62
|
}
|
|
36
63
|
|
|
37
|
-
|
|
38
64
|
export function getSqlMethodsWithOrderedFields(resourceData, dereferencedAPI, sqlVerb) {
|
|
39
65
|
const methods = {};
|
|
40
66
|
|