Skip to content

Commit 71850ae

Browse files
[docs-infra] Crash on invalid callout type
1 parent ffddc91 commit 71850ae

File tree

2 files changed

+12
-39
lines changed

2 files changed

+12
-39
lines changed

docs/pages/experiments/docs/callouts.md

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,6 @@ It says, "You will fail if you don't heed this dire warning."
110110
:::
111111
```
112112

113-
## Empty
114-
115-
Should not be used, here just to ensure forgetting the token is not a big deal.
116-
117-
:::
118-
This is a callout.
119-
It says, "You will fail if you don't heed this dire warning."
120-
121-
- emphasised: **bold text**
122-
- some code `<div/>`
123-
- a [link](#link).
124-
125-
:::
126-
127-
```markup
128-
:::
129-
This is a callout.
130-
It says, "You will fail if you don't heed this dire warning."
131-
132-
- emphasised: **bold text**
133-
- some code `<div/>`
134-
- a [link](#link).
135-
:::
136-
```
137-
138113
## With code
139114

140115
:::info

packages/markdown/parseMarkdown.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -458,22 +458,20 @@ function createRender(context) {
458458
}
459459
return undefined;
460460
},
461-
462461
renderer(token) {
463-
return `<aside class="MuiCallout-root MuiCallout-${token.severity}">
464-
${
465-
['info', 'success', 'warning', 'error'].includes(token.severity)
466-
? [
467-
'<div class="MuiCallout-icon-container">',
468-
'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="ContentCopyRoundedIcon">',
469-
`<use class="MuiCode-copied-icon" xlink:href="#${token.severity}-icon" />`,
470-
'</svg>',
471-
'</div>',
472-
].join('\n')
473-
: ''
462+
if (!['info', 'success', 'warning', 'error'].includes(token.severity)) {
463+
throw new Error(`docs-infra: Callout :::${token.severity} is not supported`);
474464
}
475-
<div class="MuiCallout-content">
476-
${this.parser.parse(token.tokens)}\n</div></aside>`;
465+
466+
return `<aside class="MuiCallout-root MuiCallout-${token.severity}">${[
467+
'<div class="MuiCallout-icon-container">',
468+
'<svg focusable="false" aria-hidden="true" viewBox="0 0 24 24" data-testid="ContentCopyRoundedIcon">',
469+
`<use class="MuiCode-copied-icon" xlink:href="#${token.severity}-icon" />`,
470+
'</svg>',
471+
'</div>',
472+
].join(
473+
'\n',
474+
)}<div class="MuiCallout-content">${this.parser.parse(token.tokens)}</div></aside>`;
477475
},
478476
},
479477
],

0 commit comments

Comments
 (0)