mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-04 12:47:14 +02:00
refactor(v2): improve regex matching code-block title (#3685)
This commit is contained in:
parent
7c7e0c24f6
commit
f8a6b391cd
1 changed files with 2 additions and 4 deletions
|
@ -84,7 +84,7 @@ const highlightDirectiveRegex = (lang) => {
|
|||
return getHighlightDirectiveRegex();
|
||||
}
|
||||
};
|
||||
const codeBlockTitleRegex = /title=".*"/;
|
||||
const codeBlockTitleRegex = /(?:title=")(.*)(?:")/;
|
||||
|
||||
export default ({
|
||||
children,
|
||||
|
@ -125,9 +125,7 @@ export default ({
|
|||
// Tested above
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
codeBlockTitle = metastring
|
||||
.match(codeBlockTitleRegex)![0]
|
||||
.split('title=')[1]
|
||||
.replace(/"+/g, '');
|
||||
.match(codeBlockTitleRegex)![1];
|
||||
}
|
||||
|
||||
let language =
|
||||
|
|
Loading…
Add table
Reference in a new issue