Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs-infra] Crash on invalid callout type #43546

Merged
merged 1 commit into from
Sep 2, 2024
Merged
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
25 changes: 0 additions & 25 deletions docs/pages/experiments/docs/callouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,31 +110,6 @@ It says, "You will fail if you don't heed this dire warning."
:::
```

## Empty

Should not be used, here just to ensure forgetting the token is not a big deal.

:::
This is a callout.
It says, "You will fail if you don't heed this dire warning."

- emphasised: **bold text**
- some code `<div/>`
- a [link](#link).

:::

```markup
:::
This is a callout.
It says, "You will fail if you don't heed this dire warning."

- emphasised: **bold text**
- some code `<div/>`
- a [link](#link).
:::
```

## With code

:::info
Expand Down
26 changes: 12 additions & 14 deletions packages/markdown/parseMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,22 +458,20 @@ function createRender(context) {
}
return undefined;
},

renderer(token) {
return `<aside class="MuiCallout-root MuiCallout-${token.severity}">
${
['info', 'success', 'warning', 'error'].includes(token.severity)
? [
'<div class="MuiCallout-icon-container">',
'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="ContentCopyRoundedIcon">',
`<use class="MuiCode-copied-icon" xlink:href="#${token.severity}-icon" />`,
'</svg>',
'</div>',
].join('\n')
: ''
if (!['info', 'success', 'warning', 'error'].includes(token.severity)) {
throw new Error(`docs-infra: Callout :::${token.severity} is not supported`);
}
<div class="MuiCallout-content">
${this.parser.parse(token.tokens)}\n</div></aside>`;

return `<aside class="MuiCallout-root MuiCallout-${token.severity}">${[
'<div class="MuiCallout-icon-container">',
'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="ContentCopyRoundedIcon">',
`<use class="MuiCode-copied-icon" xlink:href="#${token.severity}-icon" />`,
'</svg>',
'</div>',
].join(
'\n',
)}<div class="MuiCallout-content">${this.parser.parse(token.tokens)}</div></aside>`;
},
},
],
Expand Down