Skip to content

Commit

Permalink
Merge pull request #189 from marp-team/remove-dollar-prefix
Browse files Browse the repository at this point in the history
Remove dollar prefix alias for global directive
  • Loading branch information
yhatt authored Sep 11, 2019
2 parents 1538472 + 893d263 commit 4a8e0f1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 26 deletions.
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

0 comments on commit 4a8e0f1

Please sign in to comment.