File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,9 @@ class MDBookSidebarScrollbox extends HTMLElement {
1010 connectedCallback() {
1111 // Modify TOC to support external links
1212 var toc = '{{ #toc }} {{ /toc }} ';
13- toc = toc.replace(/<div >([^$<> ]*)\$\$external:([^$<> ]*)\$\$< \/div>/g, '<a class =" external-link" href =" $2" >$1</a >')
13+ // Handle both old mdbook (<div >) and new mdbook 0.5 (<span >) formats
14+ // External links open in new tab with external link icon
15+ toc = toc.replace(/< (div|span)>([^$<> ]*)\$\$external:([^$<> ]*)\$\$< \/(div|span)>/g, '<a class =" external-link" href =" $3" target =" _blank" rel =" noopener noreferrer" >$2 ↗</a >')
1416 this.innerHTML = toc
1517 // Set the current, active page, and reveal it if it's hidden
1618 let current_page = document.location.href.toString();
You can’t perform that action at this time.
0 commit comments