Skip to content

Commit

Permalink
refactor(v2): improve regex matching code-block title (facebook#3671)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anh Hong committed Nov 2, 2020
1 parent 398af74 commit 3242549
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const highlightDirectiveRegex = (lang) => {
return getHighlightDirectiveRegex();
}
};
const codeBlockTitleRegex = /title=".*"/;
const codeBlockTitleRegex = /(?<=title=").*(?=")/;

export default ({
children,
Expand Down Expand Up @@ -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)![0];
}

let language =
Expand Down

0 comments on commit 3242549

Please sign in to comment.