Skip to content

Commit

Permalink
refactor(v2): improve regex matching code-block title
Browse files Browse the repository at this point in the history
  • Loading branch information
Anh Hong committed Nov 4, 2020
1 parent 7c7e0c2 commit 8159621
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)![1];
}

let language =
Expand Down

0 comments on commit 8159621

Please sign in to comment.