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'); + }); +});