|
@ -1,72 +1,85 @@ |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var markdownit = require('../'); |
|
|
const markdownit = require('../'); |
|
|
|
|
|
const needle = require('needle'); |
|
|
|
|
|
const assert = require('assert'); |
|
|
describe('Pathological sequences speed', function () { |
|
|
const crypto = require('crypto'); |
|
|
|
|
|
|
|
|
|
|
|
describe('Pathological sequences speed', () => { |
|
|
|
|
|
|
|
|
|
|
|
// Ported from cmark, https://github.com/commonmark/cmark/blob/master/test/pathological_tests.py
|
|
|
|
|
|
describe('Cmark', () => { |
|
|
|
|
|
|
|
|
|
|
|
it('verify original source crc', async () => { |
|
|
|
|
|
/* eslint-disable max-len */ |
|
|
|
|
|
const src = await needle('get', 'https://raw.githubusercontent.com/commonmark/cmark/master/test/pathological_tests.py'); |
|
|
|
|
|
const src_md5 = crypto.createHash('md5').update(src.body).digest('hex'); |
|
|
|
|
|
|
|
|
|
|
|
assert.strictEqual( |
|
|
|
|
|
src_md5, |
|
|
|
|
|
require('./pathological.json').md5, |
|
|
|
|
|
'CRC or cmark pathological tests hanged. Verify and update pathological.json' |
|
|
|
|
|
); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
describe('Cmark', function () { |
|
|
it('nested strong emph', () => { |
|
|
//
|
|
|
|
|
|
// Ported from cmark, https://github.com/commonmark/cmark/blob/master/test/pathological_tests.py
|
|
|
|
|
|
//
|
|
|
|
|
|
it('nested strong emph', function () { |
|
|
|
|
|
markdownit().render('*a **a '.repeat(5000) + 'b' + ' a** a*'.repeat(5000)); |
|
|
markdownit().render('*a **a '.repeat(5000) + 'b' + ' a** a*'.repeat(5000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('many emph closers with no openers', function () { |
|
|
it('many emph closers with no openers', () => { |
|
|
markdownit().render('a_ '.repeat(30000)); |
|
|
markdownit().render('a_ '.repeat(30000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('many emph openers with no closers', function () { |
|
|
it('many emph openers with no closers', () => { |
|
|
markdownit().render('_a '.repeat(30000)); |
|
|
markdownit().render('_a '.repeat(30000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('many link closers with no openers', function () { |
|
|
it('many link closers with no openers', () => { |
|
|
markdownit().render('a]'.repeat(10000)); |
|
|
markdownit().render('a]'.repeat(10000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('many link openers with no closers', function () { |
|
|
it('many link openers with no closers', () => { |
|
|
markdownit().render('[a'.repeat(10000)); |
|
|
markdownit().render('[a'.repeat(10000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('mismatched openers and closers', function () { |
|
|
it('mismatched openers and closers', () => { |
|
|
markdownit().render('*a_ '.repeat(50000)); |
|
|
markdownit().render('*a_ '.repeat(50000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('openers and closers multiple of 3', function () { |
|
|
it('openers and closers multiple of 3', () => { |
|
|
markdownit().render('a**b' + ('c* '.repeat(50000))); |
|
|
markdownit().render('a**b' + ('c* '.repeat(50000))); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('link openers and emph closers', function () { |
|
|
it('link openers and emph closers', () => { |
|
|
markdownit().render('[ a_'.repeat(10000)); |
|
|
markdownit().render('[ a_'.repeat(10000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('pattern [ (]( repeated', function () { |
|
|
it('pattern [ (]( repeated', () => { |
|
|
markdownit().render('[ (]('.repeat(40000)); |
|
|
markdownit().render('[ (]('.repeat(40000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('nested brackets', function () { |
|
|
it('nested brackets', () => { |
|
|
markdownit().render('['.repeat(20000) + 'a' + ']'.repeat(20000)); |
|
|
markdownit().render('['.repeat(20000) + 'a' + ']'.repeat(20000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('nested block quotes', function () { |
|
|
it('nested block quotes', () => { |
|
|
markdownit().render('> '.repeat(50000) + 'a'); |
|
|
markdownit().render('> '.repeat(50000) + 'a'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('deeply nested lists', function () { |
|
|
it('deeply nested lists', () => { |
|
|
markdownit().render(Array(1000).fill(0).map(function (_, x) { return ' '.repeat(x) + '* a\n'; }).join('')); |
|
|
markdownit().render(Array(1000).fill(0).map(function (_, x) { return ' '.repeat(x) + '* a\n'; }).join('')); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('backticks', function () { |
|
|
it('backticks', () => { |
|
|
markdownit().render(Array(3000).fill(0).map(function (_, x) { return 'e' + '`'.repeat(x); }).join('')); |
|
|
markdownit().render(Array(3000).fill(0).map(function (_, x) { return 'e' + '`'.repeat(x); }).join('')); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('unclosed links A', function () { |
|
|
it('unclosed links A', () => { |
|
|
markdownit().render('[a](<b'.repeat(30000)); |
|
|
markdownit().render('[a](<b'.repeat(30000)); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('unclosed links B', function () { |
|
|
it('unclosed links B', () => { |
|
|
markdownit().render('[a](b'.repeat(30000)); |
|
|
markdownit().render('[a](b'.repeat(30000)); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|