From 3104b0f81e13671cb901123577ea08e00c67f414 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Wed, 11 Sep 2019 20:46:31 +0900 Subject: [PATCH 1/2] Remove dollar prefix alias for global directive --- src/markdown/directives/parse.js | 21 ++++----------------- test/markdown/directives/parse.js | 16 +++++++--------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/markdown/directives/parse.js b/src/markdown/directives/parse.js index a49a29e2..f978d8f2 100644 --- a/src/markdown/directives/parse.js +++ b/src/markdown/directives/parse.js @@ -76,31 +76,18 @@ function parse(md, opts = {}) { let recognized = false for (const key of Object.keys(obj)) { - const globalKey = key.startsWith('$') - ? (() => { - if (marpit.customDirectives.global[key]) return key - - console.warn( - `Deprecation warning: Dollar prefix support for global directive "${key}" is deprecated and will remove soon. Just remove "$" from "${key}" to fix ("${key.slice( - 1 - )}").` - ) - return key.slice(1) - })() - : key - - if (directives.globals[globalKey]) { + if (directives.globals[key]) { recognized = true globalDirectives = { ...globalDirectives, - ...directives.globals[globalKey](obj[key], marpit), + ...directives.globals[key](obj[key], marpit), } - } else if (marpit.customDirectives.global[globalKey]) { + } else if (marpit.customDirectives.global[key]) { recognized = true globalDirectives = { ...globalDirectives, ...applyBuiltinDirectives( - marpit.customDirectives.global[globalKey](obj[key], marpit), + marpit.customDirectives.global[key](obj[key], marpit), directives.globals ), } diff --git a/test/markdown/directives/parse.js b/test/markdown/directives/parse.js index 32340c86..9d6d09a3 100644 --- a/test/markdown/directives/parse.js +++ b/test/markdown/directives/parse.js @@ -72,10 +72,13 @@ describe('Marpit directives parse plugin', () => { it('applies meta to all slides', () => { const parsed = md().parse(text) - parsed.forEach(t => { - if (t.type === 'marpit_slide_open') - expect(t.meta.marpitDirectives).toStrictEqual(expected) - }) + const slides = parsed.filter(t => t.type === 'marpit_slide_open') + + expect.assertions(slides.length) + + for (const { meta } of slides) { + expect(meta.marpitDirectives).toStrictEqual(expected) + } }) it('applies global directives to Marpit instance', () => { @@ -86,11 +89,6 @@ describe('Marpit directives parse plugin', () => { expect(marpitStub.lastGlobalDirectives).toStrictEqual({}) }) - it('allows global directive name prefixed "$" [DEPRECATED]', () => { - md().parse('') - expect(marpitStub.lastGlobalDirectives).toStrictEqual(expected) - }) - it('marks directive comments as parsed', () => { const findToken = tk => tk.find(t => t.type === 'marpit_comment') From 893d2639d092b45847af6b46ea19dfd40fd8d8bc Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Wed, 11 Sep 2019 21:05:38 +0900 Subject: [PATCH 2/2] [ci skip] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2dc64a6..9e2f6268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Update CircleCI configuration to use v2.1 ([#187](https://github.com/marp-team/marpit/pull/187)) +### Removed + +- Deprecated dollar prefix alias for global directive ([#182](https://github.com/marp-team/marpit/issues/182), [#189](https://github.com/marp-team/marpit/pull/189)) + ## v1.3.2 - 2019-08-23 ### Fixed