Skip to content

Commit

Permalink
Add warning about using linkify option
Browse files Browse the repository at this point in the history
  • Loading branch information
TrySound committed Jul 24, 2019
1 parent d887353 commit 766f50a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ function Remarkable(preset, options) {
preset = 'default';
}

if (options && options.linkify != null) {
console.warn(
'linkify option is removed. Use linkify plugin instead:\n\n' +
'import Remarkable from \'remarkable\';\n' +
'import linkify from \'remarkable/linkify\';\n' +
'new Remarkable().use(linkify)\n'
);
}

this.inline = new ParserInline();
this.block = new ParserBlock();
this.core = new ParserCore();
Expand Down
17 changes: 17 additions & 0 deletions test/linkify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from 'path';
import assert from 'assert';
import { addTests } from './utils';
import Remarkable from '../lib/index';
import linkify from '../lib/linkify';
Expand All @@ -7,3 +8,19 @@ describe('linkify plugin', function () {
var md = new Remarkable({ html: true }).use(linkify);
addTests(path.join(__dirname, 'fixtures/linkify.txt'), md);
});

describe('linkify option', function () {
it('should warn about using linkify option instead of plugin', () => {
const messages = []
const oldWarn = console.warn;
console.warn = message => messages.push(message);
var md = new Remarkable({ html: true, linkify: true });
console.warn = oldWarn;
assert.deepEqual(messages, [
`linkify option is removed. Use linkify plugin instead:\n\n` +
`import Remarkable from 'remarkable';\n` +
`import linkify from 'remarkable/linkify';\n` +
`new Remarkable().use(linkify)\n`
])
});
});

0 comments on commit 766f50a

Please sign in to comment.