@@ -128,6 +128,7 @@ export async function changelogRenderer(mdRepoInfo: MarkdownRepoInfo) {
128128 ) ,
129129 mdRepoInfo ,
130130 prefixId ,
131+ idPrefix ,
131132 ) ,
132133 toc,
133134 }
@@ -138,6 +139,7 @@ export function sanitizeRawHTML(
138139 rawHtml : string ,
139140 mdRepoInfo : MarkdownRepoInfo ,
140141 prefixId : typeof prefixIdFn ,
142+ idPrefix : string ,
141143) {
142144 return sanitizeHtml ( rawHtml , {
143145 allowedTags : ALLOWED_TAGS ,
@@ -169,13 +171,13 @@ export function sanitizeRawHTML(
169171 } ,
170172 img : ( tagName , attribs ) => {
171173 if ( attribs . src ) {
172- attribs . src = resolveUrl ( attribs . src , mdRepoInfo )
174+ attribs . src = resolveUrl ( attribs . src , mdRepoInfo , idPrefix )
173175 }
174176 return { tagName, attribs }
175177 } ,
176178 source : ( tagName , attribs ) => {
177179 if ( attribs . src ) {
178- attribs . src = resolveUrl ( attribs . src , mdRepoInfo )
180+ attribs . src = resolveUrl ( attribs . src , mdRepoInfo , idPrefix )
179181 }
180182 if ( attribs . srcset ) {
181183 attribs . srcset = attribs . srcset
@@ -185,7 +187,7 @@ export function sanitizeRawHTML(
185187 const url = parts [ 0 ]
186188 if ( ! url ) return entry . trim ( )
187189 const descriptor = parts [ 1 ]
188- const resolvedUrl = resolveUrl ( url , mdRepoInfo )
190+ const resolvedUrl = resolveUrl ( url , mdRepoInfo , idPrefix )
189191 return descriptor ? `${ resolvedUrl } ${ descriptor } ` : resolvedUrl
190192 } )
191193 . join ( ', ' )
@@ -197,7 +199,7 @@ export function sanitizeRawHTML(
197199 return { tagName, attribs }
198200 }
199201
200- const resolvedHref = resolveUrl ( attribs . href , mdRepoInfo )
202+ const resolvedHref = resolveUrl ( attribs . href , mdRepoInfo , idPrefix )
201203
202204 // Add security attributes for external links
203205 if ( resolvedHref && hasProtocol ( resolvedHref , { acceptRelative : true } ) ) {
@@ -227,14 +229,14 @@ interface MarkdownRepoInfo {
227229 path ?: string
228230}
229231
230- function resolveUrl ( url : string , repoInfo : MarkdownRepoInfo ) {
232+ function resolveUrl ( url : string , repoInfo : MarkdownRepoInfo , idPrefix : string ) {
231233 if ( ! url ) return url
232234 if ( url . startsWith ( '#' ) ) {
233235 if ( url . startsWith ( '#user-content' ) ) {
234236 return url
235237 }
236238 // Prefix anchor links to match heading IDs (avoids collision with page IDs)
237- return `#user-content -${ url . slice ( 1 ) } `
239+ return `#${ idPrefix } -${ url . slice ( 1 ) } `
238240 }
239241 if ( hasProtocol ( url , { acceptRelative : true } ) ) {
240242 try {
0 commit comments