mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-22 12:37:58 +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
|
@ -97,14 +97,14 @@ export function admonitionTitleToDirectiveLabel(
|
|||
|
||||
const directiveNameGroup = `(${admonitionContainerDirectives.join('|')})`;
|
||||
const regexp = new RegExp(
|
||||
`^(?<directive>:{3,}${directiveNameGroup}) +(?<title>.*)$`,
|
||||
`^(?<indentation>( +|\t+))?(?<directive>:{3,}${directiveNameGroup}) +(?<title>.*)$`,
|
||||
'gm',
|
||||
);
|
||||
|
||||
return content.replaceAll(regexp, (substring, ...args: any[]) => {
|
||||
const groups = args.at(-1);
|
||||
|
||||
return `${groups.directive}[${groups.title}]`;
|
||||
return `${groups.indentation ?? ''}${groups.directive}[${groups.title}]`;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue