1+ // Couple of ARIA attributes allowed in several, but not all, places.
2+ const aria = [ 'ariaDescribedBy' , 'ariaLabel' , 'ariaLabelledBy' ]
3+
14/**
25 * Default schema.
36 *
@@ -15,18 +18,53 @@ export const defaultSchema = {
1518 tr : [ 'table' ]
1619 } ,
1720 attributes : {
18- a : [ 'href' ] ,
21+ a : [
22+ ...aria ,
23+ // Note: these 3 are used by GFM footnotes, they do work on all links.
24+ 'dataFootnoteBackref' ,
25+ 'dataFootnoteRef' ,
26+ [ 'className' , 'data-footnote-backref' ] ,
27+ 'href'
28+ ] ,
1929 blockquote : [ 'cite' ] ,
30+ // Note: this class is not normally allowed by GH, when manually writing
31+ // `code` as HTML in markdown, they adds it some other way.
32+ // We can’t do that, so we have to allow it.
33+ code : [ [ 'className' , / ^ l a n g u a g e - ./ ] ] ,
2034 del : [ 'cite' ] ,
2135 div : [ 'itemScope' , 'itemType' ] ,
22- img : [ 'longDesc' , 'src' ] ,
36+ dl : [ ...aria ] ,
37+ // Note: these 2 are used by GFM footnotes, they *sometimes* work.
38+ h2 : [
39+ [ 'id' , 'footnote-label' ] ,
40+ [ 'className' , 'sr-only' ]
41+ ] ,
42+ img : [ ...aria , 'longDesc' , 'src' ] ,
43+ // Note: `input` is not normally allowed by GH, when manually writing
44+ // it in markdown, they add it from tasklists some other way.
45+ // We can’t do that, so we have to allow it.
2346 input : [
2447 [ 'disabled' , true ] ,
2548 [ 'type' , 'checkbox' ]
2649 ] ,
2750 ins : [ 'cite' ] ,
51+ // Note: this class is not normally allowed by GH, when manually writing
52+ // `li` as HTML in markdown, they adds it some other way.
53+ // We can’t do that, so we have to allow it.
2854 li : [ [ 'className' , 'task-list-item' ] ] ,
55+ // Note: this class is not normally allowed by GH, when manually writing
56+ // `ol` as HTML in markdown, they adds it some other way.
57+ // We can’t do that, so we have to allow it.
58+ ol : [ ...aria , [ 'className' , 'contains-task-list' ] ] ,
2959 q : [ 'cite' ] ,
60+ section : [ 'dataFootnotes' , [ 'className' , 'footnotes' ] ] ,
61+ source : [ 'srcSet' ] ,
62+ summary : [ ...aria ] ,
63+ table : [ ...aria ] ,
64+ // Note: this class is not normally allowed by GH, when manually writing
65+ // `ol` as HTML in markdown, they adds it some other way.
66+ // We can’t do that, so we have to allow it.
67+ ul : [ ...aria , [ 'className' , 'contains-task-list' ] ] ,
3068 '*' : [
3169 'abbr' ,
3270 'accept' ,
@@ -35,10 +73,6 @@ export const defaultSchema = {
3573 'action' ,
3674 'align' ,
3775 'alt' ,
38- 'ariaDescribedBy' ,
39- 'ariaHidden' ,
40- 'ariaLabel' ,
41- 'ariaLabelledBy' ,
4276 'axis' ,
4377 'border' ,
4478 'cellPadding' ,
@@ -94,16 +128,14 @@ export const defaultSchema = {
94128 'tabIndex' ,
95129 'target' ,
96130 'title' ,
97- 'type' ,
98131 'useMap' ,
99132 'vAlign' ,
100- 'vSpace' ,
101133 'value' ,
102134 'width'
103135 ]
104136 } ,
105137 clobberPrefix : 'user-content-' ,
106- clobber : [ 'id' , 'name' ] ,
138+ clobber : [ 'ariaDescribedBy' , 'ariaLabelledBy' , ' id', 'name' ] ,
107139 protocols : {
108140 href : [ 'http' , 'https' , 'irc' , 'ircs' , 'mailto' , 'xmpp' ] ,
109141 cite : [ 'http' , 'https' ] ,
@@ -116,24 +148,17 @@ export const defaultSchema = {
116148 strip : [ 'script' ] ,
117149 tagNames : [
118150 'a' ,
119- 'abbr' ,
120151 'b' ,
121- 'bdo' ,
122152 'blockquote' ,
123153 'br' ,
124- 'caption' ,
125- 'cite' ,
126154 'code' ,
127155 'dd' ,
128156 'del' ,
129157 'details' ,
130- 'dfn' ,
131158 'div' ,
132159 'dl' ,
133160 'dt' ,
134161 'em' ,
135- 'figcaption' ,
136- 'figure' ,
137162 'h1' ,
138163 'h2' ,
139164 'h3' ,
@@ -143,21 +168,25 @@ export const defaultSchema = {
143168 'hr' ,
144169 'i' ,
145170 'img' ,
171+ // Note: `input` is not normally allowed by GH, when manually writing
172+ // it in markdown, they add it from tasklists some other way.
173+ // We can’t do that, so we have to allow it.
146174 'input' ,
147175 'ins' ,
148176 'kbd' ,
149177 'li' ,
150- 'mark' ,
151178 'ol' ,
152179 'p' ,
180+ 'picture' ,
153181 'pre' ,
154182 'q' ,
155183 'rp' ,
156184 'rt' ,
157185 'ruby' ,
158186 's' ,
159187 'samp' ,
160- 'small' ,
188+ 'section' ,
189+ 'source' ,
161190 'span' ,
162191 'strike' ,
163192 'strong' ,
@@ -170,11 +199,9 @@ export const defaultSchema = {
170199 'tfoot' ,
171200 'th' ,
172201 'thead' ,
173- 'time' ,
174202 'tr' ,
175203 'tt' ,
176204 'ul' ,
177- 'var' ,
178- 'wbr'
205+ 'var'
179206 ]
180207}
0 commit comments