fix: add v2 retrocompatible support for quoted admonitions ()

This commit is contained in:
Sébastien Lorber 2023-11-21 20:49:34 +01:00 committed by GitHub
parent 2c0bf8a3d8
commit 7c32fc341f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 2 deletions
packages/docusaurus-utils/src

View file

@ -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}]`;
});
}