Skip to content

Commit 22cd129

Browse files
authored
Merge pull request #291 from AyshaHakeem/wiki-fix
fix: section heading links
2 parents a7177b4 + 7e46217 commit 22cd129

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

wiki/public/js/wiki.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ window.Wiki = class Wiki {
3232
$(".doc-sidebar,.web-sidebar").on(
3333
"click",
3434
".collapsible",
35-
this.toggle_sidebar,
35+
this.toggle_sidebar
3636
);
3737

3838
$(".sidebar-item.active")
@@ -46,7 +46,7 @@ window.Wiki = class Wiki {
4646

4747
set_last_updated_date() {
4848
const lastUpdatedDate = frappe.datetime.prettyDate(
49-
$(".user-contributions").data("date"),
49+
$(".user-contributions").data("date")
5050
);
5151
$(".user-contributions").append(`last updated ${lastUpdatedDate}`);
5252
}
@@ -57,7 +57,7 @@ window.Wiki = class Wiki {
5757
const src = $(".navbar-brand img").attr("src");
5858
if (
5959
!["{{ light_mode_logo }}", "{{ dark_mode_logo }}", "None", ""].includes(
60-
altSrc,
60+
altSrc
6161
)
6262
) {
6363
$(".navbar-brand img").attr("src", altSrc);
@@ -96,7 +96,9 @@ window.Wiki = class Wiki {
9696
const text = $heading.textContent.trim();
9797
$heading.id = text
9898
.replace(/[^\u00C0-\u1FFF\u2C00-\uD7FF\w\- ]/g, "")
99-
.replace(/[ ]/g, "-");
99+
.replace(/[ ]/g, "-")
100+
.toLowerCase();
101+
100102
let id = $heading.id;
101103
let $a = $('<a class="no-underline">')
102104
.prop("href", "#" + id)
@@ -115,7 +117,7 @@ window.Wiki = class Wiki {
115117
$("pre code")
116118
.parent("pre")
117119
.prepend(
118-
`<button title="Copy Code" class="btn copy-btn" data-toggle="tooltip"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clipboard"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg></button>`,
120+
`<button title="Copy Code" class="btn copy-btn" data-toggle="tooltip"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clipboard"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg></button>`
119121
);
120122

121123
$(".copy-btn").on("click", function () {

wiki/wiki/doctype/wiki_page/wiki_page.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def calculate_toc_html(self, html):
188188
toc_html = ""
189189
for heading in headings:
190190
title = heading.get_text().strip()
191-
heading_id = re.sub(r"[^a-zA-Z0-9]+", "-", title.lower())
191+
heading_id = re.sub(r"[^\u00C0-\u1FFF\u2C00-\uD7FF\w\- ]", "", title).replace(" ", "-").lower()
192192
heading["id"] = heading_id
193193
title = heading.get_text().strip()
194194
level = int(heading.name[1])

0 commit comments

Comments
 (0)