Skip to content

Commit

Permalink
Fix #895 (#896)
Browse files Browse the repository at this point in the history
* Don't replace leading digit

* Install css.escape

* Escape leading digit of the anchor id
  • Loading branch information
bgpat authored Feb 5, 2020
1 parent 2928eb7 commit 90a35ab
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"conventional-changelog-cli": "^2.0.25",
"copy-dir": "^1.2.0",
"cross-env": "^6.0.3",
"css.escape": "^1.5.1",
"cssnano": "^4.1.10",
"cypress": "^3.8.1",
"cypress-image-snapshot": "^3.1.1",
Expand Down
3 changes: 2 additions & 1 deletion src/core/event/scroll.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { isMobile } from '../util/env'
import * as dom from '../util/dom'
import Tweezer from 'tweezer.js'
import cssEscape from 'css.escape'

const nav = {}
let hoverOver = false
Expand Down Expand Up @@ -138,7 +139,7 @@ export function scrollIntoView(path, id) {
return
}

const section = dom.find('#' + id)
const section = dom.find('#' + cssEscape(id))
section && scrollTo(section)

const li = nav[getNavKey(path, id)]
Expand Down
1 change: 0 additions & 1 deletion src/core/render/slugify.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function slugify(str) {
.replace(re, '')
.replace(/\s/g, '-')
.replace(/-+/g, '-')
.replace(/^(\d)/, '_$1')
let count = cache[slug]

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

0 comments on commit 90a35ab

Please sign in to comment.