From e545fc62a6b7ba5d898861280ec56dd26bfcbf3d Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Wed, 6 Nov 2019 20:53:27 +0900 Subject: [PATCH 1/2] Remove dollar prefix plugin for obsolated syntax --- src/dollar/dollar.ts | 20 ---------------- src/marp.ts | 6 ----- test/marp.ts | 57 -------------------------------------------- 3 files changed, 83 deletions(-) delete mode 100644 src/dollar/dollar.ts diff --git a/src/dollar/dollar.ts b/src/dollar/dollar.ts deleted file mode 100644 index 115ba8e1..00000000 --- a/src/dollar/dollar.ts +++ /dev/null @@ -1,20 +0,0 @@ -import marpitPlugin from '@marp-team/marpit/lib/markdown/marpit_plugin' -import { Marp } from '../marp' - -// TODO: Remove dollar prefix support after making be known deprecation to user of GUI tools like Marp for VS Code -export const markdown = marpitPlugin(({ marpit: marp }: { marpit: Marp }) => { - if (!marp.options.dollarPrefixForGlobalDirectives) return - - const customGlobalDirectives = Object.keys(marp.customDirectives.global) - - // Marpit built-in directives - marp.customDirectives.global.$theme = v => ({ theme: v }) - marp.customDirectives.global.$style = v => ({ style: v }) - marp.customDirectives.global.$headingDivider = v => ({ headingDivider: v }) - - // Custom global directives (e.g. `$size`) - for (const d of customGlobalDirectives) { - marp.customDirectives.global[`$${d}`] = v => - marp.customDirectives.global[d](v) - } -}) diff --git a/src/marp.ts b/src/marp.ts index 8377f5c2..b702b20f 100644 --- a/src/marp.ts +++ b/src/marp.ts @@ -6,7 +6,6 @@ import postcssMinifySelectors from 'postcss-minify-selectors' import postcssNormalizeWhitespace from 'postcss-normalize-whitespace' import { version } from 'katex/package.json' import browser from './browser' -import * as dollarPlugin from './dollar/dollar' import * as emojiPlugin from './emoji/emoji' import * as fittingPlugin from './fitting/fitting' import * as htmlPlugin from './html/html' @@ -30,9 +29,6 @@ export interface MarpOptions extends MarpitOptions { math?: mathPlugin.MathOptions minifyCSS?: boolean script?: boolean | scriptPlugin.ScriptOptions - - /** @deprecated Dollar prefix for global directives is removed feature in Marpit framework, and Marp Core does not recommend too. Please use only for keeping compatibility in limited cases. */ - dollarPrefixForGlobalDirectives?: boolean } const styleMinifier = postcss([ @@ -55,7 +51,6 @@ export class Marp extends Marpit { math: true, minifyCSS: true, script: true, - dollarPrefixForGlobalDirectives: false, ...opts, emoji: { shortcode: 'twemoji', @@ -95,7 +90,6 @@ export class Marp extends Marpit { .use(mathPlugin.markdown, flag => (this.renderedMath = flag)) .use(fittingPlugin.markdown) .use(sizePlugin.markdown) - .use(dollarPlugin.markdown) .use(scriptPlugin.markdown) } diff --git a/test/marp.ts b/test/marp.ts index 1937e46a..69818a75 100644 --- a/test/marp.ts +++ b/test/marp.ts @@ -665,63 +665,6 @@ describe('Marp', () => { }) }) - describe('dollarPrefixForGlobalDirectives option', () => { - it('cannot use dollar prefix for global directives by default', () => { - const instance = marp({ minifyCSS: false }) - - // $theme - expect(instance.render('').css).not.toContain( - '@theme gaia' - ) - - // $style - expect( - instance.render('').css - ).not.toContain('color: orange') - - // $headingDivider - expect( - instance.render('\n\n# 1\n# 2', { - htmlAsArray: true, - }).html - ).toHaveLength(1) - - // $size (Custom directives extended by Marp Core) - const [html] = instance.render('', { - htmlAsArray: true, - }).html - expect(html).not.toContain('0 0 960 720') - }) - - context('with true', () => { - it('can use dollar prefix as aliases for global directives', () => { - const instance = marp({ - dollarPrefixForGlobalDirectives: true, - minifyCSS: false, - }) - - expect(instance.render('').css).toContain( - '@theme gaia' - ) - - expect( - instance.render('').css - ).toContain('color: orange') - - expect( - instance.render('\n\n# 1\n# 2', { - htmlAsArray: true, - }).html - ).toHaveLength(2) - - const [html] = instance.render('', { - htmlAsArray: true, - }).html - expect(html).toContain('0 0 960 720') - }) - }) - }) - describe('size global directive', () => { it('defines size custom global directive', () => expect(marp().customDirectives.global.size).toBeTruthy()) From 6a540f8e238d08911f332b84e5b4ce309df083e2 Mon Sep 17 00:00:00 2001 From: Yuki Hattori Date: Wed, 6 Nov 2019 21:18:28 +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 705e7986..0ed8c11b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ - Upgrade Marpit to [v1.4.2](https://github.com/marp-team/marpit/releases/v1.4.2) ([#126](https://github.com/marp-team/marp-core/pull/126)) - Upgrade dependent packages to the latest version ([#126](https://github.com/marp-team/marp-core/pull/126)) +### Removed + +- Remove dollar prefix plugin for obsolated syntax ([#127](https://github.com/marp-team/marp-core/pull/127)) + ## v0.15.0 - 2019-11-05 ### Added