From 94e76bbcd2f494b0a268dee9e830c7e8ecd70802 Mon Sep 17 00:00:00 2001 From: seaHi Date: Sun, 27 Sep 2026 21:28:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Markdown=20=E6=B8=B2=E6=9F=93=E5=99=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20Apache=20=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=AF=AD=E6=B3=95=E9=AB=98=E4=BA=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/markdown/renderer.ts | 4 ++++ src/lib/markdown/rendering.test.ts | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/lib/markdown/renderer.ts b/src/lib/markdown/renderer.ts index 0d40106..a57dd25 100644 --- a/src/lib/markdown/renderer.ts +++ b/src/lib/markdown/renderer.ts @@ -27,6 +27,7 @@ import java from 'highlight.js/lib/languages/java'; import php from 'highlight.js/lib/languages/php'; import dockerfile from 'highlight.js/lib/languages/dockerfile'; import nginx from 'highlight.js/lib/languages/nginx'; +import apache from 'highlight.js/lib/languages/apache'; import ini from 'highlight.js/lib/languages/ini'; import http from 'highlight.js/lib/languages/http'; import diff from 'highlight.js/lib/languages/diff'; @@ -57,6 +58,9 @@ hljs.registerLanguage('java', java); hljs.registerLanguage('php', php); hljs.registerLanguage('dockerfile', dockerfile); hljs.registerLanguage('nginx', nginx); +hljs.registerLanguage('apache', apache); +hljs.registerLanguage('apacheconf', apache); +hljs.registerLanguage('httpd', apache); hljs.registerLanguage('ini', ini); hljs.registerLanguage('toml', ini); hljs.registerLanguage('http', http); diff --git a/src/lib/markdown/rendering.test.ts b/src/lib/markdown/rendering.test.ts index 028532f..1f0d829 100644 --- a/src/lib/markdown/rendering.test.ts +++ b/src/lib/markdown/rendering.test.ts @@ -7,6 +7,7 @@ import { resolveAdmonitionTitle, sanitizeMarkdownHtml } from './rendering'; +import { renderMarkdown } from './renderer'; describe('replaceGithubAdmonitions', () => { it('passes the type, title and quote body to the renderer', () => { @@ -122,3 +123,22 @@ describe('sanitizeMarkdownHtml', () => { expect(sanitized).toContain('rel="noopener noreferrer"'); }); }); + +describe('renderMarkdown code highlighting', () => { + it('highlights apache, apacheconf, and httpd configuration blocks', () => { + const mdApache = '```apache\nRewriteEngine On\nRewriteRule ^index\\.html$ / [R=301,L]\n```'; + const htmlApache = renderMarkdown(mdApache); + expect(htmlApache).toContain('language-apache'); + expect(htmlApache).toContain('RewriteEngine'); + + const mdConf = '```apacheconf\n\nServerName example.com\n\n```'; + const htmlConf = renderMarkdown(mdConf); + expect(htmlConf).toContain('language-apacheconf'); + expect(htmlConf).toContain('hljs-section'); + + const mdHttpd = '```httpd\n\nServerName example.com\n\n```'; + const htmlHttpd = renderMarkdown(mdHttpd); + expect(htmlHttpd).toContain('language-httpd'); + expect(htmlHttpd).toContain('hljs-section'); + }); +});