forked from readmeio/markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanitize.schema.js
43 lines (33 loc) · 970 Bytes
/
sanitize.schema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { defaultSchema } = require('hast-util-sanitize/lib/schema');
const createSchema = ({ safeMode } = {}) => {
const schema = JSON.parse(JSON.stringify(defaultSchema));
// Sanitization Schema Defaults
schema.clobberPrefix = '';
schema.tagNames.push('span');
schema.attributes['*'].push('class', 'className', 'align');
if (!safeMode) {
schema.attributes['*'].push('style');
}
schema.tagNames.push('rdme-pin');
schema.tagNames.push('rdme-embed');
schema.attributes['rdme-embed'] = [
'url',
'provider',
'html',
'title',
'href',
'iframe',
'width',
'height',
'image',
'favicon',
'align',
];
schema.attributes.a = ['href', 'title', 'class', 'className', 'download'];
schema.tagNames.push('figure');
schema.tagNames.push('figcaption');
schema.tagNames.push('input'); // allow GitHub-style todo lists
schema.ancestors.input = ['li'];
return schema;
};
module.exports = createSchema;