feat: support all HTML elements allowed by Glitch (#1233)

Closes https://github.com/elk-zone/elk/issues/1230
This commit is contained in:
jviide 2023-01-16 20:04:27 +02:00 committed by GitHub
parent 9df47ea6c2
commit 8c170961cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 6 deletions

View file

@ -35,12 +35,35 @@ const sanitizer = sanitize({
code: { code: {
class: filterClasses(/^language-\w+$/), class: filterClasses(/^language-\w+$/),
}, },
// other elements supported in glitch // Other elements supported in glitch, as seen in
h1: {}, // https://github.com/glitch-soc/mastodon/blob/13227e1dafd308dfe1a3effc3379b766274809b3/lib/sanitize_ext/sanitize_config.rb#L75
ol: {}, abbr: {
ul: {}, title: keep,
li: {}, },
del: {},
blockquote: {
cite: filterHref(),
},
b: {},
strong: {},
u: {},
sub: {},
sup: {},
i: {},
em: {}, em: {},
h1: {},
h2: {},
h3: {},
h4: {},
h5: {},
ul: {},
ol: {
start: keep,
reversed: keep,
},
li: {
value: keep,
},
}) })
/** /**
@ -255,6 +278,10 @@ function filterClasses(allowed: RegExp) {
} }
} }
function keep(value: string | undefined) {
return value
}
function set(value: string) { function set(value: string) {
return () => value return () => value
} }

View file

@ -92,7 +92,7 @@ exports[`content-rich > handles formatting from servers 1`] = `
<p></p> <p></p>
<ul> <ul>
<li>This is an indented bulleted list (not just asterisks).</li> <li>This is an indented bulleted list (not just asterisks).</li>
<li></li> <li><strong>This line is bold.</strong></li>
<li><em>This line is italic.</em></li> <li><em>This line is italic.</em></li>
</ul> </ul>
<ol> <ol>