mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-26 13:08:58 +02:00
fix: add v2 retrocompatible support for quoted admonitions (#9570)
This commit is contained in:
parent
2c0bf8a3d8
commit
7c32fc341f
3 changed files with 69 additions and 2 deletions
packages/docusaurus-utils/src
|
@ -97,14 +97,16 @@ export function admonitionTitleToDirectiveLabel(
|
|||
|
||||
const directiveNameGroup = `(${admonitionContainerDirectives.join('|')})`;
|
||||
const regexp = new RegExp(
|
||||
`^(?<indentation>( +|\t+))?(?<directive>:{3,}${directiveNameGroup}) +(?<title>.*)$`,
|
||||
`^(?<quote>(> ?)*)(?<indentation>( +|\t+))?(?<directive>:{3,}${directiveNameGroup}) +(?<title>.*)$`,
|
||||
'gm',
|
||||
);
|
||||
|
||||
return content.replaceAll(regexp, (substring, ...args: any[]) => {
|
||||
const groups = args.at(-1);
|
||||
|
||||
return `${groups.indentation ?? ''}${groups.directive}[${groups.title}]`;
|
||||
return `${groups.quote ?? ''}${groups.indentation ?? ''}${
|
||||
groups.directive
|
||||
}[${groups.title}]`;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue