From 766f50a3a547eb6278dc1711e37cd522f1ce306a Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Wed, 24 Jul 2019 18:08:34 +0300 Subject: [PATCH] Add warning about using linkify option --- lib/index.js | 9 +++++++++ test/linkify.js | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/index.js b/lib/index.js index 853778e5..c8f19b1f 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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(); diff --git a/test/linkify.js b/test/linkify.js index a93ceb0b..733dd8ed 100644 --- a/test/linkify.js +++ b/test/linkify.js @@ -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'; @@ -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` + ]) + }); +});