fix(highlightjs): unable to match due to init normalization

This commit is contained in:
Elian Doran
2025-05-18 16:05:50 +03:00
parent 4fad4de319
commit b0ebeb22d5
10 changed files with 37 additions and 42 deletions

View File

@@ -16,3 +16,14 @@ export interface MimeType extends MimeTypeDefinition {
*/
enabled: boolean;
}
/**
* Given a MIME type in the usual format (e.g. `text/csrc`), it returns a MIME type that can be passed down to the CKEditor
* code plugin.
*
* @param mimeType The MIME type to normalize, in the usual format (e.g. `text/c-src`).
* @returns the normalized MIME type (e.g. `text-c-src`).
*/
export function normalizeMimeTypeForCKEditor(mimeType: string) {
return mimeType.toLowerCase().replace(/[\W_]+/g, "-");
}