Skip to content

Commit 90a35ab

Browse files
authored
Fix #895 (#896)
* Don't replace leading digit * Install css.escape * Escape leading digit of the anchor id
1 parent 2928eb7 commit 90a35ab

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
"conventional-changelog-cli": "^2.0.25",
7575
"copy-dir": "^1.2.0",
7676
"cross-env": "^6.0.3",
77+
"css.escape": "^1.5.1",
7778
"cssnano": "^4.1.10",
7879
"cypress": "^3.8.1",
7980
"cypress-image-snapshot": "^3.1.1",

src/core/event/scroll.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { isMobile } from '../util/env'
22
import * as dom from '../util/dom'
33
import Tweezer from 'tweezer.js'
4+
import cssEscape from 'css.escape'
45

56
const nav = {}
67
let hoverOver = false
@@ -138,7 +139,7 @@ export function scrollIntoView(path, id) {
138139
return
139140
}
140141

141-
const section = dom.find('#' + id)
142+
const section = dom.find('#' + cssEscape(id))
142143
section && scrollTo(section)
143144

144145
const li = nav[getNavKey(path, id)]

src/core/render/slugify.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export function slugify(str) {
1919
.replace(re, '')
2020
.replace(/\s/g, '-')
2121
.replace(/-+/g, '-')
22-
.replace(/^(\d)/, '_$1')
2322
let count = cache[slug]
2423

2524
count = hasOwn.call(cache, slug) ? count + 1 : 0

0 commit comments

Comments
 (0)