=> {
* @returns HTMLElement 语言标签元素
*/
const createLanguageLabel = (language: string): HTMLElement => {
- const label = document.createElement("span");
- label.className = "code-language-label";
+ const label = document.createElement('span');
+ label.className = 'code-language-label';
label.textContent = getLanguageDisplayName(language);
- label.setAttribute("data-language", language);
+ label.setAttribute('data-language', language);
return label;
};
@@ -120,8 +117,8 @@ const createLanguageLabel = (language: string): HTMLElement => {
* @returns HTMLElement 复制按钮元素
*/
const createCopyButton = (codeText: string): HTMLElement => {
- const button = document.createElement("button");
- button.className = "code-copy-button";
+ const button = document.createElement('button');
+ button.className = 'code-copy-button';
button.innerHTML = `
Copy
`;
- button.setAttribute("title", "Copy code");
- button.setAttribute("aria-label", "Copy code to clipboard");
+ button.setAttribute('title', 'Copy code');
+ button.setAttribute('aria-label', 'Copy code to clipboard');
- button.addEventListener("click", async (e) => {
+ button.addEventListener('click', (e) => {
e.preventDefault();
e.stopPropagation();
- const success = await copyToClipboard(codeText);
- const textSpan = button.querySelector(".copy-text");
- if (textSpan) {
- if (success) {
- textSpan.textContent = "Copied!";
- button.classList.add("copied");
- setTimeout(() => {
- textSpan.textContent = "Copy";
- button.classList.remove("copied");
- }, 2000);
- } else {
- textSpan.textContent = "Failed";
- button.classList.add("error");
- setTimeout(() => {
- textSpan.textContent = "Copy";
- button.classList.remove("error");
- }, 2000);
+ (async () => {
+ const success = await copyToClipboard(codeText);
+ const textSpan = button.querySelector('.copy-text');
+ if (textSpan) {
+ if (success) {
+ textSpan.textContent = 'Copied!';
+ button.classList.add('copied');
+ setTimeout(() => {
+ textSpan.textContent = 'Copy';
+ button.classList.remove('copied');
+ }, 2000);
+ } else {
+ textSpan.textContent = 'Failed';
+ button.classList.add('error');
+ setTimeout(() => {
+ textSpan.textContent = 'Copy';
+ button.classList.remove('error');
+ }, 2000);
+ }
}
- }
+ })();
});
return button;
@@ -166,8 +165,8 @@ const createCopyButton = (codeText: string): HTMLElement => {
* @returns HTMLElement 工具栏元素
*/
const createCodeToolbar = (language: string, codeText: string): HTMLElement => {
- const toolbar = document.createElement("div");
- toolbar.className = "code-toolbar";
+ const toolbar = document.createElement('div');
+ toolbar.className = 'code-toolbar';
// 注意:你的 CSS 中 .code-header 使用了 justify-content: space-between
// 这里我们将语言和复制按钮都放在同一个工具栏里,会一起显示在右侧
@@ -185,27 +184,27 @@ const createCodeToolbar = (language: string, codeText: string): HTMLElement => {
* @param codeBlock pre 元素
*/
const enhanceSingleCodeBlock = (codeBlock: HTMLElement): void => {
- if (codeBlock.closest(".enhanced-code-block")) {
+ if (codeBlock.closest('.enhanced-code-block')) {
return;
}
const codeElement = codeBlock.querySelector('code[class*="language-"]');
if (!codeElement) return;
const languageClass = codeElement.className.match(/language-(\w+)/);
- const language = languageClass ? languageClass[1] : "text";
- const codeText = codeElement.textContent || "";
+ const language = languageClass ? languageClass[1] : 'text';
+ const codeText = codeElement.textContent || '';
if (!codeText.trim()) return;
-
+
const parent = codeBlock.parentNode;
if (!parent) return;
// 1. 创建总包装器,对应 .enhanced-code-block 样式
- const wrapper = document.createElement("div");
- wrapper.className = "enhanced-code-block";
+ const wrapper = document.createElement('div');
+ wrapper.className = 'enhanced-code-block';
// 2. 创建头部容器,对应 .code-header 样式
- const header = document.createElement("div");
- header.className = "code-header";
+ const header = document.createElement('div');
+ header.className = 'code-header';
// 3. 创建工具栏并放入头部
const toolbar = createCodeToolbar(language, codeText);
@@ -219,7 +218,7 @@ const enhanceSingleCodeBlock = (codeBlock: HTMLElement): void => {
wrapper.appendChild(codeBlock);
// 6. 为原代码块添加 .code-content 类,以匹配样式
- codeBlock.classList.add("code-content");
+ codeBlock.classList.add('code-content');
};
/**
@@ -228,7 +227,7 @@ const enhanceSingleCodeBlock = (codeBlock: HTMLElement): void => {
* @returns boolean 是否应该增强
*/
const shouldEnhanceCodeBlock = (preElement: HTMLElement): boolean => {
- if (preElement.closest(".enhanced-code-block")) {
+ if (preElement.closest('.enhanced-code-block')) {
return false;
}
return !!preElement.querySelector('code[class*="language-"]');
@@ -238,9 +237,7 @@ const shouldEnhanceCodeBlock = (preElement: HTMLElement): boolean => {
* 增强页面中的所有代码块
*/
export const enhanceCodeBlocks = (): void => {
- const codeBlocks = document.querySelectorAll(
- 'pre:has(code[class*="language-"])'
- );
+ const codeBlocks = document.querySelectorAll('pre:has(code[class*="language-"])');
codeBlocks.forEach((block) => {
if (shouldEnhanceCodeBlock(block as HTMLElement)) {
enhanceSingleCodeBlock(block as HTMLElement);
@@ -248,7 +245,7 @@ export const enhanceCodeBlocks = (): void => {
});
if (codeBlocks.length === 0) {
- const allPreBlocks = document.querySelectorAll("pre");
+ const allPreBlocks = document.querySelectorAll('pre');
allPreBlocks.forEach((block) => {
const codeElement = block.querySelector('code[class*="language-"]');
if (codeElement && shouldEnhanceCodeBlock(block as HTMLElement)) {
@@ -262,11 +259,11 @@ export const enhanceCodeBlocks = (): void => {
* 移除所有代码块增强
*/
export const removeCodeBlockEnhancements = (): void => {
- const enhancedBlocks = document.querySelectorAll(".enhanced-code-block");
+ const enhancedBlocks = document.querySelectorAll('.enhanced-code-block');
enhancedBlocks.forEach((wrapper) => {
- const codeBlock = wrapper.querySelector("pre.code-content");
+ const codeBlock = wrapper.querySelector('pre.code-content');
if (codeBlock && wrapper.parentNode) {
- codeBlock.classList.remove("code-content");
+ codeBlock.classList.remove('code-content');
wrapper.parentNode.insertBefore(codeBlock, wrapper);
wrapper.remove();
}
@@ -283,10 +280,10 @@ export const createCodeBlockObserver = (): MutationObserver => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE) {
const element = node as HTMLElement;
- if (element.matches("pre") && shouldEnhanceCodeBlock(element)) {
+ if (element.matches('pre') && shouldEnhanceCodeBlock(element)) {
enhanceSingleCodeBlock(element);
} else {
- element.querySelectorAll("pre").forEach((block) => {
+ element.querySelectorAll('pre').forEach((block) => {
if (shouldEnhanceCodeBlock(block)) {
enhanceSingleCodeBlock(block);
}
@@ -297,4 +294,4 @@ export const createCodeBlockObserver = (): MutationObserver => {
});
});
return observer;
-};
\ No newline at end of file
+};
diff --git a/src/components/post/codeBlocks/codeBlockStyles.ts b/src/components/post/codeBlocks/codeBlockStyles.ts
index a112718..9dff38b 100644
--- a/src/components/post/codeBlocks/codeBlockStyles.ts
+++ b/src/components/post/codeBlocks/codeBlockStyles.ts
@@ -8,35 +8,34 @@
* @param theme 当前主题 ('dark' | 'light')
* @returns CSS 样式字符串
*/
-export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): string => {
- return `
+export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): string => `
/* 代码块容器整体样式 */
.enhanced-code-block {
position: relative; /* 改为非 important,避免不必要的覆盖 */
border-radius: 8px;
overflow: hidden;
margin: 16px 0;
- border: 1px solid ${theme === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)"
- };
+ border: 1px solid ${theme === 'dark' ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'
+};
}
/* 代码块头部,用于容纳工具栏 */
.code-header {
- background: ${theme === "dark"
- ? "linear-gradient(135deg, #1e1e2e 0%, #24243e 100%)"
- : "linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)"
- };
- border-bottom: 1px solid ${theme === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)"
- };
+ background: ${theme === 'dark'
+ ? 'linear-gradient(135deg, #1e1e2e 0%, #24243e 100%)'
+ : 'linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%)'
+};
+ border-bottom: 1px solid ${theme === 'dark' ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'
+};
padding: 8px 12px;
display: flex;
justify-content: flex-end; /* 修改为 flex-end 使工具栏靠右 */
align-items: center;
min-height: 36px;
- box-shadow: ${theme === "dark"
- ? "0 1px 3px rgba(0, 0, 0, 0.3)"
- : "0 1px 3px rgba(0, 0, 0, 0.1)"
- };
+ box-shadow: ${theme === 'dark'
+ ? '0 1px 3px rgba(0, 0, 0, 0.3)'
+ : '0 1px 3px rgba(0, 0, 0, 0.1)'
+};
}
/* 工具栏,包含语言和复制按钮 */
@@ -47,10 +46,10 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
/* 语言标签样式 */
.code-language-label {
- background-color: ${theme === "dark" ? "rgba(255, 255, 255, 0.15)" : "rgba(0, 0, 0, 0.15)"
- };
- color: ${theme === "dark" ? "rgba(255, 255, 255, 0.8)" : "rgba(0, 0, 0, 0.7)"
- };
+ background-color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.15)' : 'rgba(0, 0, 0, 0.15)'
+};
+ color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.8)' : 'rgba(0, 0, 0, 0.7)'
+};
padding: 4px 8px;
border-radius: 4px;
font-size: 11px;
@@ -58,19 +57,19 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
text-transform: uppercase;
letter-spacing: 0.5px;
font-family: 'JetBrains Mono', 'Consolas', 'Monaco', 'SF Mono', 'Cascadia Code', 'Roboto Mono', 'Courier New', "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", monospace;
- border: 1px solid ${theme === "dark" ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.2)"
- };
+ border: 1px solid ${theme === 'dark' ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'
+};
user-select: none;
}
/* 复制按钮样式 */
.code-copy-button {
- background-color: ${theme === "dark" ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.1)"
- };
- color: ${theme === "dark" ? "rgba(255, 255, 255, 0.8)" : "rgba(0, 0, 0, 0.7)"
- };
- border: 1px solid ${theme === "dark" ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.2)"
- };
+ background-color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'
+};
+ color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.8)' : 'rgba(0, 0, 0, 0.7)'
+};
+ border: 1px solid ${theme === 'dark' ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'
+};
border-radius: 4px;
padding: 4px 8px;
display: flex;
@@ -85,17 +84,17 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
}
.code-copy-button:hover {
- background-color: ${theme === "dark" ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.2)"
- };
- color: ${theme === "dark" ? "rgba(255, 255, 255, 0.95)" : "rgba(0, 0, 0, 0.9)"
- };
- border-color: ${theme === "dark" ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.3)"
- };
+ background-color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.2)' : 'rgba(0, 0, 0, 0.2)'
+};
+ color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.95)' : 'rgba(0, 0, 0, 0.9)'
+};
+ border-color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'
+};
transform: translateY(-1px);
- box-shadow: ${theme === "dark"
- ? "0 2px 8px rgba(0, 0, 0, 0.3)"
- : "0 2px 8px rgba(0, 0, 0, 0.1)"
- };
+ box-shadow: ${theme === 'dark'
+ ? '0 2px 8px rgba(0, 0, 0, 0.3)'
+ : '0 2px 8px rgba(0, 0, 0, 0.1)'
+};
}
.code-copy-button:active {
@@ -104,13 +103,13 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
}
.code-copy-button:focus-visible {
- box-shadow: 0 0 0 2px ${theme === "dark" ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.3)"
- };
+ box-shadow: 0 0 0 2px ${theme === 'dark' ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'
+};
}
/* 代码内容区域样式,应用于 元素 */
.code-content {
- background-color: ${theme === "dark" ? "#282a36" : "#f8f9fa"};
+ background-color: ${theme === 'dark' ? '#282a36' : '#f8f9fa'};
margin: 0 !important;
border: none !important;
border-radius: 0 !important;
@@ -118,20 +117,20 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
/* 复制成功状态 */
.code-copy-button.copied {
- background-color: ${theme === "dark" ? "rgba(34, 197, 94, 0.2)" : "rgba(34, 197, 94, 0.1)"
- };
- color: ${theme === "dark" ? "#22c55e" : "#16a34a"};
- border-color: ${theme === "dark" ? "rgba(34, 197, 94, 0.3)" : "rgba(34, 197, 94, 0.2)"
- };
+ background-color: ${theme === 'dark' ? 'rgba(34, 197, 94, 0.2)' : 'rgba(34, 197, 94, 0.1)'
+};
+ color: ${theme === 'dark' ? '#22c55e' : '#16a34a'};
+ border-color: ${theme === 'dark' ? 'rgba(34, 197, 94, 0.3)' : 'rgba(34, 197, 94, 0.2)'
+};
}
/* 复制失败状态 */
.code-copy-button.error {
- background-color: ${theme === "dark" ? "rgba(239, 68, 68, 0.2)" : "rgba(239, 68, 68, 0.1)"
- };
- color: ${theme === "dark" ? "#ef4444" : "#dc2626"};
- border-color: ${theme === "dark" ? "rgba(239, 68, 68, 0.3)" : "rgba(239, 68, 68, 0.2)"
- };
+ background-color: ${theme === 'dark' ? 'rgba(239, 68, 68, 0.2)' : 'rgba(239, 68, 68, 0.1)'
+};
+ color: ${theme === 'dark' ? '#ef4444' : '#dc2626'};
+ border-color: ${theme === 'dark' ? 'rgba(239, 68, 68, 0.3)' : 'rgba(239, 68, 68, 0.2)'
+};
}
.copy-icon {
@@ -149,6 +148,14 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
/* 其他媒体查询和状态样式保持不变... */
@media (max-width: 768px) {
+ /* 新增:移动端抵消列表缩进 */
+ li .enhanced-code-block {
+ width: 100vw;
+ max-width: 90vw;
+ margin-left: calc(50% - 50vw + 0.55rem);
+ box-sizing: border-box;
+ }
+
.code-header {
padding: 6px 8px;
min-height: 32px;
@@ -161,7 +168,7 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
}
@media (prefers-contrast: high) {
.code-language-label, .code-copy-button {
- background-color: ${theme === "dark" ? "rgba(255, 255, 255, 0.3)" : "rgba(0, 0, 0, 0.3)"};
+ background-color: ${theme === 'dark' ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'};
border-width: 2px;
}
}
@@ -174,4 +181,3 @@ export const generateCodeBlockEnhancementStyles = (theme: 'dark' | 'light'): str
.code-header { display: none; }
}
`;
-};
\ No newline at end of file
diff --git a/src/components/post/codeBlocks/codeMirrorCleaner.ts b/src/components/post/codeBlocks/codeMirrorCleaner.ts
index f16575f..ae1dd87 100644
--- a/src/components/post/codeBlocks/codeMirrorCleaner.ts
+++ b/src/components/post/codeBlocks/codeMirrorCleaner.ts
@@ -10,43 +10,42 @@
*/
export const cleanCodeMirrorContent = (htmlContent: string): string => {
// 创建一个临时的 DOM 元素来解析 HTML
- const tempDiv = document.createElement("div");
+ const tempDiv = document.createElement('div');
tempDiv.innerHTML = htmlContent;
// 处理新的 HTML 结构:
- const mdFencesBlocks = tempDiv.querySelectorAll("pre.md-fences");
+ const mdFencesBlocks = tempDiv.querySelectorAll('pre.md-fences');
mdFencesBlocks.forEach((outerPre) => {
// 检查是否包含 cleaned-codemirror-block
- const innerPre = outerPre.querySelector("pre.cleaned-codemirror-block");
- const codeElement = innerPre?.querySelector("code");
+ const innerPre = outerPre.querySelector('pre.cleaned-codemirror-block');
+ const codeElement = innerPre?.querySelector('code');
if (innerPre && codeElement) {
// 获取语言信息,优先从外层 pre 获取 lang 属性,然后从 code 元素的类名中提取
- let langAttr =
- outerPre.getAttribute("lang") ||
- outerPre.getAttribute("data-lang") ||
- codeElement.className.match(/language-(\w+)/)?.[1] ||
- "";
+ const langAttr = outerPre.getAttribute('lang')
+ || outerPre.getAttribute('data-lang')
+ || codeElement.className.match(/language-(\w+)/)?.[1]
+ || '';
// 清理代码内容 - 替换 为普通空格
- let codeContent = codeElement.textContent || "";
- codeContent = codeContent.replace(/\u00A0/g, " "); // 替换 (非断行空格)
+ let codeContent = codeElement.textContent || '';
+ codeContent = codeContent.replace(/\u00A0/g, ' '); // 替换 (非断行空格)
// 创建新的简化代码块
- const newPre = document.createElement("pre");
- const newCode = document.createElement("code");
+ const newPre = document.createElement('pre');
+ const newCode = document.createElement('code');
// 设置语言类名用于 Prism 高亮
if (langAttr) {
newCode.className = `language-${langAttr}`;
// 同时在 pre 元素上也添加语言信息,以便调试
- newPre.setAttribute("data-lang", langAttr);
+ newPre.setAttribute('data-lang', langAttr);
}
newCode.textContent = codeContent;
newPre.appendChild(newCode);
- newPre.className = "cleaned-codemirror-block";
+ newPre.className = 'cleaned-codemirror-block';
// 替换整个外层 pre
outerPre.parentNode?.replaceChild(newPre, outerPre);
@@ -54,16 +53,16 @@ export const cleanCodeMirrorContent = (htmlContent: string): string => {
});
// 查找所有 CodeMirror 代码块(处理其他可能的结构)
- const codeMirrorBlocks = tempDiv.querySelectorAll(".CodeMirror");
+ const codeMirrorBlocks = tempDiv.querySelectorAll('.CodeMirror');
codeMirrorBlocks.forEach((block) => {
// 提取所有代码行的文本内容
- const codeLines = block.querySelectorAll(".CodeMirror-line");
+ const codeLines = block.querySelectorAll('.CodeMirror-line');
const codeContent: string[] = [];
codeLines.forEach((line) => {
// 获取每行的纯文本内容,忽略所有的样式和结构
- const lineText = line.textContent || "";
+ const lineText = line.textContent || '';
// 过滤掉那些无意义的 "xxxxxxxxxx" 内容
if (lineText.trim() && !lineText.match(/^x+$/)) {
codeContent.push(lineText);
@@ -73,33 +72,32 @@ export const cleanCodeMirrorContent = (htmlContent: string): string => {
// 如果提取到了有效的代码内容
if (codeContent.length > 0) {
// 创建一个简单的 pre 元素来替换复杂的 CodeMirror 结构
- const simpleCodeBlock = document.createElement("pre");
- const codeElement = document.createElement("code");
+ const simpleCodeBlock = document.createElement('pre');
+ const codeElement = document.createElement('code');
// 更全面地获取语言信息
- const parentPre = block.closest("pre.md-fences");
- let langAttr =
- block.getAttribute("lang") ||
- block.getAttribute("data-lang") ||
- parentPre?.getAttribute("lang") ||
- parentPre?.getAttribute("data-lang") ||
- block.className.match(/cm-s-(\w+)/)?.[1] || // CodeMirror 主题可能包含语言信息
- "";
+ const parentPre = block.closest('pre.md-fences');
+ const langAttr = block.getAttribute('lang')
+ || block.getAttribute('data-lang')
+ || parentPre?.getAttribute('lang')
+ || parentPre?.getAttribute('data-lang')
+ || block.className.match(/cm-s-(\w+)/)?.[1] // CodeMirror 主题可能包含语言信息
+ || '';
if (langAttr) {
codeElement.className = `language-${langAttr}`;
// 同时在 pre 元素上也添加语言信息,以便调试
- simpleCodeBlock.setAttribute("data-lang", langAttr);
+ simpleCodeBlock.setAttribute('data-lang', langAttr);
}
// 设置代码内容,替换 为普通空格
- let joinedContent = codeContent.join("\n");
- joinedContent = joinedContent.replace(/\u00A0/g, " ");
+ let joinedContent = codeContent.join('\n');
+ joinedContent = joinedContent.replace(/\u00A0/g, ' ');
codeElement.textContent = joinedContent;
simpleCodeBlock.appendChild(codeElement);
// 添加自定义类名用于样式控制
- simpleCodeBlock.className = "cleaned-codemirror-block";
+ simpleCodeBlock.className = 'cleaned-codemirror-block';
// 替换原始的 CodeMirror 块
block.parentNode?.replaceChild(simpleCodeBlock, block);
@@ -110,16 +108,16 @@ export const cleanCodeMirrorContent = (htmlContent: string): string => {
});
// 同时处理包含 CodeMirror 的 pre 标签(保留原有逻辑作为后备)
- const preTags = tempDiv.querySelectorAll("pre.md-fences");
+ const preTags = tempDiv.querySelectorAll('pre.md-fences');
preTags.forEach((preTag) => {
- const codeMirrorDiv = preTag.querySelector(".CodeMirror");
+ const codeMirrorDiv = preTag.querySelector('.CodeMirror');
if (codeMirrorDiv) {
// 提取代码内容
- const codeLines = codeMirrorDiv.querySelectorAll(".CodeMirror-line");
+ const codeLines = codeMirrorDiv.querySelectorAll('.CodeMirror-line');
const codeContent: string[] = [];
codeLines.forEach((line) => {
- const lineText = line.textContent || "";
+ const lineText = line.textContent || '';
if (lineText.trim() && !lineText.match(/^x+$/)) {
codeContent.push(lineText);
}
@@ -127,30 +125,29 @@ export const cleanCodeMirrorContent = (htmlContent: string): string => {
if (codeContent.length > 0) {
// 更全面地获取语言信息
- let langAttr =
- preTag.getAttribute("lang") ||
- preTag.getAttribute("data-lang") ||
- codeMirrorDiv.getAttribute("lang") ||
- codeMirrorDiv.getAttribute("data-lang") ||
- preTag.className.match(/language-(\w+)/)?.[1] ||
- codeMirrorDiv.className.match(/cm-s-(\w+)/)?.[1] ||
- "";
+ const langAttr = preTag.getAttribute('lang')
+ || preTag.getAttribute('data-lang')
+ || codeMirrorDiv.getAttribute('lang')
+ || codeMirrorDiv.getAttribute('data-lang')
+ || preTag.className.match(/language-(\w+)/)?.[1]
+ || codeMirrorDiv.className.match(/cm-s-(\w+)/)?.[1]
+ || '';
// 创建简化的代码块
- const simpleCodeBlock = document.createElement("pre");
- const codeElement = document.createElement("code");
+ const simpleCodeBlock = document.createElement('pre');
+ const codeElement = document.createElement('code');
if (langAttr) {
codeElement.className = `language-${langAttr}`;
// 同时在 pre 元素上也添加语言信息,以便调试
- simpleCodeBlock.setAttribute("data-lang", langAttr);
+ simpleCodeBlock.setAttribute('data-lang', langAttr);
}
- let joinedContent = codeContent.join("\n");
- joinedContent = joinedContent.replace(/\u00A0/g, " ");
+ let joinedContent = codeContent.join('\n');
+ joinedContent = joinedContent.replace(/\u00A0/g, ' ');
codeElement.textContent = joinedContent;
simpleCodeBlock.appendChild(codeElement);
- simpleCodeBlock.className = "cleaned-codemirror-block";
+ simpleCodeBlock.className = 'cleaned-codemirror-block';
// 替换整个 pre 标签
preTag.parentNode?.replaceChild(simpleCodeBlock, preTag);
diff --git a/src/components/post/codeBlocks/cssLoader.ts b/src/components/post/codeBlocks/cssLoader.ts
index 5dbd2df..aca0fd9 100644
--- a/src/components/post/codeBlocks/cssLoader.ts
+++ b/src/components/post/codeBlocks/cssLoader.ts
@@ -9,25 +9,23 @@
* @param id CSS 元素的唯一标识符
* @returns Promise
*/
-export const loadCSS = (href: string, id: string): Promise => {
- return new Promise((resolve, reject) => {
- // 如果已存在相同 id 的样式表,先移除
- const existing = document.getElementById(id);
- if (existing) {
- existing.remove();
- }
+export const loadCSS = (href: string, id: string): Promise => new Promise((resolve, reject) => {
+ // 如果已存在相同 id 的样式表,先移除
+ const existing = document.getElementById(id);
+ if (existing) {
+ existing.remove();
+ }
- const link = document.createElement("link");
- link.rel = "stylesheet";
- link.href = href;
- link.id = id;
+ const link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = href;
+ link.id = id;
- link.onload = () => resolve();
- link.onerror = () => reject(new Error(`Failed to load CSS: ${href}`));
+ link.onload = () => resolve();
+ link.onerror = () => reject(new Error(`Failed to load CSS: ${href}`));
- document.head.appendChild(link);
- });
-};
+ document.head.appendChild(link);
+});
/**
* 根据主题加载相应的样式文件
@@ -39,41 +37,41 @@ export const loadThemeStyles = async (theme: string): Promise => {
// 加载基础 CSS(始终需要)
await Promise.all([
loadCSS(
- "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css",
- "katex-css"
+ 'https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css',
+ 'katex-css',
),
loadCSS(
- "https://cdn.jsdelivr.net/npm/codemirror@5/lib/codemirror.css",
- "codemirror-base-css"
+ 'https://cdn.jsdelivr.net/npm/codemirror@5/lib/codemirror.css',
+ 'codemirror-base-css',
),
]);
// 根据主题加载不同的样式
- if (theme === "dark") {
+ if (theme === 'dark') {
await Promise.all([
loadCSS(
- "https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-atom-dark.css",
- "prism-theme-css"
+ 'https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-atom-dark.css',
+ 'prism-theme-css',
),
loadCSS(
- "https://cdn.jsdelivr.net/npm/codemirror@5/theme/yonce.css",
- "codemirror-theme-css"
+ 'https://cdn.jsdelivr.net/npm/codemirror@5/theme/yonce.css',
+ 'codemirror-theme-css',
),
]);
} else {
await Promise.all([
loadCSS(
- "https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-one-light.css",
- "prism-theme-css"
+ 'https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/prism-one-light.css',
+ 'prism-theme-css',
),
loadCSS(
- "https://cdn.jsdelivr.net/npm/codemirror@5/theme/duotone-light.css",
- "codemirror-theme-css"
+ 'https://cdn.jsdelivr.net/npm/codemirror@5/theme/duotone-light.css',
+ 'codemirror-theme-css',
),
]);
}
} catch (error) {
- console.warn("Failed to load some CSS files:", error);
+ console.warn('Failed to load some CSS files:', error);
throw error;
}
};
diff --git a/src/components/post/codeBlocks/prism-components.json b/src/components/post/codeBlocks/prism-components.json
index d7e1d59..0ed588b 100644
--- a/src/components/post/codeBlocks/prism-components.json
+++ b/src/components/post/codeBlocks/prism-components.json
@@ -1,1766 +1,1719 @@
{
- "core": {
- "meta": {
- "path": "components/prism-core.js",
- "option": "mandatory"
- },
- "core": "Core"
- },
- "themes": {
- "meta": {
- "path": "themes/{id}.css",
- "link": "index.html?theme={id}",
- "exclusive": true
- },
- "prism": {
- "title": "Default",
- "option": "default"
- },
- "prism-dark": "Dark",
- "prism-funky": "Funky",
- "prism-okaidia": {
- "title": "Okaidia",
- "owner": "ocodia"
- },
- "prism-twilight": {
- "title": "Twilight",
- "owner": "remybach"
- },
- "prism-coy": {
- "title": "Coy",
- "owner": "tshedor"
- },
- "prism-solarizedlight": {
- "title": "Solarized Light",
- "owner": "hectormatos2011 "
- },
- "prism-tomorrow": {
- "title": "Tomorrow Night",
- "owner": "Rosey"
- }
- },
- "languages": {
- "meta": {
- "path": "components/prism-{id}",
- "noCSS": true,
- "examplesPath": "examples/prism-{id}",
- "addCheckAll": true
- },
- "markup": {
- "title": "Markup",
- "alias": ["html", "xml", "svg", "mathml", "ssml", "atom", "rss"],
- "aliasTitles": {
- "html": "HTML",
- "xml": "XML",
- "svg": "SVG",
- "mathml": "MathML",
- "ssml": "SSML",
- "atom": "Atom",
- "rss": "RSS"
- },
- "option": "default"
- },
- "css": {
- "title": "CSS",
- "option": "default",
- "modify": "markup"
- },
- "clike": {
- "title": "C-like",
- "option": "default"
- },
- "javascript": {
- "title": "JavaScript",
- "require": "clike",
- "modify": "markup",
- "optional": "regex",
- "alias": "js",
- "option": "default"
- },
- "abap": {
- "title": "ABAP",
- "owner": "dellagustin"
- },
- "abnf": {
- "title": "ABNF",
- "owner": "RunDevelopment"
- },
- "actionscript": {
- "title": "ActionScript",
- "require": "javascript",
- "modify": "markup",
- "owner": "Golmote"
- },
- "ada": {
- "title": "Ada",
- "owner": "Lucretia"
- },
- "agda": {
- "title": "Agda",
- "owner": "xy-ren"
- },
- "al": {
- "title": "AL",
- "owner": "RunDevelopment"
- },
- "antlr4": {
- "title": "ANTLR4",
- "alias": "g4",
- "owner": "RunDevelopment"
- },
- "apacheconf": {
- "title": "Apache Configuration",
- "owner": "GuiTeK"
- },
- "apex": {
- "title": "Apex",
- "require": ["clike", "sql"],
- "owner": "RunDevelopment"
- },
- "apl": {
- "title": "APL",
- "owner": "ngn"
- },
- "applescript": {
- "title": "AppleScript",
- "owner": "Golmote"
- },
- "aql": {
- "title": "AQL",
- "owner": "RunDevelopment"
- },
- "arduino": {
- "title": "Arduino",
- "require": "cpp",
- "alias": "ino",
- "owner": "dkern"
- },
- "arff": {
- "title": "ARFF",
- "owner": "Golmote"
- },
- "armasm": {
- "title": "ARM Assembly",
- "alias": "arm-asm",
- "owner": "RunDevelopment"
- },
- "arturo": {
- "title": "Arturo",
- "alias": "art",
- "optional": [
- "bash",
- "css",
- "javascript",
- "markup",
- "markdown",
- "sql"
- ],
- "owner": "drkameleon"
- },
- "asciidoc": {
- "alias": "adoc",
- "title": "AsciiDoc",
- "owner": "Golmote"
- },
- "aspnet": {
- "title": "ASP.NET (C#)",
- "require": ["markup", "csharp"],
- "owner": "nauzilus"
- },
- "asm6502": {
- "title": "6502 Assembly",
- "owner": "kzurawel"
- },
- "asmatmel": {
- "title": "Atmel AVR Assembly",
- "owner": "cerkit"
- },
- "autohotkey": {
- "title": "AutoHotkey",
- "owner": "aviaryan"
- },
- "autoit": {
- "title": "AutoIt",
- "owner": "Golmote"
- },
- "avisynth": {
- "title": "AviSynth",
- "alias": "avs",
- "owner": "Zinfidel"
- },
- "avro-idl": {
- "title":"Avro IDL",
- "alias": "avdl",
- "owner": "RunDevelopment"
- },
- "awk": {
- "title": "AWK",
- "alias": "gawk",
- "aliasTitles": {
- "gawk": "GAWK"
- },
- "owner": "RunDevelopment"
- },
- "bash": {
- "title": "Bash",
- "alias": ["sh", "shell"],
- "aliasTitles": {
- "sh": "Shell",
- "shell": "Shell"
- },
- "owner": "zeitgeist87"
- },
- "basic": {
- "title": "BASIC",
- "owner": "Golmote"
- },
- "batch": {
- "title": "Batch",
- "owner": "Golmote"
- },
- "bbcode": {
- "title": "BBcode",
- "alias": "shortcode",
- "aliasTitles": {
- "shortcode": "Shortcode"
- },
- "owner": "RunDevelopment"
- },
- "bbj": {
- "title": "BBj",
- "owner": "hyyan"
- },
- "bicep": {
- "title": "Bicep",
- "owner": "johnnyreilly"
- },
- "birb": {
- "title": "Birb",
- "require": "clike",
- "owner": "Calamity210"
- },
- "bison": {
- "title": "Bison",
- "require": "c",
- "owner": "Golmote"
- },
- "bnf": {
- "title": "BNF",
- "alias": "rbnf",
- "aliasTitles": {
- "rbnf": "RBNF"
- },
- "owner": "RunDevelopment"
- },
- "bqn": {
- "title": "BQN",
- "owner": "yewscion"
- },
- "brainfuck": {
- "title": "Brainfuck",
- "owner": "Golmote"
- },
- "brightscript": {
- "title": "BrightScript",
- "owner": "RunDevelopment"
- },
- "bro": {
- "title": "Bro",
- "owner": "wayward710"
- },
- "bsl": {
- "title": "BSL (1C:Enterprise)",
- "alias": "oscript",
- "aliasTitles": {
- "oscript": "OneScript"
- },
- "owner": "Diversus23"
- },
- "c": {
- "title": "C",
- "require": "clike",
- "owner": "zeitgeist87"
- },
- "csharp": {
- "title": "C#",
- "require": "clike",
- "alias": ["cs", "dotnet"],
- "owner": "mvalipour"
- },
- "cpp": {
- "title": "C++",
- "require": "c",
- "owner": "zeitgeist87"
- },
- "cfscript": {
- "title": "CFScript",
- "require": "clike",
- "alias": "cfc",
- "owner": "mjclemente"
- },
- "chaiscript": {
- "title": "ChaiScript",
- "require": ["clike", "cpp"],
- "owner": "RunDevelopment"
- },
- "cil": {
- "title": "CIL",
- "owner": "sbrl"
- },
- "cilkc": {
- "title": "Cilk/C",
- "require": "c",
- "alias": "cilk-c",
- "owner": "OpenCilk"
- },
- "cilkcpp": {
- "title": "Cilk/C++",
- "require": "cpp",
- "alias": ["cilk-cpp", "cilk"],
- "owner": "OpenCilk"
- },
- "clojure": {
- "title": "Clojure",
- "owner": "troglotit"
- },
- "cmake": {
- "title": "CMake",
- "owner": "mjrogozinski"
- },
- "cobol": {
- "title": "COBOL",
- "owner": "RunDevelopment"
- },
- "coffeescript": {
- "title": "CoffeeScript",
- "require": "javascript",
- "alias": "coffee",
- "owner": "R-osey"
- },
- "concurnas": {
- "title": "Concurnas",
- "alias": "conc",
- "owner": "jasontatton"
- },
- "csp": {
- "title": "Content-Security-Policy",
- "owner": "ScottHelme"
- },
- "cooklang": {
- "title": "Cooklang",
- "owner": "ahue"
- },
- "coq": {
- "title": "Coq",
- "owner": "RunDevelopment"
- },
- "crystal": {
- "title": "Crystal",
- "require": "ruby",
- "owner": "MakeNowJust"
- },
- "css-extras": {
- "title": "CSS Extras",
- "require": "css",
- "modify": "css",
- "owner": "milesj"
- },
- "csv": {
- "title": "CSV",
- "owner": "RunDevelopment"
- },
- "cue": {
- "title": "CUE",
- "owner": "RunDevelopment"
- },
- "cypher": {
- "title": "Cypher",
- "owner": "RunDevelopment"
- },
- "d": {
- "title": "D",
- "require": "clike",
- "owner": "Golmote"
- },
- "dart": {
- "title": "Dart",
- "require": "clike",
- "owner": "Golmote"
- },
- "dataweave": {
- "title": "DataWeave",
- "owner": "machaval"
- },
- "dax": {
- "title": "DAX",
- "owner": "peterbud"
- },
- "dhall": {
- "title": "Dhall",
- "owner": "RunDevelopment"
- },
- "diff": {
- "title": "Diff",
- "owner": "uranusjr"
- },
- "django": {
- "title": "Django/Jinja2",
- "require": "markup-templating",
- "alias": "jinja2",
- "owner": "romanvm"
- },
- "dns-zone-file": {
- "title": "DNS zone file",
- "owner": "RunDevelopment",
- "alias": "dns-zone"
- },
- "docker": {
- "title": "Docker",
- "alias": "dockerfile",
- "owner": "JustinBeckwith"
- },
- "dot": {
- "title": "DOT (Graphviz)",
- "alias": "gv",
- "optional": "markup",
- "owner": "RunDevelopment"
- },
- "ebnf": {
- "title": "EBNF",
- "owner": "RunDevelopment"
- },
- "editorconfig": {
- "title": "EditorConfig",
- "owner": "osipxd"
- },
- "eiffel": {
- "title": "Eiffel",
- "owner": "Conaclos"
- },
- "ejs": {
- "title": "EJS",
- "require": ["javascript", "markup-templating"],
- "owner": "RunDevelopment",
- "alias": "eta",
- "aliasTitles": {
- "eta": "Eta"
- }
- },
- "elixir": {
- "title": "Elixir",
- "owner": "Golmote"
- },
- "elm": {
- "title": "Elm",
- "owner": "zwilias"
- },
- "etlua": {
- "title": "Embedded Lua templating",
- "require": ["lua", "markup-templating"],
- "owner": "RunDevelopment"
- },
- "erb": {
- "title": "ERB",
- "require": ["ruby", "markup-templating"],
- "owner": "Golmote"
- },
- "erlang": {
- "title": "Erlang",
- "owner": "Golmote"
- },
- "excel-formula": {
- "title": "Excel Formula",
- "alias": ["xlsx", "xls"],
- "owner": "RunDevelopment"
- },
- "fsharp": {
- "title": "F#",
- "require": "clike",
- "owner": "simonreynolds7"
- },
- "factor": {
- "title": "Factor",
- "owner": "catb0t"
- },
- "false": {
- "title": "False",
- "owner": "edukisto"
- },
- "firestore-security-rules": {
- "title": "Firestore security rules",
- "require": "clike",
- "owner": "RunDevelopment"
- },
- "flow": {
- "title": "Flow",
- "require": "javascript",
- "owner": "Golmote"
- },
- "fortran": {
- "title": "Fortran",
- "owner": "Golmote"
- },
- "ftl": {
- "title": "FreeMarker Template Language",
- "require": "markup-templating",
- "owner": "RunDevelopment"
- },
- "gml": {
- "title": "GameMaker Language",
- "alias": "gamemakerlanguage",
- "require": "clike",
- "owner": "LiarOnce"
- },
- "gap": {
- "title": "GAP (CAS)",
- "owner": "RunDevelopment"
- },
- "gcode": {
- "title": "G-code",
- "owner": "RunDevelopment"
- },
- "gdscript": {
- "title": "GDScript",
- "owner": "RunDevelopment"
- },
- "gedcom": {
- "title": "GEDCOM",
- "owner": "Golmote"
- },
- "gettext": {
- "title": "gettext",
- "alias": "po",
- "owner": "RunDevelopment"
- },
- "gherkin": {
- "title": "Gherkin",
- "owner": "hason"
- },
- "git": {
- "title": "Git",
- "owner": "lgiraudel"
- },
- "glsl": {
- "title": "GLSL",
- "require": "c",
- "owner": "Golmote"
- },
- "gn": {
- "title": "GN",
- "alias": "gni",
- "owner": "RunDevelopment"
- },
- "linker-script": {
- "title": "GNU Linker Script",
- "alias": "ld",
- "owner": "RunDevelopment"
- },
- "go": {
- "title": "Go",
- "require": "clike",
- "owner": "arnehormann"
- },
- "go-module": {
- "title": "Go module",
- "alias": "go-mod",
- "owner": "RunDevelopment"
- },
- "gradle": {
- "title": "Gradle",
- "require": "clike",
- "owner": "zeabdelkhalek-badido18"
- },
- "graphql": {
- "title": "GraphQL",
- "optional": "markdown",
- "owner": "Golmote"
- },
- "groovy": {
- "title": "Groovy",
- "require": "clike",
- "owner": "robfletcher"
- },
- "haml": {
- "title": "Haml",
- "require": "ruby",
- "optional": [
- "css",
- "css-extras",
- "coffeescript",
- "erb",
- "javascript",
- "less",
- "markdown",
- "scss",
- "textile"
- ],
- "owner": "Golmote"
- },
- "handlebars": {
- "title": "Handlebars",
- "require": "markup-templating",
- "alias": ["hbs", "mustache"],
- "aliasTitles": {
- "mustache": "Mustache"
- },
- "owner": "Golmote"
- },
- "haskell": {
- "title": "Haskell",
- "alias": "hs",
- "owner": "bholst"
- },
- "haxe": {
- "title": "Haxe",
- "require": "clike",
- "optional": "regex",
- "owner": "Golmote"
- },
- "hcl": {
- "title": "HCL",
- "owner": "outsideris"
- },
- "hlsl": {
- "title": "HLSL",
- "require": "c",
- "owner": "RunDevelopment"
- },
- "hoon": {
- "title": "Hoon",
- "owner": "matildepark"
- },
- "http": {
- "title": "HTTP",
- "optional": [
- "csp",
- "css",
- "hpkp",
- "hsts",
- "javascript",
- "json",
- "markup",
- "uri"
- ],
- "owner": "danielgtaylor"
- },
- "hpkp": {
- "title": "HTTP Public-Key-Pins",
- "owner": "ScottHelme"
- },
- "hsts": {
- "title": "HTTP Strict-Transport-Security",
- "owner": "ScottHelme"
- },
- "ichigojam": {
- "title": "IchigoJam",
- "owner": "BlueCocoa"
- },
- "icon": {
- "title": "Icon",
- "owner": "Golmote"
- },
- "icu-message-format": {
- "title": "ICU Message Format",
- "owner": "RunDevelopment"
- },
- "idris": {
- "title": "Idris",
- "alias": "idr",
- "owner": "KeenS",
- "require": "haskell"
- },
- "ignore": {
- "title": ".ignore",
- "owner": "osipxd",
- "alias": [
- "gitignore",
- "hgignore",
- "npmignore"
- ],
- "aliasTitles": {
- "gitignore": ".gitignore",
- "hgignore": ".hgignore",
- "npmignore": ".npmignore"
- }
- },
- "inform7": {
- "title": "Inform 7",
- "owner": "Golmote"
- },
- "ini": {
- "title": "Ini",
- "owner": "aviaryan"
- },
- "io": {
- "title": "Io",
- "owner": "AlesTsurko"
- },
- "j": {
- "title": "J",
- "owner": "Golmote"
- },
- "java": {
- "title": "Java",
- "require": "clike",
- "owner": "sherblot"
- },
- "javadoc": {
- "title": "JavaDoc",
- "require": ["markup", "java", "javadoclike"],
- "modify": "java",
- "optional": "scala",
- "owner": "RunDevelopment"
- },
- "javadoclike": {
- "title": "JavaDoc-like",
- "modify": [
- "java",
- "javascript",
- "php"
- ],
- "owner": "RunDevelopment"
- },
- "javastacktrace": {
- "title": "Java stack trace",
- "owner": "RunDevelopment"
- },
- "jexl": {
- "title": "Jexl",
- "owner": "czosel"
- },
- "jolie": {
- "title": "Jolie",
- "require": "clike",
- "owner": "thesave"
- },
- "jq": {
- "title": "JQ",
- "owner": "RunDevelopment"
- },
- "jsdoc": {
- "title": "JSDoc",
- "require": ["javascript", "javadoclike", "typescript"],
- "modify": "javascript",
- "optional": [
- "actionscript",
- "coffeescript"
- ],
- "owner": "RunDevelopment"
- },
- "js-extras": {
- "title": "JS Extras",
- "require": "javascript",
- "modify": "javascript",
- "optional": [
- "actionscript",
- "coffeescript",
- "flow",
- "n4js",
- "typescript"
- ],
- "owner": "RunDevelopment"
- },
- "json": {
- "title": "JSON",
- "alias": "webmanifest",
- "aliasTitles": {
- "webmanifest": "Web App Manifest"
- },
- "owner": "CupOfTea696"
- },
- "json5": {
- "title": "JSON5",
- "require": "json",
- "owner": "RunDevelopment"
- },
- "jsonp": {
- "title": "JSONP",
- "require": "json",
- "owner": "RunDevelopment"
- },
- "jsstacktrace": {
- "title": "JS stack trace",
- "owner": "sbrl"
- },
- "js-templates": {
- "title": "JS Templates",
- "require": "javascript",
- "modify": "javascript",
- "optional": [
- "css",
- "css-extras",
- "graphql",
- "markdown",
- "markup",
- "sql"
- ],
- "owner": "RunDevelopment"
- },
- "julia": {
- "title": "Julia",
- "owner": "cdagnino"
- },
- "keepalived": {
- "title": "Keepalived Configure",
- "owner": "dev-itsheng"
- },
- "keyman": {
- "title": "Keyman",
- "owner": "mcdurdin"
- },
- "kotlin": {
- "title": "Kotlin",
- "alias": ["kt", "kts"],
- "aliasTitles": {
- "kts": "Kotlin Script"
- },
- "require": "clike",
- "owner": "Golmote"
- },
- "kumir": {
- "title": "KuMir (КуМир)",
- "alias": "kum",
- "owner": "edukisto"
- },
- "kusto": {
- "title": "Kusto",
- "owner": "RunDevelopment"
- },
- "latex": {
- "title": "LaTeX",
- "alias": ["tex", "context"],
- "aliasTitles": {
- "tex": "TeX",
- "context": "ConTeXt"
- },
- "owner": "japborst"
- },
- "latte": {
- "title": "Latte",
- "require": ["clike", "markup-templating", "php"],
- "owner": "nette"
- },
- "less": {
- "title": "Less",
- "require": "css",
- "optional": "css-extras",
- "owner": "Golmote"
- },
- "lilypond": {
- "title": "LilyPond",
- "require": "scheme",
- "alias": "ly",
- "owner": "RunDevelopment"
- },
- "liquid": {
- "title": "Liquid",
- "require": "markup-templating",
- "owner": "cinhtau"
- },
- "lisp": {
- "title": "Lisp",
- "alias": ["emacs", "elisp", "emacs-lisp"],
- "owner": "JuanCaicedo"
- },
- "livescript": {
- "title": "LiveScript",
- "owner": "Golmote"
- },
- "llvm": {
- "title": "LLVM IR",
- "owner": "porglezomp"
- },
- "log": {
- "title": "Log file",
- "optional": "javastacktrace",
- "owner": "RunDevelopment"
- },
- "lolcode": {
- "title": "LOLCODE",
- "owner": "Golmote"
- },
- "lua": {
- "title": "Lua",
- "owner": "Golmote"
- },
- "magma": {
- "title": "Magma (CAS)",
- "owner": "RunDevelopment"
- },
- "makefile": {
- "title": "Makefile",
- "owner": "Golmote"
- },
- "markdown": {
- "title": "Markdown",
- "require": "markup",
- "optional": "yaml",
- "alias": "md",
- "owner": "Golmote"
- },
- "markup-templating": {
- "title": "Markup templating",
- "require": "markup",
- "owner": "Golmote"
- },
- "mata": {
- "title": "Mata",
- "owner": "RunDevelopment"
- },
- "matlab": {
- "title": "MATLAB",
- "owner": "Golmote"
- },
- "maxscript": {
- "title": "MAXScript",
- "owner": "RunDevelopment"
- },
- "mel": {
- "title": "MEL",
- "owner": "Golmote"
- },
- "mermaid": {
- "title": "Mermaid",
- "owner": "RunDevelopment"
- },
- "metafont": {
- "title": "METAFONT",
- "owner": "LaeriExNihilo"
- },
- "mizar": {
- "title": "Mizar",
- "owner": "Golmote"
- },
- "mongodb": {
- "title": "MongoDB",
- "owner": "airs0urce",
- "require": "javascript"
- },
- "monkey": {
- "title": "Monkey",
- "owner": "Golmote"
- },
- "moonscript": {
- "title": "MoonScript",
- "alias": "moon",
- "owner": "RunDevelopment"
- },
- "n1ql": {
- "title": "N1QL",
- "owner": "TMWilds"
- },
- "n4js": {
- "title": "N4JS",
- "require": "javascript",
- "optional": "jsdoc",
- "alias": "n4jsd",
- "owner": "bsmith-n4"
- },
- "nand2tetris-hdl": {
- "title": "Nand To Tetris HDL",
- "owner": "stephanmax"
- },
- "naniscript": {
- "title": "Naninovel Script",
- "owner": "Elringus",
- "alias": "nani"
- },
- "nasm": {
- "title": "NASM",
- "owner": "rbmj"
- },
- "neon": {
- "title": "NEON",
- "owner": "nette"
- },
- "nevod": {
- "title": "Nevod",
- "owner": "nezaboodka"
- },
- "nginx": {
- "title": "nginx",
- "owner": "volado"
- },
- "nim": {
- "title": "Nim",
- "owner": "Golmote"
- },
- "nix": {
- "title": "Nix",
- "owner": "Golmote"
- },
- "nsis": {
- "title": "NSIS",
- "owner": "idleberg"
- },
- "objectivec": {
- "title": "Objective-C",
- "require": "c",
- "alias": "objc",
- "owner": "uranusjr"
- },
- "ocaml": {
- "title": "OCaml",
- "owner": "Golmote"
- },
- "odin": {
- "title": "Odin",
- "owner": "edukisto"
- },
- "opencl": {
- "title": "OpenCL",
- "require": "c",
- "modify": [
- "c",
- "cpp"
- ],
- "owner": "Milania1"
- },
- "openqasm": {
- "title": "OpenQasm",
- "alias": "qasm",
- "owner": "RunDevelopment"
- },
- "oz": {
- "title": "Oz",
- "owner": "Golmote"
- },
- "parigp": {
- "title": "PARI/GP",
- "owner": "Golmote"
- },
- "parser": {
- "title": "Parser",
- "require": "markup",
- "owner": "Golmote"
- },
- "pascal": {
- "title": "Pascal",
- "alias": "objectpascal",
- "aliasTitles": {
- "objectpascal": "Object Pascal"
- },
- "owner": "Golmote"
- },
- "pascaligo": {
- "title": "Pascaligo",
- "owner": "DefinitelyNotAGoat"
- },
- "psl": {
- "title": "PATROL Scripting Language",
- "owner": "bertysentry"
- },
- "pcaxis": {
- "title": "PC-Axis",
- "alias": "px",
- "owner": "RunDevelopment"
- },
- "peoplecode": {
- "title": "PeopleCode",
- "alias": "pcode",
- "owner": "RunDevelopment"
- },
- "perl": {
- "title": "Perl",
- "owner": "Golmote"
- },
- "php": {
- "title": "PHP",
- "require": "markup-templating",
- "owner": "milesj"
- },
- "phpdoc": {
- "title": "PHPDoc",
- "require": ["php", "javadoclike"],
- "modify": "php",
- "owner": "RunDevelopment"
- },
- "php-extras": {
- "title": "PHP Extras",
- "require": "php",
- "modify": "php",
- "owner": "milesj"
- },
- "plant-uml": {
- "title": "PlantUML",
- "alias": "plantuml",
- "owner": "RunDevelopment"
- },
- "plsql": {
- "title": "PL/SQL",
- "require": "sql",
- "owner": "Golmote"
- },
- "powerquery": {
- "title": "PowerQuery",
- "alias": ["pq", "mscript"],
- "owner": "peterbud"
- },
- "powershell": {
- "title": "PowerShell",
- "owner": "nauzilus"
- },
- "processing": {
- "title": "Processing",
- "require": "clike",
- "owner": "Golmote"
- },
- "prolog": {
- "title": "Prolog",
- "owner": "Golmote"
- },
- "promql": {
- "title": "PromQL",
- "owner": "arendjr"
- },
- "properties": {
- "title": ".properties",
- "owner": "Golmote"
- },
- "protobuf": {
- "title": "Protocol Buffers",
- "require": "clike",
- "owner": "just-boris"
- },
- "pug": {
- "title": "Pug",
- "require": ["markup", "javascript"],
- "optional": [
- "coffeescript",
- "ejs",
- "handlebars",
- "less",
- "livescript",
- "markdown",
- "scss",
- "stylus",
- "twig"
- ],
- "owner": "Golmote"
- },
- "puppet": {
- "title": "Puppet",
- "owner": "Golmote"
- },
- "pure": {
- "title": "Pure",
- "optional": [
- "c",
- "cpp",
- "fortran"
- ],
- "owner": "Golmote"
- },
- "purebasic": {
- "title": "PureBasic",
- "require": "clike",
- "alias": "pbfasm",
- "owner": "HeX0R101"
- },
- "purescript": {
- "title": "PureScript",
- "require": "haskell",
- "alias": "purs",
- "owner": "sriharshachilakapati"
- },
- "python": {
- "title": "Python",
- "alias": "py",
- "owner": "multipetros"
- },
- "qsharp": {
- "title": "Q#",
- "require": "clike",
- "alias": "qs",
- "owner": "fedonman"
- },
- "q": {
- "title": "Q (kdb+ database)",
- "owner": "Golmote"
- },
- "qml": {
- "title": "QML",
- "require": "javascript",
- "owner": "RunDevelopment"
- },
- "qore": {
- "title": "Qore",
- "require": "clike",
- "owner": "temnroegg"
- },
- "r": {
- "title": "R",
- "owner": "Golmote"
- },
- "racket": {
- "title": "Racket",
- "require": "scheme",
- "alias": "rkt",
- "owner": "RunDevelopment"
- },
- "cshtml": {
- "title": "Razor C#",
- "alias": "razor",
- "require": ["markup", "csharp"],
- "optional":[
- "css",
- "css-extras",
- "javascript",
- "js-extras"
- ],
- "owner": "RunDevelopment"
- },
- "jsx": {
- "title": "React JSX",
- "require": ["markup", "javascript"],
- "optional": [
- "jsdoc",
- "js-extras",
- "js-templates"
- ],
- "owner": "vkbansal"
- },
- "tsx": {
- "title": "React TSX",
- "require": ["jsx", "typescript"]
- },
- "reason": {
- "title": "Reason",
- "require": "clike",
- "owner": "Golmote"
- },
- "regex": {
- "title": "Regex",
- "owner": "RunDevelopment"
- },
- "rego": {
- "title": "Rego",
- "owner": "JordanSh"
- },
- "renpy": {
- "title": "Ren'py",
- "alias": "rpy",
- "owner": "HyuchiaDiego"
- },
- "rescript": {
- "title": "ReScript",
- "alias": "res",
- "owner": "vmarcosp"
- },
- "rest": {
- "title": "reST (reStructuredText)",
- "owner": "Golmote"
- },
- "rip": {
- "title": "Rip",
- "owner": "ravinggenius"
- },
- "roboconf": {
- "title": "Roboconf",
- "owner": "Golmote"
- },
- "robotframework": {
- "title": "Robot Framework",
- "alias": "robot",
- "owner": "RunDevelopment"
- },
- "ruby": {
- "title": "Ruby",
- "require": "clike",
- "alias": "rb",
- "owner": "samflores"
- },
- "rust": {
- "title": "Rust",
- "owner": "Golmote"
- },
- "sas": {
- "title": "SAS",
- "optional": ["groovy", "lua", "sql"],
- "owner": "Golmote"
- },
- "sass": {
- "title": "Sass (Sass)",
- "require": "css",
- "optional": "css-extras",
- "owner": "Golmote"
- },
- "scss": {
- "title": "Sass (SCSS)",
- "require": "css",
- "optional": "css-extras",
- "owner": "MoOx"
- },
- "scala": {
- "title": "Scala",
- "require": "java",
- "owner": "jozic"
- },
- "scheme": {
- "title": "Scheme",
- "owner": "bacchus123"
- },
- "shell-session": {
- "title": "Shell session",
- "require": "bash",
- "alias": ["sh-session", "shellsession"],
- "owner": "RunDevelopment"
- },
- "smali": {
- "title": "Smali",
- "owner": "RunDevelopment"
- },
- "smalltalk": {
- "title": "Smalltalk",
- "owner": "Golmote"
- },
- "smarty": {
- "title": "Smarty",
- "require": "markup-templating",
- "optional": "php",
- "owner": "Golmote"
- },
- "sml": {
- "title": "SML",
- "alias": "smlnj",
- "aliasTitles": {
- "smlnj": "SML/NJ"
- },
- "owner": "RunDevelopment"
- },
- "solidity": {
- "title": "Solidity (Ethereum)",
- "alias": "sol",
- "require": "clike",
- "owner": "glachaud"
- },
- "solution-file": {
- "title": "Solution file",
- "alias": "sln",
- "owner": "RunDevelopment"
- },
- "soy": {
- "title": "Soy (Closure Template)",
- "require": "markup-templating",
- "owner": "Golmote"
- },
- "sparql": {
- "title": "SPARQL",
- "require": "turtle",
- "owner": "Triply-Dev",
- "alias": "rq"
- },
- "splunk-spl": {
- "title": "Splunk SPL",
- "owner": "RunDevelopment"
- },
- "sqf": {
- "title": "SQF: Status Quo Function (Arma 3)",
- "require": "clike",
- "owner": "RunDevelopment"
- },
- "sql": {
- "title": "SQL",
- "owner": "multipetros"
- },
- "squirrel": {
- "title": "Squirrel",
- "require": "clike",
- "owner": "RunDevelopment"
- },
- "stan": {
- "title": "Stan",
- "owner": "RunDevelopment"
- },
- "stata": {
- "title": "Stata Ado",
- "require": ["mata", "java", "python"],
- "owner": "RunDevelopment"
- },
- "iecst": {
- "title": "Structured Text (IEC 61131-3)",
- "owner": "serhioromano"
- },
- "stylus": {
- "title": "Stylus",
- "owner": "vkbansal"
- },
- "supercollider": {
- "title": "SuperCollider",
- "alias": "sclang",
- "owner": "RunDevelopment"
- },
- "swift": {
- "title": "Swift",
- "owner": "chrischares"
- },
- "systemd": {
- "title": "Systemd configuration file",
- "owner": "RunDevelopment"
- },
- "t4-templating": {
- "title": "T4 templating",
- "owner": "RunDevelopment"
- },
- "t4-cs": {
- "title": "T4 Text Templates (C#)",
- "require": ["t4-templating", "csharp"],
- "alias": "t4",
- "owner": "RunDevelopment"
- },
- "t4-vb": {
- "title": "T4 Text Templates (VB)",
- "require": ["t4-templating", "vbnet"],
- "owner": "RunDevelopment"
- },
- "tap": {
- "title": "TAP",
- "owner": "isaacs",
- "require": "yaml"
- },
- "tcl": {
- "title": "Tcl",
- "owner": "PeterChaplin"
- },
- "tt2": {
- "title": "Template Toolkit 2",
- "require": ["clike", "markup-templating"],
- "owner": "gflohr"
- },
- "textile": {
- "title": "Textile",
- "require": "markup",
- "optional": "css",
- "owner": "Golmote"
- },
- "toml": {
- "title": "TOML",
- "owner": "RunDevelopment"
- },
- "tremor": {
- "title": "Tremor",
- "alias": [
- "trickle",
- "troy"
- ],
- "owner": "darach",
- "aliasTitles": {
- "trickle": "trickle",
- "troy": "troy"
- }
- },
- "turtle": {
- "title": "Turtle",
- "alias": "trig",
- "aliasTitles": {
- "trig": "TriG"
- },
- "owner": "jakubklimek"
- },
- "twig": {
- "title": "Twig",
- "require": "markup-templating",
- "owner": "brandonkelly"
- },
- "typescript": {
- "title": "TypeScript",
- "require": "javascript",
- "optional": "js-templates",
- "alias": "ts",
- "owner": "vkbansal"
- },
- "typoscript": {
- "title": "TypoScript",
- "alias": "tsconfig",
- "aliasTitles": {
- "tsconfig": "TSConfig"
- },
- "owner": "dkern"
- },
- "unrealscript": {
- "title": "UnrealScript",
- "alias": ["uscript", "uc"],
- "owner": "RunDevelopment"
- },
- "uorazor": {
- "title": "UO Razor Script",
- "owner": "jaseowns"
- },
- "uri": {
- "title": "URI",
- "alias": "url",
- "aliasTitles": {
- "url": "URL"
- },
- "owner": "RunDevelopment"
- },
- "v": {
- "title": "V",
- "require": "clike",
- "owner": "taggon"
- },
- "vala": {
- "title": "Vala",
- "require": "clike",
- "optional": "regex",
- "owner": "TemplarVolk"
- },
- "vbnet": {
- "title": "VB.Net",
- "require": "basic",
- "owner": "Bigsby"
- },
- "velocity": {
- "title": "Velocity",
- "require": "markup",
- "owner": "Golmote"
- },
- "verilog": {
- "title": "Verilog",
- "owner": "a-rey"
- },
- "vhdl": {
- "title": "VHDL",
- "owner": "a-rey"
- },
- "vim": {
- "title": "vim",
- "owner": "westonganger"
- },
- "visual-basic": {
- "title": "Visual Basic",
- "alias": ["vb", "vba"],
- "aliasTitles": {
- "vba": "VBA"
- },
- "owner": "Golmote"
- },
- "warpscript": {
- "title": "WarpScript",
- "owner": "RunDevelopment"
- },
- "wasm": {
- "title": "WebAssembly",
- "owner": "Golmote"
- },
- "web-idl": {
- "title": "Web IDL",
- "alias": "webidl",
- "owner": "RunDevelopment"
- },
- "wgsl": {
- "title": "WGSL",
- "owner": "Dr4gonthree"
- },
- "wiki": {
- "title": "Wiki markup",
- "require": "markup",
- "owner": "Golmote"
- },
- "wolfram": {
- "title": "Wolfram language",
- "alias": ["mathematica", "nb", "wl"],
- "aliasTitles": {
- "mathematica": "Mathematica",
- "nb": "Mathematica Notebook"
- },
- "owner": "msollami"
- },
- "wren": {
- "title": "Wren",
- "owner": "clsource"
- },
- "xeora": {
- "title": "Xeora",
- "require": "markup",
- "alias": "xeoracube",
- "aliasTitles": {
- "xeoracube": "XeoraCube"
- },
- "owner": "freakmaxi"
- },
- "xml-doc": {
- "title": "XML doc (.net)",
- "require": "markup",
- "modify": ["csharp", "fsharp", "vbnet"],
- "owner": "RunDevelopment"
- },
- "xojo": {
- "title": "Xojo (REALbasic)",
- "owner": "Golmote"
- },
- "xquery": {
- "title": "XQuery",
- "require": "markup",
- "owner": "Golmote"
- },
- "yaml": {
- "title": "YAML",
- "alias": "yml",
- "owner": "hason"
- },
- "yang": {
- "title": "YANG",
- "owner": "RunDevelopment"
- },
- "zig": {
- "title": "Zig",
- "owner": "RunDevelopment"
- }
- },
- "plugins": {
- "meta": {
- "path": "plugins/{id}/prism-{id}",
- "link": "plugins/{id}/"
- },
- "line-highlight": {
- "title": "Line Highlight",
- "description": "Highlights specific lines and/or line ranges."
- },
- "line-numbers": {
- "title": "Line Numbers",
- "description": "Line number at the beginning of code lines.",
- "owner": "kuba-kubula"
- },
- "show-invisibles": {
- "title": "Show Invisibles",
- "description": "Show hidden characters such as tabs and line breaks.",
- "optional": [
- "autolinker",
- "data-uri-highlight"
- ]
- },
- "autolinker": {
- "title": "Autolinker",
- "description": "Converts URLs and emails in code to clickable links. Parses Markdown links in comments."
- },
- "wpd": {
- "title": "WebPlatform Docs",
- "description": "Makes tokens link to WebPlatform.org documentation. The links open in a new tab."
- },
- "custom-class": {
- "title": "Custom Class",
- "description": "This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.",
- "owner": "dvkndn",
- "noCSS": true
- },
- "file-highlight": {
- "title": "File Highlight",
- "description": "Fetch external files and highlight them with Prism. Used on the Prism website itself.",
- "noCSS": true
- },
- "show-language": {
- "title": "Show Language",
- "description": "Display the highlighted language in code blocks (inline code does not show the label).",
- "owner": "nauzilus",
- "noCSS": true,
- "require": "toolbar"
- },
- "jsonp-highlight": {
- "title": "JSONP Highlight",
- "description": "Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).",
- "noCSS": true,
- "owner": "nauzilus"
- },
- "highlight-keywords": {
- "title": "Highlight Keywords",
- "description": "Adds special CSS classes for each keyword for fine-grained highlighting.",
- "owner": "vkbansal",
- "noCSS": true
- },
- "remove-initial-line-feed": {
- "title": "Remove initial line feed",
- "description": "Removes the initial line feed in code blocks.",
- "owner": "Golmote",
- "noCSS": true
- },
- "inline-color": {
- "title": "Inline color",
- "description": "Adds a small inline preview for colors in style sheets.",
- "require": "css-extras",
- "owner": "RunDevelopment"
- },
- "previewers": {
- "title": "Previewers",
- "description": "Previewers for angles, colors, gradients, easing and time.",
- "require": "css-extras",
- "owner": "Golmote"
- },
- "autoloader": {
- "title": "Autoloader",
- "description": "Automatically loads the needed languages to highlight the code blocks.",
- "owner": "Golmote",
- "noCSS": true
- },
- "keep-markup": {
- "title": "Keep Markup",
- "description": "Prevents custom markup from being dropped out during highlighting.",
- "owner": "Golmote",
- "optional": "normalize-whitespace",
- "noCSS": true
- },
- "command-line": {
- "title": "Command Line",
- "description": "Display a command line with a prompt and, optionally, the output/response from the commands.",
- "owner": "chriswells0"
- },
- "unescaped-markup": {
- "title": "Unescaped Markup",
- "description": "Write markup without having to escape anything."
- },
- "normalize-whitespace": {
- "title": "Normalize Whitespace",
- "description": "Supports multiple operations to normalize whitespace in code blocks.",
- "owner": "zeitgeist87",
- "optional": "unescaped-markup",
- "noCSS": true
- },
- "data-uri-highlight": {
- "title": "Data-URI Highlight",
- "description": "Highlights data-URI contents.",
- "owner": "Golmote",
- "noCSS": true
- },
- "toolbar": {
- "title": "Toolbar",
- "description": "Attach a toolbar for plugins to easily register buttons on the top of a code block.",
- "owner": "mAAdhaTTah"
- },
- "copy-to-clipboard": {
- "title": "Copy to Clipboard Button",
- "description": "Add a button that copies the code block to the clipboard when clicked.",
- "owner": "mAAdhaTTah",
- "require": "toolbar",
- "noCSS": true
- },
- "download-button": {
- "title": "Download Button",
- "description": "A button in the toolbar of a code block adding a convenient way to download a code file.",
- "owner": "Golmote",
- "require": "toolbar",
- "noCSS": true
- },
- "match-braces": {
- "title": "Match braces",
- "description": "Highlights matching braces.",
- "owner": "RunDevelopment"
- },
- "diff-highlight": {
- "title": "Diff Highlight",
- "description": "Highlights the code inside diff blocks.",
- "owner": "RunDevelopment",
- "require": "diff"
- },
- "filter-highlight-all": {
- "title": "Filter highlightAll",
- "description": "Filters the elements the highlightAll and highlightAllUnder methods actually highlight.",
- "owner": "RunDevelopment",
- "noCSS": true
- },
- "treeview": {
- "title": "Treeview",
- "description": "A language with special styles to highlight file system tree structures.",
- "owner": "Golmote"
- }
- }
-}
\ No newline at end of file
+ "core": {
+ "meta": {
+ "path": "components/prism-core.js",
+ "option": "mandatory"
+ },
+ "core": "Core"
+ },
+ "themes": {
+ "meta": {
+ "path": "themes/{id}.css",
+ "link": "index.html?theme={id}",
+ "exclusive": true
+ },
+ "prism": {
+ "title": "Default",
+ "option": "default"
+ },
+ "prism-dark": "Dark",
+ "prism-funky": "Funky",
+ "prism-okaidia": {
+ "title": "Okaidia",
+ "owner": "ocodia"
+ },
+ "prism-twilight": {
+ "title": "Twilight",
+ "owner": "remybach"
+ },
+ "prism-coy": {
+ "title": "Coy",
+ "owner": "tshedor"
+ },
+ "prism-solarizedlight": {
+ "title": "Solarized Light",
+ "owner": "hectormatos2011 "
+ },
+ "prism-tomorrow": {
+ "title": "Tomorrow Night",
+ "owner": "Rosey"
+ }
+ },
+ "languages": {
+ "meta": {
+ "path": "components/prism-{id}",
+ "noCSS": true,
+ "examplesPath": "examples/prism-{id}",
+ "addCheckAll": true
+ },
+ "markup": {
+ "title": "Markup",
+ "alias": ["html", "xml", "svg", "mathml", "ssml", "atom", "rss"],
+ "aliasTitles": {
+ "html": "HTML",
+ "xml": "XML",
+ "svg": "SVG",
+ "mathml": "MathML",
+ "ssml": "SSML",
+ "atom": "Atom",
+ "rss": "RSS"
+ },
+ "option": "default"
+ },
+ "css": {
+ "title": "CSS",
+ "option": "default",
+ "modify": "markup"
+ },
+ "clike": {
+ "title": "C-like",
+ "option": "default"
+ },
+ "javascript": {
+ "title": "JavaScript",
+ "require": "clike",
+ "modify": "markup",
+ "optional": "regex",
+ "alias": "js",
+ "option": "default"
+ },
+ "abap": {
+ "title": "ABAP",
+ "owner": "dellagustin"
+ },
+ "abnf": {
+ "title": "ABNF",
+ "owner": "RunDevelopment"
+ },
+ "actionscript": {
+ "title": "ActionScript",
+ "require": "javascript",
+ "modify": "markup",
+ "owner": "Golmote"
+ },
+ "ada": {
+ "title": "Ada",
+ "owner": "Lucretia"
+ },
+ "agda": {
+ "title": "Agda",
+ "owner": "xy-ren"
+ },
+ "al": {
+ "title": "AL",
+ "owner": "RunDevelopment"
+ },
+ "antlr4": {
+ "title": "ANTLR4",
+ "alias": "g4",
+ "owner": "RunDevelopment"
+ },
+ "apacheconf": {
+ "title": "Apache Configuration",
+ "owner": "GuiTeK"
+ },
+ "apex": {
+ "title": "Apex",
+ "require": ["clike", "sql"],
+ "owner": "RunDevelopment"
+ },
+ "apl": {
+ "title": "APL",
+ "owner": "ngn"
+ },
+ "applescript": {
+ "title": "AppleScript",
+ "owner": "Golmote"
+ },
+ "aql": {
+ "title": "AQL",
+ "owner": "RunDevelopment"
+ },
+ "arduino": {
+ "title": "Arduino",
+ "require": "cpp",
+ "alias": "ino",
+ "owner": "dkern"
+ },
+ "arff": {
+ "title": "ARFF",
+ "owner": "Golmote"
+ },
+ "armasm": {
+ "title": "ARM Assembly",
+ "alias": "arm-asm",
+ "owner": "RunDevelopment"
+ },
+ "arturo": {
+ "title": "Arturo",
+ "alias": "art",
+ "optional": ["bash", "css", "javascript", "markup", "markdown", "sql"],
+ "owner": "drkameleon"
+ },
+ "asciidoc": {
+ "alias": "adoc",
+ "title": "AsciiDoc",
+ "owner": "Golmote"
+ },
+ "aspnet": {
+ "title": "ASP.NET (C#)",
+ "require": ["markup", "csharp"],
+ "owner": "nauzilus"
+ },
+ "asm6502": {
+ "title": "6502 Assembly",
+ "owner": "kzurawel"
+ },
+ "asmatmel": {
+ "title": "Atmel AVR Assembly",
+ "owner": "cerkit"
+ },
+ "autohotkey": {
+ "title": "AutoHotkey",
+ "owner": "aviaryan"
+ },
+ "autoit": {
+ "title": "AutoIt",
+ "owner": "Golmote"
+ },
+ "avisynth": {
+ "title": "AviSynth",
+ "alias": "avs",
+ "owner": "Zinfidel"
+ },
+ "avro-idl": {
+ "title": "Avro IDL",
+ "alias": "avdl",
+ "owner": "RunDevelopment"
+ },
+ "awk": {
+ "title": "AWK",
+ "alias": "gawk",
+ "aliasTitles": {
+ "gawk": "GAWK"
+ },
+ "owner": "RunDevelopment"
+ },
+ "bash": {
+ "title": "Bash",
+ "alias": ["sh", "shell"],
+ "aliasTitles": {
+ "sh": "Shell",
+ "shell": "Shell"
+ },
+ "owner": "zeitgeist87"
+ },
+ "basic": {
+ "title": "BASIC",
+ "owner": "Golmote"
+ },
+ "batch": {
+ "title": "Batch",
+ "owner": "Golmote"
+ },
+ "bbcode": {
+ "title": "BBcode",
+ "alias": "shortcode",
+ "aliasTitles": {
+ "shortcode": "Shortcode"
+ },
+ "owner": "RunDevelopment"
+ },
+ "bbj": {
+ "title": "BBj",
+ "owner": "hyyan"
+ },
+ "bicep": {
+ "title": "Bicep",
+ "owner": "johnnyreilly"
+ },
+ "birb": {
+ "title": "Birb",
+ "require": "clike",
+ "owner": "Calamity210"
+ },
+ "bison": {
+ "title": "Bison",
+ "require": "c",
+ "owner": "Golmote"
+ },
+ "bnf": {
+ "title": "BNF",
+ "alias": "rbnf",
+ "aliasTitles": {
+ "rbnf": "RBNF"
+ },
+ "owner": "RunDevelopment"
+ },
+ "bqn": {
+ "title": "BQN",
+ "owner": "yewscion"
+ },
+ "brainfuck": {
+ "title": "Brainfuck",
+ "owner": "Golmote"
+ },
+ "brightscript": {
+ "title": "BrightScript",
+ "owner": "RunDevelopment"
+ },
+ "bro": {
+ "title": "Bro",
+ "owner": "wayward710"
+ },
+ "bsl": {
+ "title": "BSL (1C:Enterprise)",
+ "alias": "oscript",
+ "aliasTitles": {
+ "oscript": "OneScript"
+ },
+ "owner": "Diversus23"
+ },
+ "c": {
+ "title": "C",
+ "require": "clike",
+ "owner": "zeitgeist87"
+ },
+ "csharp": {
+ "title": "C#",
+ "require": "clike",
+ "alias": ["cs", "dotnet"],
+ "owner": "mvalipour"
+ },
+ "cpp": {
+ "title": "C++",
+ "require": "c",
+ "owner": "zeitgeist87"
+ },
+ "cfscript": {
+ "title": "CFScript",
+ "require": "clike",
+ "alias": "cfc",
+ "owner": "mjclemente"
+ },
+ "chaiscript": {
+ "title": "ChaiScript",
+ "require": ["clike", "cpp"],
+ "owner": "RunDevelopment"
+ },
+ "cil": {
+ "title": "CIL",
+ "owner": "sbrl"
+ },
+ "cilkc": {
+ "title": "Cilk/C",
+ "require": "c",
+ "alias": "cilk-c",
+ "owner": "OpenCilk"
+ },
+ "cilkcpp": {
+ "title": "Cilk/C++",
+ "require": "cpp",
+ "alias": ["cilk-cpp", "cilk"],
+ "owner": "OpenCilk"
+ },
+ "clojure": {
+ "title": "Clojure",
+ "owner": "troglotit"
+ },
+ "cmake": {
+ "title": "CMake",
+ "owner": "mjrogozinski"
+ },
+ "cobol": {
+ "title": "COBOL",
+ "owner": "RunDevelopment"
+ },
+ "coffeescript": {
+ "title": "CoffeeScript",
+ "require": "javascript",
+ "alias": "coffee",
+ "owner": "R-osey"
+ },
+ "concurnas": {
+ "title": "Concurnas",
+ "alias": "conc",
+ "owner": "jasontatton"
+ },
+ "csp": {
+ "title": "Content-Security-Policy",
+ "owner": "ScottHelme"
+ },
+ "cooklang": {
+ "title": "Cooklang",
+ "owner": "ahue"
+ },
+ "coq": {
+ "title": "Coq",
+ "owner": "RunDevelopment"
+ },
+ "crystal": {
+ "title": "Crystal",
+ "require": "ruby",
+ "owner": "MakeNowJust"
+ },
+ "css-extras": {
+ "title": "CSS Extras",
+ "require": "css",
+ "modify": "css",
+ "owner": "milesj"
+ },
+ "csv": {
+ "title": "CSV",
+ "owner": "RunDevelopment"
+ },
+ "cue": {
+ "title": "CUE",
+ "owner": "RunDevelopment"
+ },
+ "cypher": {
+ "title": "Cypher",
+ "owner": "RunDevelopment"
+ },
+ "d": {
+ "title": "D",
+ "require": "clike",
+ "owner": "Golmote"
+ },
+ "dart": {
+ "title": "Dart",
+ "require": "clike",
+ "owner": "Golmote"
+ },
+ "dataweave": {
+ "title": "DataWeave",
+ "owner": "machaval"
+ },
+ "dax": {
+ "title": "DAX",
+ "owner": "peterbud"
+ },
+ "dhall": {
+ "title": "Dhall",
+ "owner": "RunDevelopment"
+ },
+ "diff": {
+ "title": "Diff",
+ "owner": "uranusjr"
+ },
+ "django": {
+ "title": "Django/Jinja2",
+ "require": "markup-templating",
+ "alias": "jinja2",
+ "owner": "romanvm"
+ },
+ "dns-zone-file": {
+ "title": "DNS zone file",
+ "owner": "RunDevelopment",
+ "alias": "dns-zone"
+ },
+ "docker": {
+ "title": "Docker",
+ "alias": "dockerfile",
+ "owner": "JustinBeckwith"
+ },
+ "dot": {
+ "title": "DOT (Graphviz)",
+ "alias": "gv",
+ "optional": "markup",
+ "owner": "RunDevelopment"
+ },
+ "ebnf": {
+ "title": "EBNF",
+ "owner": "RunDevelopment"
+ },
+ "editorconfig": {
+ "title": "EditorConfig",
+ "owner": "osipxd"
+ },
+ "eiffel": {
+ "title": "Eiffel",
+ "owner": "Conaclos"
+ },
+ "ejs": {
+ "title": "EJS",
+ "require": ["javascript", "markup-templating"],
+ "owner": "RunDevelopment",
+ "alias": "eta",
+ "aliasTitles": {
+ "eta": "Eta"
+ }
+ },
+ "elixir": {
+ "title": "Elixir",
+ "owner": "Golmote"
+ },
+ "elm": {
+ "title": "Elm",
+ "owner": "zwilias"
+ },
+ "etlua": {
+ "title": "Embedded Lua templating",
+ "require": ["lua", "markup-templating"],
+ "owner": "RunDevelopment"
+ },
+ "erb": {
+ "title": "ERB",
+ "require": ["ruby", "markup-templating"],
+ "owner": "Golmote"
+ },
+ "erlang": {
+ "title": "Erlang",
+ "owner": "Golmote"
+ },
+ "excel-formula": {
+ "title": "Excel Formula",
+ "alias": ["xlsx", "xls"],
+ "owner": "RunDevelopment"
+ },
+ "fsharp": {
+ "title": "F#",
+ "require": "clike",
+ "owner": "simonreynolds7"
+ },
+ "factor": {
+ "title": "Factor",
+ "owner": "catb0t"
+ },
+ "false": {
+ "title": "False",
+ "owner": "edukisto"
+ },
+ "firestore-security-rules": {
+ "title": "Firestore security rules",
+ "require": "clike",
+ "owner": "RunDevelopment"
+ },
+ "flow": {
+ "title": "Flow",
+ "require": "javascript",
+ "owner": "Golmote"
+ },
+ "fortran": {
+ "title": "Fortran",
+ "owner": "Golmote"
+ },
+ "ftl": {
+ "title": "FreeMarker Template Language",
+ "require": "markup-templating",
+ "owner": "RunDevelopment"
+ },
+ "gml": {
+ "title": "GameMaker Language",
+ "alias": "gamemakerlanguage",
+ "require": "clike",
+ "owner": "LiarOnce"
+ },
+ "gap": {
+ "title": "GAP (CAS)",
+ "owner": "RunDevelopment"
+ },
+ "gcode": {
+ "title": "G-code",
+ "owner": "RunDevelopment"
+ },
+ "gdscript": {
+ "title": "GDScript",
+ "owner": "RunDevelopment"
+ },
+ "gedcom": {
+ "title": "GEDCOM",
+ "owner": "Golmote"
+ },
+ "gettext": {
+ "title": "gettext",
+ "alias": "po",
+ "owner": "RunDevelopment"
+ },
+ "gherkin": {
+ "title": "Gherkin",
+ "owner": "hason"
+ },
+ "git": {
+ "title": "Git",
+ "owner": "lgiraudel"
+ },
+ "glsl": {
+ "title": "GLSL",
+ "require": "c",
+ "owner": "Golmote"
+ },
+ "gn": {
+ "title": "GN",
+ "alias": "gni",
+ "owner": "RunDevelopment"
+ },
+ "linker-script": {
+ "title": "GNU Linker Script",
+ "alias": "ld",
+ "owner": "RunDevelopment"
+ },
+ "go": {
+ "title": "Go",
+ "require": "clike",
+ "owner": "arnehormann"
+ },
+ "go-module": {
+ "title": "Go module",
+ "alias": "go-mod",
+ "owner": "RunDevelopment"
+ },
+ "gradle": {
+ "title": "Gradle",
+ "require": "clike",
+ "owner": "zeabdelkhalek-badido18"
+ },
+ "graphql": {
+ "title": "GraphQL",
+ "optional": "markdown",
+ "owner": "Golmote"
+ },
+ "groovy": {
+ "title": "Groovy",
+ "require": "clike",
+ "owner": "robfletcher"
+ },
+ "haml": {
+ "title": "Haml",
+ "require": "ruby",
+ "optional": [
+ "css",
+ "css-extras",
+ "coffeescript",
+ "erb",
+ "javascript",
+ "less",
+ "markdown",
+ "scss",
+ "textile"
+ ],
+ "owner": "Golmote"
+ },
+ "handlebars": {
+ "title": "Handlebars",
+ "require": "markup-templating",
+ "alias": ["hbs", "mustache"],
+ "aliasTitles": {
+ "mustache": "Mustache"
+ },
+ "owner": "Golmote"
+ },
+ "haskell": {
+ "title": "Haskell",
+ "alias": "hs",
+ "owner": "bholst"
+ },
+ "haxe": {
+ "title": "Haxe",
+ "require": "clike",
+ "optional": "regex",
+ "owner": "Golmote"
+ },
+ "hcl": {
+ "title": "HCL",
+ "owner": "outsideris"
+ },
+ "hlsl": {
+ "title": "HLSL",
+ "require": "c",
+ "owner": "RunDevelopment"
+ },
+ "hoon": {
+ "title": "Hoon",
+ "owner": "matildepark"
+ },
+ "http": {
+ "title": "HTTP",
+ "optional": [
+ "csp",
+ "css",
+ "hpkp",
+ "hsts",
+ "javascript",
+ "json",
+ "markup",
+ "uri"
+ ],
+ "owner": "danielgtaylor"
+ },
+ "hpkp": {
+ "title": "HTTP Public-Key-Pins",
+ "owner": "ScottHelme"
+ },
+ "hsts": {
+ "title": "HTTP Strict-Transport-Security",
+ "owner": "ScottHelme"
+ },
+ "ichigojam": {
+ "title": "IchigoJam",
+ "owner": "BlueCocoa"
+ },
+ "icon": {
+ "title": "Icon",
+ "owner": "Golmote"
+ },
+ "icu-message-format": {
+ "title": "ICU Message Format",
+ "owner": "RunDevelopment"
+ },
+ "idris": {
+ "title": "Idris",
+ "alias": "idr",
+ "owner": "KeenS",
+ "require": "haskell"
+ },
+ "ignore": {
+ "title": ".ignore",
+ "owner": "osipxd",
+ "alias": ["gitignore", "hgignore", "npmignore"],
+ "aliasTitles": {
+ "gitignore": ".gitignore",
+ "hgignore": ".hgignore",
+ "npmignore": ".npmignore"
+ }
+ },
+ "inform7": {
+ "title": "Inform 7",
+ "owner": "Golmote"
+ },
+ "ini": {
+ "title": "Ini",
+ "owner": "aviaryan"
+ },
+ "io": {
+ "title": "Io",
+ "owner": "AlesTsurko"
+ },
+ "j": {
+ "title": "J",
+ "owner": "Golmote"
+ },
+ "java": {
+ "title": "Java",
+ "require": "clike",
+ "owner": "sherblot"
+ },
+ "javadoc": {
+ "title": "JavaDoc",
+ "require": ["markup", "java", "javadoclike"],
+ "modify": "java",
+ "optional": "scala",
+ "owner": "RunDevelopment"
+ },
+ "javadoclike": {
+ "title": "JavaDoc-like",
+ "modify": ["java", "javascript", "php"],
+ "owner": "RunDevelopment"
+ },
+ "javastacktrace": {
+ "title": "Java stack trace",
+ "owner": "RunDevelopment"
+ },
+ "jexl": {
+ "title": "Jexl",
+ "owner": "czosel"
+ },
+ "jolie": {
+ "title": "Jolie",
+ "require": "clike",
+ "owner": "thesave"
+ },
+ "jq": {
+ "title": "JQ",
+ "owner": "RunDevelopment"
+ },
+ "jsdoc": {
+ "title": "JSDoc",
+ "require": ["javascript", "javadoclike", "typescript"],
+ "modify": "javascript",
+ "optional": ["actionscript", "coffeescript"],
+ "owner": "RunDevelopment"
+ },
+ "js-extras": {
+ "title": "JS Extras",
+ "require": "javascript",
+ "modify": "javascript",
+ "optional": [
+ "actionscript",
+ "coffeescript",
+ "flow",
+ "n4js",
+ "typescript"
+ ],
+ "owner": "RunDevelopment"
+ },
+ "json": {
+ "title": "JSON",
+ "alias": "webmanifest",
+ "aliasTitles": {
+ "webmanifest": "Web App Manifest"
+ },
+ "owner": "CupOfTea696"
+ },
+ "json5": {
+ "title": "JSON5",
+ "require": "json",
+ "owner": "RunDevelopment"
+ },
+ "jsonp": {
+ "title": "JSONP",
+ "require": "json",
+ "owner": "RunDevelopment"
+ },
+ "jsstacktrace": {
+ "title": "JS stack trace",
+ "owner": "sbrl"
+ },
+ "js-templates": {
+ "title": "JS Templates",
+ "require": "javascript",
+ "modify": "javascript",
+ "optional": ["css", "css-extras", "graphql", "markdown", "markup", "sql"],
+ "owner": "RunDevelopment"
+ },
+ "julia": {
+ "title": "Julia",
+ "owner": "cdagnino"
+ },
+ "keepalived": {
+ "title": "Keepalived Configure",
+ "owner": "dev-itsheng"
+ },
+ "keyman": {
+ "title": "Keyman",
+ "owner": "mcdurdin"
+ },
+ "kotlin": {
+ "title": "Kotlin",
+ "alias": ["kt", "kts"],
+ "aliasTitles": {
+ "kts": "Kotlin Script"
+ },
+ "require": "clike",
+ "owner": "Golmote"
+ },
+ "kumir": {
+ "title": "KuMir (КуМир)",
+ "alias": "kum",
+ "owner": "edukisto"
+ },
+ "kusto": {
+ "title": "Kusto",
+ "owner": "RunDevelopment"
+ },
+ "latex": {
+ "title": "LaTeX",
+ "alias": ["tex", "context"],
+ "aliasTitles": {
+ "tex": "TeX",
+ "context": "ConTeXt"
+ },
+ "owner": "japborst"
+ },
+ "latte": {
+ "title": "Latte",
+ "require": ["clike", "markup-templating", "php"],
+ "owner": "nette"
+ },
+ "less": {
+ "title": "Less",
+ "require": "css",
+ "optional": "css-extras",
+ "owner": "Golmote"
+ },
+ "lilypond": {
+ "title": "LilyPond",
+ "require": "scheme",
+ "alias": "ly",
+ "owner": "RunDevelopment"
+ },
+ "liquid": {
+ "title": "Liquid",
+ "require": "markup-templating",
+ "owner": "cinhtau"
+ },
+ "lisp": {
+ "title": "Lisp",
+ "alias": ["emacs", "elisp", "emacs-lisp"],
+ "owner": "JuanCaicedo"
+ },
+ "livescript": {
+ "title": "LiveScript",
+ "owner": "Golmote"
+ },
+ "llvm": {
+ "title": "LLVM IR",
+ "owner": "porglezomp"
+ },
+ "log": {
+ "title": "Log file",
+ "optional": "javastacktrace",
+ "owner": "RunDevelopment"
+ },
+ "lolcode": {
+ "title": "LOLCODE",
+ "owner": "Golmote"
+ },
+ "lua": {
+ "title": "Lua",
+ "owner": "Golmote"
+ },
+ "magma": {
+ "title": "Magma (CAS)",
+ "owner": "RunDevelopment"
+ },
+ "makefile": {
+ "title": "Makefile",
+ "owner": "Golmote"
+ },
+ "markdown": {
+ "title": "Markdown",
+ "require": "markup",
+ "optional": "yaml",
+ "alias": "md",
+ "owner": "Golmote"
+ },
+ "markup-templating": {
+ "title": "Markup templating",
+ "require": "markup",
+ "owner": "Golmote"
+ },
+ "mata": {
+ "title": "Mata",
+ "owner": "RunDevelopment"
+ },
+ "matlab": {
+ "title": "MATLAB",
+ "owner": "Golmote"
+ },
+ "maxscript": {
+ "title": "MAXScript",
+ "owner": "RunDevelopment"
+ },
+ "mel": {
+ "title": "MEL",
+ "owner": "Golmote"
+ },
+ "mermaid": {
+ "title": "Mermaid",
+ "owner": "RunDevelopment"
+ },
+ "metafont": {
+ "title": "METAFONT",
+ "owner": "LaeriExNihilo"
+ },
+ "mizar": {
+ "title": "Mizar",
+ "owner": "Golmote"
+ },
+ "mongodb": {
+ "title": "MongoDB",
+ "owner": "airs0urce",
+ "require": "javascript"
+ },
+ "monkey": {
+ "title": "Monkey",
+ "owner": "Golmote"
+ },
+ "moonscript": {
+ "title": "MoonScript",
+ "alias": "moon",
+ "owner": "RunDevelopment"
+ },
+ "n1ql": {
+ "title": "N1QL",
+ "owner": "TMWilds"
+ },
+ "n4js": {
+ "title": "N4JS",
+ "require": "javascript",
+ "optional": "jsdoc",
+ "alias": "n4jsd",
+ "owner": "bsmith-n4"
+ },
+ "nand2tetris-hdl": {
+ "title": "Nand To Tetris HDL",
+ "owner": "stephanmax"
+ },
+ "naniscript": {
+ "title": "Naninovel Script",
+ "owner": "Elringus",
+ "alias": "nani"
+ },
+ "nasm": {
+ "title": "NASM",
+ "owner": "rbmj"
+ },
+ "neon": {
+ "title": "NEON",
+ "owner": "nette"
+ },
+ "nevod": {
+ "title": "Nevod",
+ "owner": "nezaboodka"
+ },
+ "nginx": {
+ "title": "nginx",
+ "owner": "volado"
+ },
+ "nim": {
+ "title": "Nim",
+ "owner": "Golmote"
+ },
+ "nix": {
+ "title": "Nix",
+ "owner": "Golmote"
+ },
+ "nsis": {
+ "title": "NSIS",
+ "owner": "idleberg"
+ },
+ "objectivec": {
+ "title": "Objective-C",
+ "require": "c",
+ "alias": "objc",
+ "owner": "uranusjr"
+ },
+ "ocaml": {
+ "title": "OCaml",
+ "owner": "Golmote"
+ },
+ "odin": {
+ "title": "Odin",
+ "owner": "edukisto"
+ },
+ "opencl": {
+ "title": "OpenCL",
+ "require": "c",
+ "modify": ["c", "cpp"],
+ "owner": "Milania1"
+ },
+ "openqasm": {
+ "title": "OpenQasm",
+ "alias": "qasm",
+ "owner": "RunDevelopment"
+ },
+ "oz": {
+ "title": "Oz",
+ "owner": "Golmote"
+ },
+ "parigp": {
+ "title": "PARI/GP",
+ "owner": "Golmote"
+ },
+ "parser": {
+ "title": "Parser",
+ "require": "markup",
+ "owner": "Golmote"
+ },
+ "pascal": {
+ "title": "Pascal",
+ "alias": "objectpascal",
+ "aliasTitles": {
+ "objectpascal": "Object Pascal"
+ },
+ "owner": "Golmote"
+ },
+ "pascaligo": {
+ "title": "Pascaligo",
+ "owner": "DefinitelyNotAGoat"
+ },
+ "psl": {
+ "title": "PATROL Scripting Language",
+ "owner": "bertysentry"
+ },
+ "pcaxis": {
+ "title": "PC-Axis",
+ "alias": "px",
+ "owner": "RunDevelopment"
+ },
+ "peoplecode": {
+ "title": "PeopleCode",
+ "alias": "pcode",
+ "owner": "RunDevelopment"
+ },
+ "perl": {
+ "title": "Perl",
+ "owner": "Golmote"
+ },
+ "php": {
+ "title": "PHP",
+ "require": "markup-templating",
+ "owner": "milesj"
+ },
+ "phpdoc": {
+ "title": "PHPDoc",
+ "require": ["php", "javadoclike"],
+ "modify": "php",
+ "owner": "RunDevelopment"
+ },
+ "php-extras": {
+ "title": "PHP Extras",
+ "require": "php",
+ "modify": "php",
+ "owner": "milesj"
+ },
+ "plant-uml": {
+ "title": "PlantUML",
+ "alias": "plantuml",
+ "owner": "RunDevelopment"
+ },
+ "plsql": {
+ "title": "PL/SQL",
+ "require": "sql",
+ "owner": "Golmote"
+ },
+ "powerquery": {
+ "title": "PowerQuery",
+ "alias": ["pq", "mscript"],
+ "owner": "peterbud"
+ },
+ "powershell": {
+ "title": "PowerShell",
+ "owner": "nauzilus"
+ },
+ "processing": {
+ "title": "Processing",
+ "require": "clike",
+ "owner": "Golmote"
+ },
+ "prolog": {
+ "title": "Prolog",
+ "owner": "Golmote"
+ },
+ "promql": {
+ "title": "PromQL",
+ "owner": "arendjr"
+ },
+ "properties": {
+ "title": ".properties",
+ "owner": "Golmote"
+ },
+ "protobuf": {
+ "title": "Protocol Buffers",
+ "require": "clike",
+ "owner": "just-boris"
+ },
+ "pug": {
+ "title": "Pug",
+ "require": ["markup", "javascript"],
+ "optional": [
+ "coffeescript",
+ "ejs",
+ "handlebars",
+ "less",
+ "livescript",
+ "markdown",
+ "scss",
+ "stylus",
+ "twig"
+ ],
+ "owner": "Golmote"
+ },
+ "puppet": {
+ "title": "Puppet",
+ "owner": "Golmote"
+ },
+ "pure": {
+ "title": "Pure",
+ "optional": ["c", "cpp", "fortran"],
+ "owner": "Golmote"
+ },
+ "purebasic": {
+ "title": "PureBasic",
+ "require": "clike",
+ "alias": "pbfasm",
+ "owner": "HeX0R101"
+ },
+ "purescript": {
+ "title": "PureScript",
+ "require": "haskell",
+ "alias": "purs",
+ "owner": "sriharshachilakapati"
+ },
+ "python": {
+ "title": "Python",
+ "alias": "py",
+ "owner": "multipetros"
+ },
+ "qsharp": {
+ "title": "Q#",
+ "require": "clike",
+ "alias": "qs",
+ "owner": "fedonman"
+ },
+ "q": {
+ "title": "Q (kdb+ database)",
+ "owner": "Golmote"
+ },
+ "qml": {
+ "title": "QML",
+ "require": "javascript",
+ "owner": "RunDevelopment"
+ },
+ "qore": {
+ "title": "Qore",
+ "require": "clike",
+ "owner": "temnroegg"
+ },
+ "r": {
+ "title": "R",
+ "owner": "Golmote"
+ },
+ "racket": {
+ "title": "Racket",
+ "require": "scheme",
+ "alias": "rkt",
+ "owner": "RunDevelopment"
+ },
+ "cshtml": {
+ "title": "Razor C#",
+ "alias": "razor",
+ "require": ["markup", "csharp"],
+ "optional": ["css", "css-extras", "javascript", "js-extras"],
+ "owner": "RunDevelopment"
+ },
+ "jsx": {
+ "title": "React JSX",
+ "require": ["markup", "javascript"],
+ "optional": ["jsdoc", "js-extras", "js-templates"],
+ "owner": "vkbansal"
+ },
+ "tsx": {
+ "title": "React TSX",
+ "require": ["jsx", "typescript"]
+ },
+ "reason": {
+ "title": "Reason",
+ "require": "clike",
+ "owner": "Golmote"
+ },
+ "regex": {
+ "title": "Regex",
+ "owner": "RunDevelopment"
+ },
+ "rego": {
+ "title": "Rego",
+ "owner": "JordanSh"
+ },
+ "renpy": {
+ "title": "Ren'py",
+ "alias": "rpy",
+ "owner": "HyuchiaDiego"
+ },
+ "rescript": {
+ "title": "ReScript",
+ "alias": "res",
+ "owner": "vmarcosp"
+ },
+ "rest": {
+ "title": "reST (reStructuredText)",
+ "owner": "Golmote"
+ },
+ "rip": {
+ "title": "Rip",
+ "owner": "ravinggenius"
+ },
+ "roboconf": {
+ "title": "Roboconf",
+ "owner": "Golmote"
+ },
+ "robotframework": {
+ "title": "Robot Framework",
+ "alias": "robot",
+ "owner": "RunDevelopment"
+ },
+ "ruby": {
+ "title": "Ruby",
+ "require": "clike",
+ "alias": "rb",
+ "owner": "samflores"
+ },
+ "rust": {
+ "title": "Rust",
+ "owner": "Golmote"
+ },
+ "sas": {
+ "title": "SAS",
+ "optional": ["groovy", "lua", "sql"],
+ "owner": "Golmote"
+ },
+ "sass": {
+ "title": "Sass (Sass)",
+ "require": "css",
+ "optional": "css-extras",
+ "owner": "Golmote"
+ },
+ "scss": {
+ "title": "Sass (SCSS)",
+ "require": "css",
+ "optional": "css-extras",
+ "owner": "MoOx"
+ },
+ "scala": {
+ "title": "Scala",
+ "require": "java",
+ "owner": "jozic"
+ },
+ "scheme": {
+ "title": "Scheme",
+ "owner": "bacchus123"
+ },
+ "shell-session": {
+ "title": "Shell session",
+ "require": "bash",
+ "alias": ["sh-session", "shellsession"],
+ "owner": "RunDevelopment"
+ },
+ "smali": {
+ "title": "Smali",
+ "owner": "RunDevelopment"
+ },
+ "smalltalk": {
+ "title": "Smalltalk",
+ "owner": "Golmote"
+ },
+ "smarty": {
+ "title": "Smarty",
+ "require": "markup-templating",
+ "optional": "php",
+ "owner": "Golmote"
+ },
+ "sml": {
+ "title": "SML",
+ "alias": "smlnj",
+ "aliasTitles": {
+ "smlnj": "SML/NJ"
+ },
+ "owner": "RunDevelopment"
+ },
+ "solidity": {
+ "title": "Solidity (Ethereum)",
+ "alias": "sol",
+ "require": "clike",
+ "owner": "glachaud"
+ },
+ "solution-file": {
+ "title": "Solution file",
+ "alias": "sln",
+ "owner": "RunDevelopment"
+ },
+ "soy": {
+ "title": "Soy (Closure Template)",
+ "require": "markup-templating",
+ "owner": "Golmote"
+ },
+ "sparql": {
+ "title": "SPARQL",
+ "require": "turtle",
+ "owner": "Triply-Dev",
+ "alias": "rq"
+ },
+ "splunk-spl": {
+ "title": "Splunk SPL",
+ "owner": "RunDevelopment"
+ },
+ "sqf": {
+ "title": "SQF: Status Quo Function (Arma 3)",
+ "require": "clike",
+ "owner": "RunDevelopment"
+ },
+ "sql": {
+ "title": "SQL",
+ "owner": "multipetros"
+ },
+ "squirrel": {
+ "title": "Squirrel",
+ "require": "clike",
+ "owner": "RunDevelopment"
+ },
+ "stan": {
+ "title": "Stan",
+ "owner": "RunDevelopment"
+ },
+ "stata": {
+ "title": "Stata Ado",
+ "require": ["mata", "java", "python"],
+ "owner": "RunDevelopment"
+ },
+ "iecst": {
+ "title": "Structured Text (IEC 61131-3)",
+ "owner": "serhioromano"
+ },
+ "stylus": {
+ "title": "Stylus",
+ "owner": "vkbansal"
+ },
+ "supercollider": {
+ "title": "SuperCollider",
+ "alias": "sclang",
+ "owner": "RunDevelopment"
+ },
+ "swift": {
+ "title": "Swift",
+ "owner": "chrischares"
+ },
+ "systemd": {
+ "title": "Systemd configuration file",
+ "owner": "RunDevelopment"
+ },
+ "t4-templating": {
+ "title": "T4 templating",
+ "owner": "RunDevelopment"
+ },
+ "t4-cs": {
+ "title": "T4 Text Templates (C#)",
+ "require": ["t4-templating", "csharp"],
+ "alias": "t4",
+ "owner": "RunDevelopment"
+ },
+ "t4-vb": {
+ "title": "T4 Text Templates (VB)",
+ "require": ["t4-templating", "vbnet"],
+ "owner": "RunDevelopment"
+ },
+ "tap": {
+ "title": "TAP",
+ "owner": "isaacs",
+ "require": "yaml"
+ },
+ "tcl": {
+ "title": "Tcl",
+ "owner": "PeterChaplin"
+ },
+ "tt2": {
+ "title": "Template Toolkit 2",
+ "require": ["clike", "markup-templating"],
+ "owner": "gflohr"
+ },
+ "textile": {
+ "title": "Textile",
+ "require": "markup",
+ "optional": "css",
+ "owner": "Golmote"
+ },
+ "toml": {
+ "title": "TOML",
+ "owner": "RunDevelopment"
+ },
+ "tremor": {
+ "title": "Tremor",
+ "alias": ["trickle", "troy"],
+ "owner": "darach",
+ "aliasTitles": {
+ "trickle": "trickle",
+ "troy": "troy"
+ }
+ },
+ "turtle": {
+ "title": "Turtle",
+ "alias": "trig",
+ "aliasTitles": {
+ "trig": "TriG"
+ },
+ "owner": "jakubklimek"
+ },
+ "twig": {
+ "title": "Twig",
+ "require": "markup-templating",
+ "owner": "brandonkelly"
+ },
+ "typescript": {
+ "title": "TypeScript",
+ "require": "javascript",
+ "optional": "js-templates",
+ "alias": "ts",
+ "owner": "vkbansal"
+ },
+ "typoscript": {
+ "title": "TypoScript",
+ "alias": "tsconfig",
+ "aliasTitles": {
+ "tsconfig": "TSConfig"
+ },
+ "owner": "dkern"
+ },
+ "unrealscript": {
+ "title": "UnrealScript",
+ "alias": ["uscript", "uc"],
+ "owner": "RunDevelopment"
+ },
+ "uorazor": {
+ "title": "UO Razor Script",
+ "owner": "jaseowns"
+ },
+ "uri": {
+ "title": "URI",
+ "alias": "url",
+ "aliasTitles": {
+ "url": "URL"
+ },
+ "owner": "RunDevelopment"
+ },
+ "v": {
+ "title": "V",
+ "require": "clike",
+ "owner": "taggon"
+ },
+ "vala": {
+ "title": "Vala",
+ "require": "clike",
+ "optional": "regex",
+ "owner": "TemplarVolk"
+ },
+ "vbnet": {
+ "title": "VB.Net",
+ "require": "basic",
+ "owner": "Bigsby"
+ },
+ "velocity": {
+ "title": "Velocity",
+ "require": "markup",
+ "owner": "Golmote"
+ },
+ "verilog": {
+ "title": "Verilog",
+ "owner": "a-rey"
+ },
+ "vhdl": {
+ "title": "VHDL",
+ "owner": "a-rey"
+ },
+ "vim": {
+ "title": "vim",
+ "owner": "westonganger"
+ },
+ "visual-basic": {
+ "title": "Visual Basic",
+ "alias": ["vb", "vba"],
+ "aliasTitles": {
+ "vba": "VBA"
+ },
+ "owner": "Golmote"
+ },
+ "warpscript": {
+ "title": "WarpScript",
+ "owner": "RunDevelopment"
+ },
+ "wasm": {
+ "title": "WebAssembly",
+ "owner": "Golmote"
+ },
+ "web-idl": {
+ "title": "Web IDL",
+ "alias": "webidl",
+ "owner": "RunDevelopment"
+ },
+ "wgsl": {
+ "title": "WGSL",
+ "owner": "Dr4gonthree"
+ },
+ "wiki": {
+ "title": "Wiki markup",
+ "require": "markup",
+ "owner": "Golmote"
+ },
+ "wolfram": {
+ "title": "Wolfram language",
+ "alias": ["mathematica", "nb", "wl"],
+ "aliasTitles": {
+ "mathematica": "Mathematica",
+ "nb": "Mathematica Notebook"
+ },
+ "owner": "msollami"
+ },
+ "wren": {
+ "title": "Wren",
+ "owner": "clsource"
+ },
+ "xeora": {
+ "title": "Xeora",
+ "require": "markup",
+ "alias": "xeoracube",
+ "aliasTitles": {
+ "xeoracube": "XeoraCube"
+ },
+ "owner": "freakmaxi"
+ },
+ "xml-doc": {
+ "title": "XML doc (.net)",
+ "require": "markup",
+ "modify": ["csharp", "fsharp", "vbnet"],
+ "owner": "RunDevelopment"
+ },
+ "xojo": {
+ "title": "Xojo (REALbasic)",
+ "owner": "Golmote"
+ },
+ "xquery": {
+ "title": "XQuery",
+ "require": "markup",
+ "owner": "Golmote"
+ },
+ "yaml": {
+ "title": "YAML",
+ "alias": "yml",
+ "owner": "hason"
+ },
+ "yang": {
+ "title": "YANG",
+ "owner": "RunDevelopment"
+ },
+ "zig": {
+ "title": "Zig",
+ "owner": "RunDevelopment"
+ }
+ },
+ "plugins": {
+ "meta": {
+ "path": "plugins/{id}/prism-{id}",
+ "link": "plugins/{id}/"
+ },
+ "line-highlight": {
+ "title": "Line Highlight",
+ "description": "Highlights specific lines and/or line ranges."
+ },
+ "line-numbers": {
+ "title": "Line Numbers",
+ "description": "Line number at the beginning of code lines.",
+ "owner": "kuba-kubula"
+ },
+ "show-invisibles": {
+ "title": "Show Invisibles",
+ "description": "Show hidden characters such as tabs and line breaks.",
+ "optional": ["autolinker", "data-uri-highlight"]
+ },
+ "autolinker": {
+ "title": "Autolinker",
+ "description": "Converts URLs and emails in code to clickable links. Parses Markdown links in comments."
+ },
+ "wpd": {
+ "title": "WebPlatform Docs",
+ "description": "Makes tokens link to WebPlatform.org documentation. The links open in a new tab."
+ },
+ "custom-class": {
+ "title": "Custom Class",
+ "description": "This plugin allows you to prefix Prism's default classes (.comment can become .namespace--comment) or replace them with your defined ones (like .editor__comment). You can even add new classes.",
+ "owner": "dvkndn",
+ "noCSS": true
+ },
+ "file-highlight": {
+ "title": "File Highlight",
+ "description": "Fetch external files and highlight them with Prism. Used on the Prism website itself.",
+ "noCSS": true
+ },
+ "show-language": {
+ "title": "Show Language",
+ "description": "Display the highlighted language in code blocks (inline code does not show the label).",
+ "owner": "nauzilus",
+ "noCSS": true,
+ "require": "toolbar"
+ },
+ "jsonp-highlight": {
+ "title": "JSONP Highlight",
+ "description": "Fetch content with JSONP and highlight some interesting content (e.g. GitHub/Gists or Bitbucket API).",
+ "noCSS": true,
+ "owner": "nauzilus"
+ },
+ "highlight-keywords": {
+ "title": "Highlight Keywords",
+ "description": "Adds special CSS classes for each keyword for fine-grained highlighting.",
+ "owner": "vkbansal",
+ "noCSS": true
+ },
+ "remove-initial-line-feed": {
+ "title": "Remove initial line feed",
+ "description": "Removes the initial line feed in code blocks.",
+ "owner": "Golmote",
+ "noCSS": true
+ },
+ "inline-color": {
+ "title": "Inline color",
+ "description": "Adds a small inline preview for colors in style sheets.",
+ "require": "css-extras",
+ "owner": "RunDevelopment"
+ },
+ "previewers": {
+ "title": "Previewers",
+ "description": "Previewers for angles, colors, gradients, easing and time.",
+ "require": "css-extras",
+ "owner": "Golmote"
+ },
+ "autoloader": {
+ "title": "Autoloader",
+ "description": "Automatically loads the needed languages to highlight the code blocks.",
+ "owner": "Golmote",
+ "noCSS": true
+ },
+ "keep-markup": {
+ "title": "Keep Markup",
+ "description": "Prevents custom markup from being dropped out during highlighting.",
+ "owner": "Golmote",
+ "optional": "normalize-whitespace",
+ "noCSS": true
+ },
+ "command-line": {
+ "title": "Command Line",
+ "description": "Display a command line with a prompt and, optionally, the output/response from the commands.",
+ "owner": "chriswells0"
+ },
+ "unescaped-markup": {
+ "title": "Unescaped Markup",
+ "description": "Write markup without having to escape anything."
+ },
+ "normalize-whitespace": {
+ "title": "Normalize Whitespace",
+ "description": "Supports multiple operations to normalize whitespace in code blocks.",
+ "owner": "zeitgeist87",
+ "optional": "unescaped-markup",
+ "noCSS": true
+ },
+ "data-uri-highlight": {
+ "title": "Data-URI Highlight",
+ "description": "Highlights data-URI contents.",
+ "owner": "Golmote",
+ "noCSS": true
+ },
+ "toolbar": {
+ "title": "Toolbar",
+ "description": "Attach a toolbar for plugins to easily register buttons on the top of a code block.",
+ "owner": "mAAdhaTTah"
+ },
+ "copy-to-clipboard": {
+ "title": "Copy to Clipboard Button",
+ "description": "Add a button that copies the code block to the clipboard when clicked.",
+ "owner": "mAAdhaTTah",
+ "require": "toolbar",
+ "noCSS": true
+ },
+ "download-button": {
+ "title": "Download Button",
+ "description": "A button in the toolbar of a code block adding a convenient way to download a code file.",
+ "owner": "Golmote",
+ "require": "toolbar",
+ "noCSS": true
+ },
+ "match-braces": {
+ "title": "Match braces",
+ "description": "Highlights matching braces.",
+ "owner": "RunDevelopment"
+ },
+ "diff-highlight": {
+ "title": "Diff Highlight",
+ "description": "Highlights the code inside diff blocks.",
+ "owner": "RunDevelopment",
+ "require": "diff"
+ },
+ "filter-highlight-all": {
+ "title": "Filter highlightAll",
+ "description": "Filters the elements the highlightAll and highlightAllUnder methods actually highlight.",
+ "owner": "RunDevelopment",
+ "noCSS": true
+ },
+ "treeview": {
+ "title": "Treeview",
+ "description": "A language with special styles to highlight file system tree structures.",
+ "owner": "Golmote"
+ }
+ }
+}
diff --git a/src/components/post/codeBlocks/prismHighlighter.ts b/src/components/post/codeBlocks/prismHighlighter.ts
index cd2617a..b96c3c9 100644
--- a/src/components/post/codeBlocks/prismHighlighter.ts
+++ b/src/components/post/codeBlocks/prismHighlighter.ts
@@ -4,12 +4,12 @@
*/
// @ts-ignore - prismjs doesn't have built-in types
-import Prism from "prismjs";
+import Prism from 'prismjs';
import {
extractLanguagesFromHTML,
loadMultiplePrismLanguages,
-} from "./prismLanguageLoader";
-import { enhanceCodeBlocks } from "./codeBlockEnhancer";
+} from './prismLanguageLoader';
+import { enhanceCodeBlocks } from './codeBlockEnhancer';
/**
* 清除代码块的高亮标记
@@ -18,7 +18,7 @@ export const clearHighlightMarks = (): void => {
document
.querySelectorAll('pre code[class*="language-"].highlighted')
.forEach((block) => {
- block.classList.remove("highlighted");
+ block.classList.remove('highlighted');
});
};
@@ -27,7 +27,7 @@ export const clearHighlightMarks = (): void => {
*/
export const markBlocksAsHighlighted = (): void => {
document.querySelectorAll('pre code[class*="language-"]').forEach((block) => {
- block.classList.add("highlighted");
+ block.classList.add('highlighted');
});
};
@@ -38,26 +38,22 @@ export const markBlocksAsHighlighted = (): void => {
* @returns Promise
*/
export const highlightWithRetry = (
- maxAttempts: number = 3,
- baseDelay: number = 100
-): Promise => {
- return new Promise((resolve) => {
- const retryHighlight = (attempts = 0) => {
- setTimeout(() => {
+ maxAttempts = 3,
+ baseDelay = 100,
+): Promise => new Promise((resolve) => {
+ const retryHighlight = (attempts = 0) => {
+ setTimeout(
+ () => {
try {
// 使用 Prism.highlightAll() 重新高亮所有代码块
Prism.highlightAll();
// 检查是否还有未高亮的代码块,如果有且重试次数未达到上限,则继续重试
- const unhighlightedBlocks = document.querySelectorAll(
- 'pre code[class*="language-"]:not(.highlighted)'
- );
+ const unhighlightedBlocks = document.querySelectorAll('pre code[class*="language-"]:not(.highlighted)');
if (unhighlightedBlocks.length > 0 && attempts < maxAttempts) {
- console.log(
- `Retrying highlight, attempt ${attempts + 1}, remaining blocks: ${
- unhighlightedBlocks.length
- }`
- );
+ console.log(`Retrying highlight, attempt ${attempts + 1}, remaining blocks: ${
+ unhighlightedBlocks.length
+ }`);
retryHighlight(attempts + 1);
} else {
// 标记所有代码块为已高亮,避免重复处理
@@ -67,28 +63,27 @@ export const highlightWithRetry = (
resolve();
}
} catch (error) {
- console.warn("Failed to highlight code blocks:", error);
+ console.warn('Failed to highlight code blocks:', error);
resolve();
}
- }, baseDelay + attempts * baseDelay); // 递增延迟时间
- };
+ },
+ baseDelay + attempts * baseDelay,
+ ); // 递增延迟时间
+ };
- retryHighlight();
- });
-};
+ retryHighlight();
+});
/**
* 高亮特定的代码块元素
* @param codeBlocks 代码块元素列表
*/
-export const highlightSpecificBlocks = (
- codeBlocks: NodeListOf
-): void => {
+export const highlightSpecificBlocks = (codeBlocks: NodeListOf): void => {
codeBlocks.forEach((block) => {
try {
Prism.highlightElement(block as HTMLElement);
} catch (error) {
- console.warn("Failed to highlight code block:", error);
+ console.warn('Failed to highlight code block:', error);
}
});
};
@@ -98,9 +93,7 @@ export const highlightSpecificBlocks = (
* @param content HTML 内容字符串
* @returns Promise
*/
-export const performCompleteHighlight = async (
- content: string
-): Promise => {
+export const performCompleteHighlight = async (content: string): Promise => {
try {
// 清除之前的高亮标记,确保可以重新高亮
clearHighlightMarks();
@@ -109,7 +102,7 @@ export const performCompleteHighlight = async (
const requiredLanguages = extractLanguagesFromHTML(content);
if (requiredLanguages.length > 0) {
- console.log("Loading languages:", requiredLanguages);
+ console.log('Loading languages:', requiredLanguages);
// 加载所需的语言包
await loadMultiplePrismLanguages(requiredLanguages);
}
@@ -117,7 +110,7 @@ export const performCompleteHighlight = async (
// 执行带重试机制的高亮
await highlightWithRetry();
} catch (error) {
- console.warn("Failed to perform complete highlight:", error);
+ console.warn('Failed to perform complete highlight:', error);
}
};
@@ -139,9 +132,7 @@ export const highlightAfterCSSLoad = async (content: string): Promise => {
await loadMultiplePrismLanguages(requiredLanguages);
}
- const codeBlocks = document.querySelectorAll(
- 'pre code[class*="language-"]'
- );
+ const codeBlocks = document.querySelectorAll('pre code[class*="language-"]');
highlightSpecificBlocks(codeBlocks);
// 增强代码块
@@ -149,7 +140,7 @@ export const highlightAfterCSSLoad = async (content: string): Promise => {
enhanceCodeBlocks();
}, 100);
} catch (error) {
- console.warn("Failed to highlight after CSS load:", error);
+ console.warn('Failed to highlight after CSS load:', error);
}
};
@@ -158,9 +149,7 @@ export const highlightAfterCSSLoad = async (content: string): Promise => {
* @param content HTML 内容字符串
* @returns 清理函数
*/
-export const highlightOnMount = async (
- content: string
-): Promise<() => void> => {
+export const highlightOnMount = async (content: string): Promise<() => void> => {
try {
// 清除之前的高亮标记,确保可以重新高亮
clearHighlightMarks();
@@ -174,17 +163,13 @@ export const highlightOnMount = async (
}
// 延迟执行高亮,带重试机制
- const retryHighlightOnMount = (
- attempts = 0
- ): ReturnType => {
- return setTimeout(() => {
+ const retryHighlightOnMount = (attempts = 0): ReturnType => setTimeout(
+ () => {
try {
Prism.highlightAll();
// 检查是否还有未高亮的代码块,如果有且重试次数未达到上限,则继续重试
- const unhighlightedBlocks = document.querySelectorAll(
- 'pre code[class*="language-"]:not(.highlighted)'
- );
+ const unhighlightedBlocks = document.querySelectorAll('pre code[class*="language-"]:not(.highlighted)');
if (unhighlightedBlocks.length > 0 && attempts < 2) {
console.log(`Retrying highlight on mount, attempt ${attempts + 1}`);
retryHighlightOnMount(attempts + 1);
@@ -195,15 +180,16 @@ export const highlightOnMount = async (
enhanceCodeBlocks();
}
} catch (error) {
- console.warn("Failed to highlight code blocks on mount:", error);
+ console.warn('Failed to highlight code blocks on mount:', error);
}
- }, 200 + attempts * 150);
- };
+ },
+ 200 + attempts * 150,
+ );
const timer = retryHighlightOnMount();
return () => clearTimeout(timer);
} catch (error) {
- console.warn("Failed to highlight on mount:", error);
+ console.warn('Failed to highlight on mount:', error);
return () => {};
}
};
diff --git a/src/components/post/codeBlocks/prismLanguageLoader.ts b/src/components/post/codeBlocks/prismLanguageLoader.ts
index edeb272..e2b942f 100644
--- a/src/components/post/codeBlocks/prismLanguageLoader.ts
+++ b/src/components/post/codeBlocks/prismLanguageLoader.ts
@@ -12,8 +12,8 @@
*/
// @ts-ignore - prismjs doesn't have built-in types
-import Prism from "prismjs";
-import components from "./prism-components.json"; // 假设您将提供的 JSON 保存为此文件
+import Prism from 'prismjs';
+import components from './prism-components.json'; // 假设您将提供的 JSON 保存为此文件
// -----------------------------------------------------------------------------
// Data Processing: Generate Dependency and Alias Maps from Official JSON
@@ -39,7 +39,7 @@ const processLanguageData = () => {
const languages = components.languages as Record;
for (const langId in languages) {
- if (langId === "meta") {
+ if (langId === 'meta') {
continue;
}
const langInfo = languages[langId];
@@ -57,11 +57,10 @@ const processLanguageData = () => {
// 2. 建立依赖映射 (合并 'require' 和 'modify')
const deps = new Set();
- const toArray = (val?: string | string[]) =>
- val ? (Array.isArray(val) ? val : [val]) : [];
+ const toArray = (val?: string | string[]) => (val ? (Array.isArray(val) ? val : [val]) : []);
- toArray(langInfo.require).forEach((dep) => deps.add(dep));
- toArray(langInfo.modify).forEach((dep) => deps.add(dep));
+ toArray(langInfo.require).forEach(dep => deps.add(dep));
+ toArray(langInfo.modify).forEach(dep => deps.add(dep));
if (deps.size > 0) {
languageDependencies.set(langId, Array.from(deps));
@@ -83,7 +82,7 @@ const loadedLanguages = new Set();
const loadingPromises = new Map>();
// Prism.js CDN 基础 URL (保持版本同步)
-const PRISM_CDN_BASE = "https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components";
+const PRISM_CDN_BASE = 'https://cdn.jsdelivr.net/npm/prismjs@1.30.0/components';
/**
* 通过 CDN 动态加载单个语言包
@@ -107,7 +106,7 @@ const loadSingleLanguage = async (language: string): Promise => {
}
try {
- const script = document.createElement("script");
+ const script = document.createElement('script');
const scriptSrc = `${PRISM_CDN_BASE}/prism-${language}.min.js`;
script.src = scriptSrc;
@@ -168,9 +167,7 @@ export const loadPrismLanguage = async (language: string): Promise => {
const dependencies = languageDependencies.get(canonicalLanguage) || [];
if (dependencies.length > 0) {
- const dependencyPromises = dependencies.map((dep) =>
- loadPrismLanguage(dep)
- );
+ const dependencyPromises = dependencies.map(dep => loadPrismLanguage(dep));
await Promise.all(dependencyPromises);
}
@@ -194,14 +191,14 @@ export const extractLanguagesFromHTML = (htmlContent: string): string[] => {
while ((match = languageRegex.exec(htmlContent)) !== null) {
const lang = match[1];
- if (lang && lang !== "none") {
+ if (lang && lang !== 'none') {
languages.add(lang);
}
}
const result = Array.from(languages);
if (result.length > 0) {
- console.log("📋 Prism: Found languages to load:", result);
+ console.log('📋 Prism: Found languages to load:', result);
}
return result;
};
@@ -210,10 +207,8 @@ export const extractLanguagesFromHTML = (htmlContent: string): string[] => {
* 批量加载多个语言包
* @param languages 语言包数组
*/
-export const loadMultiplePrismLanguages = async (
- languages: string[]
-): Promise => {
- const loadPromises = languages.map((lang) => loadPrismLanguage(lang));
+export const loadMultiplePrismLanguages = async (languages: string[]): Promise => {
+ const loadPromises = languages.map(lang => loadPrismLanguage(lang));
await Promise.allSettled(loadPromises);
};
@@ -222,16 +217,16 @@ export const loadMultiplePrismLanguages = async (
*/
export const preloadCommonLanguages = async (): Promise => {
const commonLanguages = [
- "javascript", // or "js"
- "typescript", // or "ts"
- "python", // or "py"
- "go",
- "java",
- "css",
- "json",
- "bash", // or "shell"
- "sql",
- "markup", // or "html"
+ 'javascript', // or "js"
+ 'typescript', // or "ts"
+ 'python', // or "py"
+ 'go',
+ 'java',
+ 'css',
+ 'json',
+ 'bash', // or "shell"
+ 'sql',
+ 'markup', // or "html"
];
await loadMultiplePrismLanguages(commonLanguages);
};
@@ -242,11 +237,11 @@ export const preloadCommonLanguages = async (): Promise => {
(async () => {
try {
// 预加载基础核心语言,几乎所有语言都依赖它们
- await loadPrismLanguage("markup"); // 包括 clike
- await loadPrismLanguage("css");
- await loadPrismLanguage("javascript");
+ await loadPrismLanguage('markup'); // 包括 clike
+ await loadPrismLanguage('css');
+ await loadPrismLanguage('javascript');
} catch (error) {
- console.warn("Failed to preload base languages:", error);
+ console.warn('Failed to preload base languages:', error);
}
})();
@@ -254,15 +249,15 @@ export const preloadCommonLanguages = async (): Promise => {
// Debug Tools
// -----------------------------------------------------------------------------
// 调试工具:在浏览器控制台中暴露测试函数
-if (typeof window !== "undefined") {
+if (typeof window !== 'undefined') {
(window as any).debugPrismLanguageLoader = {
extractLanguagesFromHTML,
loadPrismLanguage,
testExtraction: (html: string) => {
- console.log("🧪 Testing language extraction:");
- console.log("Input HTML:", html);
+ console.log('🧪 Testing language extraction:');
+ console.log('Input HTML:', html);
const languages = extractLanguagesFromHTML(html);
- console.log("Extracted languages:", languages);
+ console.log('Extracted languages:', languages);
return languages;
},
testPythonHTML: () => {
@@ -272,23 +267,23 @@ if (typeof window !== "undefined") {
return (window as any).debugPrismLanguageLoader.testExtraction(testHTML);
},
testSQLHTML: () => {
- const testHTML = `SELECT * FROM users WHERE id = 1;
`;
+ const testHTML = 'SELECT * FROM users WHERE id = 1;
';
return (window as any).debugPrismLanguageLoader.testExtraction(testHTML);
},
checkAliases: () => {
- console.log("🔍 Language aliases map:");
- console.log("python ->", languageAliases.get("python"));
- console.log("py ->", languageAliases.get("py"));
- console.log("sql ->", languageAliases.get("sql"));
- console.log("javascript ->", languageAliases.get("javascript"));
- console.log("js ->", languageAliases.get("js"));
+ console.log('🔍 Language aliases map:');
+ console.log('python ->', languageAliases.get('python'));
+ console.log('py ->', languageAliases.get('py'));
+ console.log('sql ->', languageAliases.get('sql'));
+ console.log('javascript ->', languageAliases.get('javascript'));
+ console.log('js ->', languageAliases.get('js'));
},
checkDependencies: () => {
- console.log("📦 Language dependencies map:");
- console.log("python deps:", languageDependencies.get("python"));
- console.log("sql deps:", languageDependencies.get("sql"));
- console.log("javascript deps:", languageDependencies.get("javascript"));
- console.log("go deps:", languageDependencies.get("go"));
+ console.log('📦 Language dependencies map:');
+ console.log('python deps:', languageDependencies.get('python'));
+ console.log('sql deps:', languageDependencies.get('sql'));
+ console.log('javascript deps:', languageDependencies.get('javascript'));
+ console.log('go deps:', languageDependencies.get('go'));
},
};
}
diff --git a/src/components/post/comments/Form.tsx b/src/components/post/comments/Form.tsx
index 56947f2..b5917f7 100644
--- a/src/components/post/comments/Form.tsx
+++ b/src/components/post/comments/Form.tsx
@@ -1,15 +1,14 @@
import React, { useEffect, useRef, useState } from 'react';
-import _ from 'lodash';
import { useBoolean } from 'ahooks';
// 不再需要 Timeout 类型
-// import type { Timeout } from 'ahooks/lib/useRequest/src/types';
+// import type { Timeout } from 'ahooks/lib/useRequest/src/types';
import type { CommentsState } from './types';
import type { SetState } from 'ahooks/lib/useSetState';
type CommentFormProps = {
Ctx: CommentsState;
setCtx: SetState;
-}
+};
export const CommentForm: React.FC = ({ Ctx, setCtx }) => {
const { blogId, postId, replyToId } = Ctx;
@@ -20,10 +19,6 @@ export const CommentForm: React.FC = ({ Ctx, setCtx }) => {
// 使用一个 Ref 来确保 focus 事件处理函数只被有效执行一次
const isWaitingForPopupClose = useRef(false);
- useEffect(() => {
- setCommentText('');
- }, [replyToId]);
-
// 新增 Effect 来处理 focus 事件的监听和清理
useEffect(() => {
const handleFocus = () => {
@@ -68,7 +63,11 @@ export const CommentForm: React.FC = ({ Ctx, setCtx }) => {
}
const popupOptions = 'width=600,height=550,resizable=yes,scrollbars=yes';
- const popup = window.open(finalUrl, `blogger-comment-${Date.now()}`, popupOptions);
+ const popup = window.open(
+ finalUrl,
+ `blogger-comment-${Date.now()}`,
+ popupOptions,
+ );
if (!popup) {
alert('评论窗口被浏览器拦截,请允许弹出窗口后重试。');
@@ -86,30 +85,42 @@ export const CommentForm: React.FC = ({ Ctx, setCtx }) => {
return (
-
- {replyToId ? '正在回复...' : '发表新评论'}
-
+
{replyToId ? '正在回复...' : '发表新评论'}
);
-};
\ No newline at end of file
+};
diff --git a/src/components/post/comments/Item.tsx b/src/components/post/comments/Item.tsx
index 3ce4bc6..ac359fe 100644
--- a/src/components/post/comments/Item.tsx
+++ b/src/components/post/comments/Item.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useRef, useEffect } from 'react';
+import React, { useState, useRef, useEffect, type JSX } from 'react';
import { isMobile } from 'react-device-detect';
import type { CommentItem, MetaBlogger } from '../../../models/CommentItem';
import { getCurrentTheme } from '../../../constants/colors';
@@ -12,7 +12,11 @@ interface CommentItemComponentProps {
ClickReplyButton: () => void;
}
-export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: CommentItemComponentProps) {
+export function CommentItemComponent({
+ comment,
+ setCtx,
+ ClickReplyButton,
+}: CommentItemComponentProps): JSX.Element {
const colors = getCurrentTheme();
const [showTooltip, setShowTooltip] = useState(false);
const [showToast, setShowToast] = useState(false);
@@ -29,7 +33,10 @@ export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: Comm
useEffect(() => {
if (!isMobile || !showTooltip) return;
const handleClickOutside = (event: MouseEvent) => {
- if (linkIconRef.current && !linkIconRef.current.contains(event.target as Node)) {
+ if (
+ linkIconRef.current
+ && !linkIconRef.current.contains(event.target as Node)
+ ) {
setShowTooltip(false);
setTooltipText('');
}
@@ -89,7 +96,7 @@ export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: Comm
month: 'short',
day: 'numeric',
hour: '2-digit',
- minute: '2-digit'
+ minute: '2-digit',
});
};
@@ -243,7 +250,7 @@ export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: Comm
const tempDiv = document.createElement('div');
tempDiv.innerHTML = htmlContent;
// 获取纯文本,并截断
- const text = tempDiv.textContent || tempDiv.innerText || "";
+ const text = tempDiv.textContent || tempDiv.innerText || '';
return text.length > 50 ? `${text.substring(0, 50)}...` : text;
};
@@ -255,7 +262,12 @@ export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: Comm
) : (
comment.author.name.charAt(0).toUpperCase()
@@ -281,7 +293,11 @@ export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: Comm
style={linkIconStyles}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
- onClick={handleLinkIconClick}
+ onClick={(event) => {
+ handleLinkIconClick(event).catch((err) => {
+ console.error('Submit handler failed:', err);
+ });
+ }}
>
🔗
@@ -298,11 +314,13 @@ export function CommentItemComponent({ comment, setCtx, ClickReplyButton }: Comm