Skip to content

Commit

Permalink
fix(app): Add comments to Markdown component.
Browse files Browse the repository at this point in the history
  • Loading branch information
nellh committed Jan 24, 2024
1 parent 7d253bd commit 69b87d2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/openneuro-app/src/scripts/utils/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ interface MarkdownProps {
children: string
}

// Closely aligned with GitHub Markdown
// See https://github.com/gjtorikian/html-pipeline/blob/7e562219f9814777b73b48f32aece874452c0c5e/lib/html_pipeline/sanitization_filter.rb

const ALLOWED_TAGS = [
"h1",
"h2",
Expand Down Expand Up @@ -147,6 +150,9 @@ const ALLOWED_ATTR = [
"longdesc",
]

/**
* Sanitize disallowed HTML tags and attributes and convert from Markdown to JSX
*/
export function Markdown({ children }: MarkdownProps) {
const sanitizedMarkdown = DOMPurify.sanitize(children, {
ALLOWED_TAGS,
Expand Down

0 comments on commit 69b87d2

Please sign in to comment.