From 0bd915f601b5224af5c4c119aae96c92b252dbda Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 15 Dec 2023 00:18:49 -0700 Subject: [PATCH] chore: clean up code --- src/index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index 95afb42..531f043 100644 --- a/src/index.js +++ b/src/index.js @@ -20,7 +20,7 @@ export function markedHighlight(options) { return; } - const lang = getLang(token); + const lang = getLang(token.lang); if (options.async) { return Promise.resolve(options.highlight(token.text, lang, token.lang || '')).then(updateToken(token)); @@ -34,7 +34,7 @@ export function markedHighlight(options) { }, renderer: { code(code, infoString, escaped) { - const lang = (infoString || '').match(/\S*/)[0]; + const lang = getLang(infoString); const classAttr = lang ? ` class="${options.langPrefix}${escape(lang)}"` : ''; @@ -45,8 +45,8 @@ export function markedHighlight(options) { }; } -function getLang(token) { - return (token.lang || '').match(/\S*/)[0]; +function getLang(lang) { + return (lang || '').match(/\S*/)[0]; } function updateToken(token) {