mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-07 05:12:31 +02:00
fix: v3 admonitions should support v2 title syntax for nested admonitions (#9535)
Fix admonition title mdx v1 compat option when admonition is nested
This commit is contained in:
parent
95d3a65e74
commit
b464545629
3 changed files with 82 additions and 9 deletions
|
@ -1288,17 +1288,23 @@ describe('admonitionTitleToDirectiveLabel', () => {
|
|||
`);
|
||||
});
|
||||
|
||||
it('does not transform left-padded directives', () => {
|
||||
it('transforms space indented directives', () => {
|
||||
expect(
|
||||
admonitionTitleToDirectiveLabel(
|
||||
dedent`
|
||||
before
|
||||
|
||||
:::note Title
|
||||
:::note 1 space
|
||||
|
||||
content
|
||||
content
|
||||
|
||||
:::
|
||||
:::
|
||||
|
||||
:::note 2 spaces
|
||||
|
||||
content
|
||||
|
||||
:::
|
||||
|
||||
after
|
||||
`,
|
||||
|
@ -1307,16 +1313,63 @@ describe('admonitionTitleToDirectiveLabel', () => {
|
|||
).toEqual(dedent`
|
||||
before
|
||||
|
||||
:::note Title
|
||||
:::note[1 space]
|
||||
|
||||
content
|
||||
content
|
||||
|
||||
:::
|
||||
:::
|
||||
|
||||
:::note[2 spaces]
|
||||
|
||||
content
|
||||
|
||||
:::
|
||||
|
||||
after
|
||||
`);
|
||||
});
|
||||
|
||||
it('transforms tab indented directives', () => {
|
||||
expect(
|
||||
admonitionTitleToDirectiveLabel(
|
||||
`
|
||||
before
|
||||
|
||||
\t:::note 1 tab
|
||||
|
||||
\tcontent
|
||||
|
||||
\t:::
|
||||
|
||||
\t\t:::note 2 tabs
|
||||
|
||||
\t\tcontent
|
||||
|
||||
\t\t:::
|
||||
|
||||
after
|
||||
`,
|
||||
directives,
|
||||
),
|
||||
).toBe(`
|
||||
before
|
||||
|
||||
\t:::note[1 tab]
|
||||
|
||||
\tcontent
|
||||
|
||||
\t:::
|
||||
|
||||
\t\t:::note[2 tabs]
|
||||
|
||||
\t\tcontent
|
||||
|
||||
\t\t:::
|
||||
|
||||
after
|
||||
`);
|
||||
});
|
||||
|
||||
it('does not transform admonition without title', () => {
|
||||
expect(
|
||||
admonitionTitleToDirectiveLabel(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue