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

allow simple markdown plugin loading #585

Closed
neumayr opened this issue Jun 14, 2018 · 4 comments · Fixed by #1422
Closed

allow simple markdown plugin loading #585

neumayr opened this issue Jun 14, 2018 · 4 comments · Fixed by #1422
Labels
type: feature request Request to add a new feature version: next Planned to do or already included in the next(1.0.0) version

Comments

@neumayr
Copy link

neumayr commented Jun 14, 2018

Feature request

What problem does this feature solve?

markdown.config currently requires a javascript function argument. This is only manageable with a config.js setup. I would like to allow markdown plugin loading also from a config.yml file.
Similar requests, see #326 & #579

What does the proposed API look like?

I would propose a markdown.plugins endpoint that requires an Array. See implementation example.

How should this be implemented in your opinion?

# .vuepress/config.yml
markdown:
  lineNumbers: true
  plugins:
    - ins
    - markdown-it-mark
// .vuepress/config.js
module.exports = {
  markdown: {
    lineNumbers: true,
    plugins: ['ins', 'markdown-it-mark']
  }
}
// vuepress/lib/markdown/index.js:58

  // apply user plugins
  if (markdown.plugins) {
    markdown.plugins.forEach(function (plugin) {
      plugin = plugin.replace('markdown-it-', '')
      md.use(require(`markdown-it-${plugin}`))
    })
  }

Are you willing to work on this yourself?

Yes 🎉 wip branch is alive

@ulivz ulivz added the type: feature request Request to add a new feature label Jun 14, 2018
@ulivz
Copy link
Member

ulivz commented Jun 14, 2018

Thanks, It would be better to also support shortcuts without markdown-it-:

module.exports = {
  markdown: {
    lineNumbers: true,
    plugins: ['ins', 'mark']
  }
}

@ulivz ulivz added the contribution welcome Contributions welcome label Jun 14, 2018
@neumayr
Copy link
Author

neumayr commented Jun 14, 2018

@ulivz Do all markdown-it plugins have this convention about naming? If yes, I could add a fixed prefix to the require statement. No problem. If you want to support both versions (with and w/o prefix) I'll have to do some string s&r. Is this ok for you?

Check https://github.com/neumayr/vuepress/commit/6be77173bbd7afd0a52adebd29b97a7e506bf74c

@ulivz
Copy link
Member

ulivz commented Jun 14, 2018

We should support both versions since VuePress's plugin API (In branch) has supported it.

Feel free to open a pull request.

@ulivz ulivz added version: next Planned to do or already included in the next(1.0.0) version and removed contribution welcome Contributions welcome labels Aug 20, 2018
@neumayr
Copy link
Author

neumayr commented Oct 1, 2018

@ulivz Because a lot has changed with the new v1.0.0-alpha progress.
Is the initial idea still ok, or is there a better integration concept (automatically fetching missing markdown-plugins) like it's done with vuepress plugins…

rebased: d674424

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Request to add a new feature version: next Planned to do or already included in the next(1.0.0) version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants