diff --git a/theme/toc.js.hbs b/theme/toc.js.hbs
index 5bc3c97a3..98e817b97 100644
--- a/theme/toc.js.hbs
+++ b/theme/toc.js.hbs
@@ -10,7 +10,9 @@ class MDBookSidebarScrollbox extends HTMLElement {
connectedCallback() {
// Modify TOC to support external links
var toc = '{{#toc}}{{/toc}}';
- toc = toc.replace(/
([^$<>]*)\$\$external:([^$<>]*)\$\$<\/div>/g, '
$1')
+ // Handle both old mdbook (
) and new mdbook 0.5 (
) formats
+ // External links open in new tab with external link icon
+ toc = toc.replace(/<(div|span)>([^$<>]*)\$\$external:([^$<>]*)\$\$<\/(div|span)>/g, '$2 ↗')
this.innerHTML = toc
// Set the current, active page, and reveal it if it's hidden
let current_page = document.location.href.toString();