Skip to content

Commit e380541

Browse files
authored
Merge pull request #678 from hackmdio/fix-anchor-id-case-sensitive
Fix anchor id to keep uppercase characters
2 parents 5f84906 + 919b746 commit e380541

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

public/js/extra.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,11 @@ export function renderTags (view) {
156156
}
157157

158158
function slugifyWithUTF8 (text) {
159-
let newText = S(text.toLowerCase()).trim().stripTags().dasherize().s
159+
// remove html tags and trim spaces
160+
let newText = S(text).trim().stripTags().s
161+
// replace all spaces in between to dashes
162+
newText = newText.replace(/\s+/g, '-')
163+
// slugify string to make it valid for attribute
160164
newText = newText.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g, '')
161165
return newText
162166
}

0 commit comments

Comments
 (0)