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

Output deprecation warning when use dollar prefix in global directive #183

Merged
merged 11 commits into from
Aug 11, 2019

Conversation

yhatt
Copy link
Member

@yhatt yhatt commented Aug 7, 2019

Marpit will output deprecation warning when using dollar-prefixed global directive. See also #182.

It would be hard to notice this warning if user is using GUI tool like Marp Web and Marp for VS Code. Marp CLI user can see this warning in console.

Prefix removal will do step by step to avoid confusion. We are planning to provide (optional) prefixed custom directives in Marp Core. We have to remove meta filter, to override built-in meta by using custom defined directive for Marp Core.

ToDo

  • Output deprecation warning when using dollar prefix
  • Remove meta filter in custom directives for setting the value of built-in directives (Allows providing the escape hatch in Marp Core)

const globalKey = key.startsWith('$') ? key.slice(1) : key
const globalKey = key.startsWith('$')
? (() => {
if (marpit.customDirectives.global[key]) return key
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use an original directive key without warning if the dollar-prefixed custom global directive was defined.


for (const prop of Object.keys(newProps)) {
if (builtinDirectives[prop]) {
ret = { ...ret, ...builtinDirectives[prop](newProps[prop], marpit) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When aliasing from custom directive to built-in directive, we will re-apply function of built-in directives to allow only valid value.

yhatt added 3 commits August 12, 2019 04:33
- Remove an example of global directive with dollar prefix
- Add advanced section to explain about custom directives
@yhatt yhatt changed the title Output deprecation warning when use dollar prefix Output deprecation warning when use dollar prefix in global directive Aug 11, 2019
@yhatt
Copy link
Member Author

yhatt commented Aug 11, 2019

A usage of custom directives was well-organized by the change of this PR. Thus, I've updated document of directives to explain about custom directives.
https://deploy-preview-183--marpit.netlify.com/directives?id=advanced

@yhatt yhatt merged commit 0be285c into master Aug 11, 2019
@yhatt yhatt deleted the deprecate-dollar-prefix branch August 11, 2019 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant