fix(ghCompatibleHeaderId): add % as an escaped char

This commit is contained in:
Estevao Soares dos Santos 2016-12-30 19:21:03 +00:00
parent db97a90d5b
commit 3102615ec2
7 changed files with 3 additions and 3 deletions

View File

@ -189,7 +189,7 @@ var defaultOptions = showdown.getDefaultOptions();
* **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids. Setting to true overrides **prefixHeaderId** * **noHeaderId**: (boolean) [default false] Disable the automatic generation of header ids. Setting to true overrides **prefixHeaderId**
* **ghCompatibleHeaderId**: (boolean) [default false] Generate header ids compatible with github style (spaces are replaced with dashes, ][&~$!@#*()=:/,;?+'.\ chars are removed * **ghCompatibleHeaderId**: (boolean) [default false] Generate header ids compatible with github style (spaces are replaced with dashes, ][&~$!@#*()=:/,;?+'.%\ chars are removed
* **prefixHeaderId**: (string/boolean) [default false] Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to `true` will add a generic 'section' prefix. * **prefixHeaderId**: (string/boolean) [default false] Add a prefix to the generated header ids. Passing a string will prefix that string to the header id. Setting to `true` will add a generic 'section' prefix.

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -23,7 +23,7 @@ function getDefaultOpts(simple) {
}, },
ghCompatibleHeaderId: { ghCompatibleHeaderId: {
defaultValue: false, defaultValue: false,
describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, &~$!@#*()=:/,;?+\'. chars are removed)', describe: 'Generate header ids compatible with github style (spaces are replaced with dashes, &~$!@#*()=:/,;?+%\\\'. chars are removed)',
type: 'string' type: 'string'
}, },
headerLevelStart: { headerLevelStart: {

View File

@ -63,7 +63,7 @@ showdown.subParser('headers', function (text, options, globals) {
.replace(/~T/g, '') .replace(/~T/g, '')
.replace(/~D/g, '') .replace(/~D/g, '')
//replace rest of the chars (&~$ are repeated as they might have been escaped) //replace rest of the chars (&~$ are repeated as they might have been escaped)
.replace(/[&~$!@#*()=:/,;?+'.\\]/g, '') .replace(/[&~$!@#*()=:/,;?+'.%\\]/g, '')
.toLowerCase(); .toLowerCase();
} else { } else {
escapedId = m.replace(/[^\w]/g, '').toLowerCase(); escapedId = m.replace(/[^\w]/g, '').toLowerCase();