@@ -29,8 +29,9 @@ import annotate from './annotate'
2929import alerts from './alerts'
3030import removeHtmlComments from 'remark-remove-comments'
3131import remarkStringify from 'remark-stringify'
32+ import type { Context , UnifiedProcessor } from '@/content-render/types'
3233
33- export function createProcessor ( context ) {
34+ export function createProcessor ( context : Context ) : UnifiedProcessor {
3435 return (
3536 unified ( )
3637 . use ( remarkParse )
@@ -44,11 +45,13 @@ export function createProcessor(context) {
4445 . use ( remark2rehype , { allowDangerousHtml : true } )
4546 // HTML AST below vvv
4647 . use ( slug )
47- . use ( useEnglishHeadings , context )
48+ // useEnglishHeadings plugin requires context with englishHeadings property
49+ . use ( useEnglishHeadings as any , context || { } )
4850 . use ( headingLinks )
4951 . use ( codeHeader )
5052 . use ( annotate , context )
51- . use ( highlight , {
53+ // Using 'as any' for highlight plugin due to complex type mismatch between unified and rehype-highlight
54+ . use ( highlight as any , {
5255 languages : { ...common , graphql, dockerfile, http, groovy, erb, powershell } ,
5356 subset : false ,
5457 aliases : {
@@ -71,24 +74,28 @@ export function createProcessor(context) {
7174 . use ( rewriteForRowheaders )
7275 . use ( rewriteImgSources )
7376 . use ( rewriteAssetImgTags )
74- . use ( alerts , context )
77+ // alerts plugin requires context with alertTitles property
78+ . use ( alerts as any , context || { } )
7579 // HTML AST above ^^^
76- . use ( html )
77- // String below vvv
80+ . use ( html ) as UnifiedProcessor // String below vvv
7881 )
7982}
8083
81- export function createMarkdownOnlyProcessor ( context ) {
82- return unified ( ) . use ( remarkParse ) . use ( gfm ) . use ( rewriteLocalLinks , context ) . use ( remarkStringify )
84+ export function createMarkdownOnlyProcessor ( context : Context ) : UnifiedProcessor {
85+ return unified ( )
86+ . use ( remarkParse )
87+ . use ( gfm )
88+ . use ( rewriteLocalLinks , context )
89+ . use ( remarkStringify ) as UnifiedProcessor
8390}
8491
85- export function createMinimalProcessor ( context ) {
92+ export function createMinimalProcessor ( context : Context ) : UnifiedProcessor {
8693 return unified ( )
8794 . use ( remarkParse )
8895 . use ( gfm )
8996 . use ( rewriteLocalLinks , context )
9097 . use ( remark2rehype , { allowDangerousHtml : true } )
9198 . use ( slug )
9299 . use ( raw )
93- . use ( html )
100+ . use ( html ) as UnifiedProcessor
94101}
0 commit comments