mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 14:52:52 +01:00
fix: fix TOC highlight for non-ASCII titles (#246)
This commit is contained in:
@@ -183,7 +183,7 @@ class TableOfContents extends HTMLElement {
|
||||
.find((element) => element instanceof HTMLAnchorElement);
|
||||
|
||||
if (anchor) {
|
||||
const id = anchor.hash?.substring(1);
|
||||
const id = decodeURIComponent(anchor.hash?.substring(1));
|
||||
const idx = this.headingIdxMap.get(id);
|
||||
if (idx !== undefined) {
|
||||
this.anchorNavTarget = this.headings[idx];
|
||||
@@ -227,7 +227,7 @@ class TableOfContents extends HTMLElement {
|
||||
|
||||
this.headings = new Array(this.tocEntries.length);
|
||||
for (let i = 0; i < this.tocEntries.length; i++) {
|
||||
const id = this.tocEntries[i].hash?.substring(1);
|
||||
const id = decodeURIComponent(this.tocEntries[i].hash?.substring(1));
|
||||
const section = document.getElementById(id)?.parentElement;
|
||||
if (section instanceof HTMLElement) {
|
||||
this.headings[i] = section;
|
||||
|
||||
Reference in New Issue
Block a user