@@ -6,14 +6,12 @@ import { remarkMermaid } from '@theguild/remark-mermaid'
6
6
import { remarkNpm2Yarn } from '@theguild/remark-npm2yarn'
7
7
import type { Program } from 'estree'
8
8
import rehypeKatex from 'rehype-katex'
9
- import type { Options as RehypePrettyCodeOptions } from 'rehype-pretty-code'
10
9
import rehypePrettyCode from 'rehype-pretty-code'
11
10
import rehypeRaw from 'rehype-raw'
12
11
import remarkFrontmatter from 'remark-frontmatter'
13
12
import remarkGfm from 'remark-gfm'
14
13
import remarkMath from 'remark-math'
15
14
import remarkReadingTime from 'remark-reading-time'
16
- import { bundledLanguages , getHighlighter } from 'shiki'
17
15
import type { Pluggable , Plugin } from 'unified'
18
16
import type {
19
17
FrontMatter ,
@@ -23,7 +21,6 @@ import type {
23
21
StructurizedData
24
22
} from '../types'
25
23
import {
26
- CODE_BLOCK_FILENAME_REGEX ,
27
24
CWD ,
28
25
DEFAULT_LOCALE ,
29
26
ERROR_ROUTES ,
@@ -34,6 +31,7 @@ import {
34
31
recmaRewriteJsx
35
32
} from './recma-plugins/index.js'
36
33
import {
34
+ DEFAULT_REHYPE_PRETTY_CODE_OPTIONS ,
37
35
rehypeAttachCodeMeta ,
38
36
rehypeBetterReactMathjax ,
39
37
rehypeExtractTocContent ,
@@ -53,45 +51,6 @@ import {
53
51
} from './remark-plugins/index.js'
54
52
import { logger , truthy } from './utils.js'
55
53
56
- export const DEFAULT_REHYPE_PRETTY_CODE_OPTIONS : RehypePrettyCodeOptions = {
57
- keepBackground : false ,
58
- grid : false ,
59
- onVisitLine ( node ) {
60
- // Prevent lines from collapsing in `display: grid` mode, and
61
- // allow empty lines to be copy/pasted
62
- if ( node . children . length === 0 ) {
63
- node . children . push ( { type : 'text' , value : ' ' } )
64
- }
65
- delete node . properties [ 'data-line' ]
66
- } ,
67
- filterMetaString : meta => meta . replace ( CODE_BLOCK_FILENAME_REGEX , '' ) ,
68
- async getHighlighter ( _opts ) {
69
- const DEFAULT_OPTS = {
70
- themes : {
71
- light : 'github-light' ,
72
- dark : 'github-dark'
73
- } ,
74
- defaultColor : false
75
- } as const
76
-
77
- const highlighter = await getHighlighter ( {
78
- themes : Object . values ( DEFAULT_OPTS . themes ) ,
79
- langs : Object . keys ( bundledLanguages )
80
- } )
81
-
82
- const originalCodeToHtml = highlighter . codeToHtml
83
-
84
- return Object . assign ( highlighter , {
85
- codeToHtml ( code : string , lang : string ) {
86
- return originalCodeToHtml ( code , { lang, ...DEFAULT_OPTS } )
87
- } ,
88
- ansiToHtml ( code : string ) {
89
- return this . codeToHtml ( code , 'ansi' )
90
- }
91
- } )
92
- }
93
- }
94
-
95
54
const cachedCompilerForFormat : Record <
96
55
Exclude < ProcessorOptions [ 'format' ] , undefined | null > ,
97
56
Processor
0 commit comments