@@ -52,7 +52,7 @@ async function getCompiler(options?: CompileOptions): Promise<MarkdownExit> {
5252}
5353
5454async function createCompiler ( options ?: CompileOptions ) : Promise < MarkdownExit > {
55- const md = new MarkdownExit ( { html : true , linkify : true } ) ;
55+ const markdown = new MarkdownExit ( { html : true , linkify : true } ) ;
5656
5757 // Shiki highlighting with JS RegExp engine (no WASM) + lazy language loading
5858 const themes = options ?. shiki ?. themes ?? {
@@ -71,8 +71,8 @@ async function createCompiler(options?: CompileOptions): Promise<MarkdownExit> {
7171 transformerNotationFocus ( ) ,
7272 transformerNotationErrorLevel ( ) ,
7373 ] ;
74- md . renderer . rules . fence = async ( tokens : ReadonlyArray < Token > , idx : number ) => {
75- const token = tokens [ idx ] ;
74+ markdown . renderer . rules . fence = async ( tokens : ReadonlyArray < Token > , tokenIndex : number ) => {
75+ const token = tokens [ tokenIndex ] ;
7676 const code = token . content ;
7777 let lang = token . info ? token . info . split ( / \s + / g) [ 0 ] : 'text' ;
7878 if ( ! isSpecialLang ( lang ) && ! highlighter . getLoadedLanguages ( ) . includes ( lang ) ) {
@@ -92,49 +92,49 @@ async function createCompiler(options?: CompileOptions): Promise<MarkdownExit> {
9292 } ;
9393
9494 // Code block wrapping (must come after shiki, before line-numbers)
95- md . use ( preWrapperPlugin ) ;
95+ markdown . use ( preWrapperPlugin ) ;
9696
9797 // Container blocks: :::tip, :::warning, etc.
98- md . use ( containerPlugin ) ;
98+ markdown . use ( containerPlugin ) ;
9999
100100 // Image path normalization + lazy loading
101- md . use ( imagePlugin , { lazyLoading : true } ) ;
101+ markdown . use ( imagePlugin , { lazyLoading : true } ) ;
102102
103103 // Link handling: external attrs, .md normalization
104- md . use ( linkPlugin ) ;
104+ markdown . use ( linkPlugin ) ;
105105
106106 // Line numbers (opt-in per code block by default)
107- md . use ( lineNumberPlugin , false ) ;
107+ markdown . use ( lineNumberPlugin , false ) ;
108108
109109 // GitHub alerts: > [!NOTE], > [!TIP], etc.
110- md . use ( gitHubAlertsPlugin ) ;
110+ markdown . use ( gitHubAlertsPlugin ) ;
111111
112112 // Attribute syntax: {.class #id}
113- md . use ( attrs ) ;
113+ markdown . use ( attrs ) ;
114114
115115 // Emoji shortcodes
116- md . use ( emoji ) ;
116+ markdown . use ( emoji ) ;
117117
118118 // Heading anchors
119119 // @ts -expect-error markdown-it-anchor types reference @types/markdown-it, structurally incompatible with markdown-exit
120- md . use ( anchor , {
120+ markdown . use ( anchor , {
121121 permalink : anchor . permalink . ariaHidden ( { placement : 'before' } ) ,
122122 } ) ;
123123
124124 // [[toc]] directive
125- md . use ( tocPlugin ) ;
125+ markdown . use ( tocPlugin ) ;
126126
127- return md ;
127+ return markdown ;
128128}
129129
130130function extractHeadings ( tokens : ReadonlyArray < Token > ) : ReadonlyArray < Heading > {
131131 const headings : Array < Heading > = [ ] ;
132- for ( let i = 0 ; i < tokens . length ; i ++ ) {
133- const token = tokens [ i ] ;
132+ for ( let tokenIndex = 0 ; tokenIndex < tokens . length ; tokenIndex ++ ) {
133+ const token = tokens [ tokenIndex ] ;
134134 if ( token . type === 'heading_open' ) {
135135 const depth = Number ( token . tag . slice ( 1 ) ) ;
136136 const slug = token . attrGet ?.( 'id' ) ?? '' ;
137- const inline = tokens [ i + 1 ] ;
137+ const inline = tokens [ tokenIndex + 1 ] ;
138138 const text = (
139139 inline ?. children
140140 ?. filter ( ( child ) => child . type === 'text' || child . type === 'code_inline' )
@@ -156,7 +156,8 @@ export async function compile(source: string, options?: CompileOptions): Promise
156156 const headings = extractHeadings ( tokens ) ;
157157 const html = await compiler . renderAsync ( content , env ) ;
158158
159- const title = ( frontmatter . title as string ) ?? headings . find ( ( h ) => h . depth === 1 ) ?. text ?? '' ;
159+ const title =
160+ ( frontmatter . title as string ) ?? headings . find ( ( heading ) => heading . depth === 1 ) ?. text ?? '' ;
160161
161162 return { html, frontmatter, headings, title } ;
162163}
0 commit comments