MCPcopy
hub / github.com/marktext/marktext / transformAliasToOrigin

Function transformAliasToOrigin

packages/muya/src/utils/prism/loadLanguage.ts:24–55  ·  view source on GitHub ↗
(langs: string[])

Source from the content-addressed store, hash-verified

22
23// Look for the origin language by alias
24export function transformAliasToOrigin(langs: string[]) {
25 const result = [];
26
27 for (const lang of langs) {
28 if (languages[lang]) {
29 result.push(lang);
30 }
31 else {
32 const language = Object.keys(languages).find((name) => {
33 const l = languages[name];
34 if (l.alias) {
35 return (
36 l.alias === lang
37 || (Array.isArray(l.alias) && l.alias.includes(lang))
38 );
39 }
40
41 return false;
42 });
43
44 if (language) {
45 result.push(language);
46 }
47 else {
48 // The lang is not exist, the will handle in `initLoadLanguage`
49 result.push(lang);
50 }
51 }
52 }
53
54 return result;
55}
56
57// Minimal Prism surface this module needs — full Prism typings live in
58// prismjs's external @types package, but we only read `languages` here.

Callers 2

updateMethod · 0.50
backspaceHandlerMethod · 0.50

Calls 2

pushMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected