File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ import fs from "fs"
2
2
import path from "path"
3
3
import dotenv from "dotenv"
4
4
import { DateTime } from "luxon"
5
- import hljs from "highlight.js"
5
+ import highlight from "highlight.js"
6
+ import highlightDiff from "highlightjs-code-diff"
6
7
import markdownIt from "markdown-it"
7
8
import anchor from "markdown-it-anchor"
8
9
import bracketedSpans from "markdown-it-bracketed-spans"
@@ -16,14 +17,17 @@ dotenv.config()
16
17
17
18
export default function ( eleventyConfig ) {
18
19
const isDevelopment = process . env . NODE_ENV === "development"
20
+ const hljs = highlightDiff ( highlight )
19
21
const markdownItConfig = markdownIt ( {
20
22
html : true ,
21
23
linkify : true ,
22
24
typographer : true ,
23
25
highlight : function ( str , lang ) {
24
- if ( lang && hljs . getLanguage ( lang ) ) {
26
+ const processLang = lang . replace ( "diff:" , "" )
27
+ if ( lang && hljs . getLanguage ( processLang ) ) {
25
28
try {
26
- return hljs . highlight ( str , { language : lang } ) . value
29
+ const returnValue = hljs . highlight ( str , { language : lang } ) . value
30
+ return returnValue
27
31
} catch ( __ ) { }
28
32
}
29
33
return ""
You can’t perform that action at this time.
0 commit comments