Skip to content

Commit 3af66f8

Browse files
authored
feat: extend supported tags for html (#209)
1 parent e1a4cee commit 3af66f8

1 file changed

Lines changed: 55 additions & 6 deletions

File tree

packages/components/src/utils/sanitizeHtml.ts

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,70 @@ import sanitize from 'sanitize-html';
33
const sanitazeHtml = (html: string): string => {
44
return sanitize(unescape(html), {
55
allowedTags: [
6-
'br',
6+
// Content sectioning
77
'h1',
88
'h2',
99
'h3',
1010
'h4',
1111
'h5',
1212
'h6',
13-
'bold',
14-
'italic',
13+
14+
// Text content
15+
'blockquote',
16+
'dd',
17+
'dl',
18+
'dt',
19+
'figcaption',
20+
'figure',
21+
'hr',
22+
'li',
1523
'ol',
24+
'p',
25+
'pre',
1626
'ul',
17-
'li',
18-
'hr',
27+
28+
// Inline text semantics
1929
'a',
20-
'p',
30+
'abbr',
31+
'b',
32+
'bdi',
33+
'bdo',
34+
'br',
35+
'cite',
36+
'code',
37+
'data',
38+
'dfn',
39+
'em',
40+
'i',
41+
'kdb',
42+
'mark',
43+
'q',
44+
'rp',
45+
'rt',
46+
'ruby',
47+
's',
48+
'samp',
49+
'small',
50+
'span',
51+
'strong',
52+
'sub',
53+
'sup',
54+
'time',
55+
'u',
56+
'var',
57+
'wbr',
58+
59+
// Image and multimedia
60+
'area',
61+
'audio',
62+
'img',
63+
'map',
64+
'track',
65+
'video',
66+
67+
// SVG and MathML
68+
'svg',
69+
'math',
2170
],
2271
allowedAttributes: {
2372
a: ['href'],

0 commit comments

Comments
 (0)