mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(headerLevelStart): fix for NaN error when specifying a non number as headerLevelStart param
This commit is contained in:
parent
7e55bceb0e
commit
be72b4879f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -4,3 +4,4 @@
|
|||
node_modules
|
||||
npm-debug.log
|
||||
localtest.html
|
||||
/*.test.*
|
||||
|
|
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -1,7 +1,8 @@
|
|||
showdown.subParser('headers', function (text, options, globals) {
|
||||
'use strict';
|
||||
|
||||
var prefixHeader = options.prefixHeaderId;
|
||||
var prefixHeader = options.prefixHeaderId,
|
||||
headerLevelStart = (isNaN(parseInt(options.headerLevelStart))) ? 1 : parseInt(options.headerLevelStart);
|
||||
|
||||
// Set text-style headers:
|
||||
// Header 1
|
||||
|
@ -13,16 +14,16 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||
text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm, function (wholeMatch, m1) {
|
||||
|
||||
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
|
||||
hLevel = parseInt(options.headerLevelStart),
|
||||
hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
|
||||
hLevel = headerLevelStart,
|
||||
hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
|
||||
return showdown.subParser('hashBlock')(hashBlock, options, globals);
|
||||
});
|
||||
|
||||
text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, function (matchFound, m1) {
|
||||
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
|
||||
hLevel = parseInt(options.headerLevelStart) + 1,
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
|
||||
hLevel = headerLevelStart + 1,
|
||||
hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
|
||||
return showdown.subParser('hashBlock')(hashBlock, options, globals);
|
||||
});
|
||||
|
@ -48,9 +49,9 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||
|
||||
text = text.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm, function (wholeMatch, m1, m2) {
|
||||
var span = showdown.subParser('spanGamut')(m2, options, globals),
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
|
||||
hLevel = parseInt(options.headerLevelStart) - 1 + m1.length,
|
||||
header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
|
||||
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m2) + '"',
|
||||
hLevel = headerLevelStart - 1 + m1.length,
|
||||
header = '<h' + hLevel + hID + '>' + span + '</h' + hLevel + '>';
|
||||
|
||||
return showdown.subParser('hashBlock')(header, options, globals);
|
||||
});
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/**
|
||||
* Created by Estevao on 10-07-2015.
|
||||
*/
|
||||
/*
|
||||
var showdown = require('../dist/showdown.js'),
|
||||
bootstrap = require('./bootstrap.js'),
|
||||
assertion = bootstrap.assertion,
|
||||
testsuite = bootstrap.getTestSuite('test/features/');
|
||||
|
||||
describe('makeHtml() single test', function () {
|
||||
'use strict';
|
||||
});
|
||||
*/
|
Loading…
Reference in New Issue
Block a user