File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -358,9 +358,19 @@ export class View extends HTMLElement {
358358 Promise . resolve ( this . #emit( 'external-link' , { a, href } , true ) )
359359 . then ( x => x ? globalThis . open ( href , '_blank' ) : null )
360360 . catch ( e => console . error ( e ) )
361- else Promise . resolve ( this . #emit( 'link' , { a, href } , true ) )
362- . then ( x => x ? this . goTo ( href ) : null )
363- . catch ( e => console . error ( e ) )
361+ else {
362+ let internalHref = href
363+ if ( ! book . resolveHref ( href_ ) ) {
364+ const hashIndex = href_ . indexOf ( '#' )
365+ if ( hashIndex >= 0 ) {
366+ const hash = href_ . slice ( hashIndex )
367+ internalHref = section ?. resolveHref ?. ( hash ) ?? href
368+ }
369+ }
370+ Promise . resolve ( this . #emit( 'link' , { a, href : internalHref } , true ) )
371+ . then ( x => x ? this . goTo ( internalHref ) : null )
372+ . catch ( e => console . error ( e ) )
373+ }
364374 } )
365375 }
366376 async addAnnotation ( annotation , remove ) {
You can’t perform that action at this time.
0 commit comments