Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dollar prefix alias for global directive #189

Merged
merged 2 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 4 additions & 17 deletions src/markdown/directives/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
),
}
Expand Down
16 changes: 7 additions & 9 deletions test/markdown/directives/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -86,11 +89,6 @@ describe('Marpit directives parse plugin', () => {
expect(marpitStub.lastGlobalDirectives).toStrictEqual({})
})

it('allows global directive name prefixed "$" [DEPRECATED]', () => {
md().parse('<!-- $theme: test_theme -->')
expect(marpitStub.lastGlobalDirectives).toStrictEqual(expected)
})

it('marks directive comments as parsed', () => {
const findToken = tk => tk.find(t => t.type === 'marpit_comment')

Expand Down