From 9f3b2f8e2e0f86caa6d53b18361c5eaa7b6a26c3 Mon Sep 17 00:00:00 2001 From: Oliver Geer Date: Tue, 29 Jul 2025 21:35:13 +0100 Subject: [PATCH] Make autodetect work with hyphen-including language names (Fix #103) --- plugins/autodetect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/autodetect.js b/plugins/autodetect.js index e54f753..c14be00 100644 --- a/plugins/autodetect.js +++ b/plugins/autodetect.js @@ -19,7 +19,7 @@ codeInput.plugins.Autodetect = class extends codeInput.Plugin { afterHighlight(codeInput) { let langClass = codeInput.codeElement.className || codeInput.preElement.className; let lang = langClass.match(/lang(\w|-)*/i)[0]; // Get word starting with lang...; Get outer bracket - lang = lang.split("-")[1]; + lang = lang.match(/(?<=-)(\w|-)*/i)[0]; if(lang == "undefined") { codeInput.removeAttribute("language"); codeInput.removeAttribute("lang");