Skip to content

Commit ef0c9ef

Browse files
committed
Add section on extending default schema
Related to remarkjs/remark-react#23.
1 parent 3bcbe29 commit ef0c9ef

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

readme.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,20 @@ Sanitize the given [HAST][] tree.
9191
### `Schema`
9292

9393
Configuration. If not given, defaults to [GitHub][] style sanitation.
94-
If any key isn’t given, it defaults to GH’s style too.
94+
If any top-level key isn’t given, it defaults to GH’s style too.
9595

9696
For a thorough sample, see the packages [`github.json`][schema-github].
9797

98+
To extend the the standard schema with a few changes, clone `github.json`
99+
like so:
100+
101+
```js
102+
var clone = require('clone');
103+
var base = require('hast-util-sanitize/lib/github.json');
104+
var schema = clone(base);
105+
schema.attributes['*'].push('className');
106+
```
107+
98108
###### `attributes`
99109

100110
Map of tag-names to allowed attributes (`Object.<Array.<string>>`).

0 commit comments

Comments
 (0)