Browse Source

Removed unnecessary conditions

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
d917047d32
  1. 5
      lib/parser_block.js
  2. 6
      lib/rules_core/linkify.js
  3. 6
      test/misc.js

5
lib/parser_block.js

@ -62,11 +62,6 @@ ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
if (ok) { break; } if (ok) { break; }
} }
/* istanbul ignore if */
if (!ok) { throw new Error('No matching rules found'); }
/* istanbul ignore if */
if (line === state.line) { throw new Error('None of rules updated state.line'); }
// set state.tight iff we had an empty line before current tag // set state.tight iff we had an empty line before current tag
// i.e. latest empty line should not count // i.e. latest empty line should not count
state.tight = !hasEmptyLines; state.tight = !hasEmptyLines;

6
lib/rules_core/linkify.js

@ -31,6 +31,7 @@ function createLinkifier() {
replaceFn: function (autolinker, match) { replaceFn: function (autolinker, match) {
// Only collect matched strings but don't change anything. // Only collect matched strings but don't change anything.
switch (match.getType()) { switch (match.getType()) {
/*eslint default-case:0*/
case 'url': case 'url':
links.push({ links.push({
text: match.matchedText, text: match.matchedText,
@ -44,8 +45,6 @@ function createLinkifier() {
url: 'mailto:' + match.getEmail().replace(/^mailto:/i, '') url: 'mailto:' + match.getEmail().replace(/^mailto:/i, '')
}); });
break; break;
/* istanbul ignore next */
default:
} }
return false; return false;
} }
@ -121,9 +120,6 @@ module.exports = function linkify(state) {
pos = text.indexOf(links[ln].text); pos = text.indexOf(links[ln].text);
/* istanbul ignore next */
if (pos === -1) { continue; } // that should never happen
if (pos) { if (pos) {
level = level; level = level;
nodes.push({ nodes.push({

6
test/misc.js

@ -96,14 +96,16 @@ describe('API', function () {
var md = new Remarkable({ breaks: true }); var md = new Remarkable({ breaks: true });
assert.strictEqual(md.render('a\nb'), '<p>a<br>\nb</p>\n'); assert.strictEqual(md.render('a\nb'), '<p>a<br>\nb</p>\n');
md.set({ xhtmlOut: true })
assert.strictEqual(md.render('a\nb'), '<p>a<br />\nb</p>\n');
}); });
it('xhtmlOut enabled', function () { it('xhtmlOut enabled', function () {
var md = new Remarkable({ breaks: true, xhtmlOut: true }); var md = new Remarkable({ xhtmlOut: true });
assert.strictEqual(md.render('---'), '<hr />\n'); assert.strictEqual(md.render('---'), '<hr />\n');
assert.strictEqual(md.render('![]()'), '<p><img src="" alt="" /></p>\n'); assert.strictEqual(md.render('![]()'), '<p><img src="" alt="" /></p>\n');
assert.strictEqual(md.render('a\nb'), '<p>a<br />\nb</p>\n'); assert.strictEqual(md.render('a \\\nb'), '<p>a <br />\nb</p>\n');
}); });
it('xhtmlOut disabled', function () { it('xhtmlOut disabled', function () {

Loading…
Cancel
Save