Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add_support_for_description_lists.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

# Add support for description lists
3 changes: 3 additions & 0 deletions src/app/plugins/markdown/allowedHtmlTags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export const MARKDOWN_ALLOWED_HTML_TAGS = new Set([
'blockquote',
'br',
'code',
'dd',
'del',
'details',
'div',
'dl',
'dt',
'em',
'h1',
'h2',
Expand Down
22 changes: 22 additions & 0 deletions src/app/plugins/react-custom-html-parser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,28 @@ export const getReactCustomHtmlParser = (
);
}

if (name === 'dl') {
return (
<dl {...props} className={css.DescriptionList}>
{renderChildren()}
</dl>
);
}
if (name === 'dt') {
return (
<dt {...props} className={css.DescriptionTerm}>
{renderChildren()}
</dt>
);
}
if (name === 'dd') {
return (
<dd {...props} className={css.DescriptionDetails}>
{renderChildren()}
</dd>
);
}

if (name === 'code') {
if (parent && 'name' in parent && parent.name === 'pre') {
const codeContent = renderChildren();
Expand Down
22 changes: 22 additions & 0 deletions src/app/styles/CustomHtml.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,3 +338,25 @@ export const Td = style([
minWidth: toRem(100),
},
]);

export const DescriptionList = style([
DefaultReset,
{
display: 'flex',
flexDirection: 'column',
},
]);

export const DescriptionTerm = style([
DefaultReset,
{
fontWeight: 'bolder',
},
]);

export const DescriptionDetails = style([
DefaultReset,
{
marginInlineStart: config.space.S700,
},
]);
3 changes: 3 additions & 0 deletions src/app/utils/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const permittedHtmlTags = [
'img',
'details',
'summary',
'dl',
'dt',
'dd',
] as const;

const permittedTagToAttributes = {
Expand Down
Loading