* Don't replace leading digit

* Install css.escape

* Escape leading digit of the anchor id
This commit is contained in:
Atsushi Tanaka
2020-02-05 22:23:05 +05:30
committed by GitHub
parent 2928eb7e55
commit 90a35ab952
4 changed files with 9 additions and 2 deletions
+6
View File
@@ -3263,6 +3263,12 @@
"integrity": "sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==",
"dev": true
},
"css.escape": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
"integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=",
"dev": true
},
"cssesc": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-2.0.0.tgz",
+1
View File
@@ -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",
+2 -1
View File
@@ -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
@@ -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)]
-1
View File
@@ -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