diff options
Diffstat (limited to 'packages/markdown/remark')
-rw-r--r-- | packages/markdown/remark/src/highlight.ts | 4 | ||||
-rw-r--r-- | packages/markdown/remark/src/rehype-collect-headings.ts | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/packages/markdown/remark/src/highlight.ts b/packages/markdown/remark/src/highlight.ts index 41ec8880b..ef1a734ba 100644 --- a/packages/markdown/remark/src/highlight.ts +++ b/packages/markdown/remark/src/highlight.ts @@ -43,14 +43,14 @@ export async function highlightCodeBlocks(tree: Root, highlighter: Highlighter) let languageMatch: RegExpMatchArray | null | undefined; let { className } = node.properties; if (typeof className === 'string') { - languageMatch = className.match(languagePattern); + languageMatch = languagePattern.exec(className); } else if (Array.isArray(className)) { for (const cls of className) { if (typeof cls !== 'string') { continue; } - languageMatch = cls.match(languagePattern); + languageMatch = languagePattern.exec(cls); if (languageMatch) { break; } diff --git a/packages/markdown/remark/src/rehype-collect-headings.ts b/packages/markdown/remark/src/rehype-collect-headings.ts index 862400545..3bff443e2 100644 --- a/packages/markdown/remark/src/rehype-collect-headings.ts +++ b/packages/markdown/remark/src/rehype-collect-headings.ts @@ -20,7 +20,7 @@ export function rehypeHeadingIds(): ReturnType<RehypePlugin> { if (node.type !== 'element') return; const { tagName } = node; if (tagName[0] !== 'h') return; - const [, level] = tagName.match(/h([0-6])/) ?? []; + const [, level] = /h([0-6])/.exec(tagName) ?? []; if (!level) return; const depth = Number.parseInt(level); @@ -30,7 +30,7 @@ export function rehypeHeadingIds(): ReturnType<RehypePlugin> { return; } if (child.type === 'raw') { - if (child.value.match(/^\n?<.*>\n?$/)) { + if (/^\n?<.*>\n?$/.test(child.value)) { return; } } |