Skip to content

Commit

Permalink
Implement Allinc plugin
Browse files Browse the repository at this point in the history
Resolves #61
  • Loading branch information
hagenburger committed Oct 3, 2018
1 parent 12408b3 commit cc5fc45
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/allinc/.npmignore
38 changes: 38 additions & 0 deletions plugins/allinc/README.md
@@ -0,0 +1,38 @@
# PIMD Allinc Plugin

Load all PIMD plugins at once:

- [Classes](https://github.com/hagenburger/pimd/tree/master/plugins/classes#readme)
- [ID](https://github.com/hagenburger/pimd/tree/master/plugins/id#readme)
- [Preview](https://github.com/hagenburger/pimd/tree/master/plugins/preview#readme)
- [Highlight](https://github.com/hagenburger/pimd/tree/master/plugins/highlight#readme)
- [Showmore](https://github.com/hagenburger/pimd/tree/master/plugins/showmore#readme)
- [HTML injector](https://github.com/hagenburger/pimd/tree/master/plugins/html-injector#readme)

## Usage

```sh
npm install --save-dev pimd @pimd/allinc-plugin
```

```javascript +highlight=/allincPlugin/g,"require(\"@pimd/allinc-plugin\")",/(?<!\/)config/g
const { Document } = require("pimd")
const Config = require("pimd/lib/config")
const allincPlugin = require("@pimd/allinc-plugin")
const markdown = "# Example"

const config = new Config()
config.use(allincPlugin)

const doc = new Document(markdown, config)
console.log(doc.render())
```

---

## Copyright

Copyright 2018++ [Nico Hagenburger](https://www.hagenburger.net). See
[MIT-LICENSE](MIT-LICENSE) for details. Get in touch with
[@hagenburger](https://twitter.com/hagenburger) on Twitter or
[open an issue](https://github.com/hagenburger/pimd/issues/new).
19 changes: 19 additions & 0 deletions plugins/allinc/index.js
@@ -0,0 +1,19 @@
const classesPlugin = require("@pimd/classes-plugin")
const highlightPlugin = require("@pimd/highlight-plugin")
const htmlInjectorPlugin = require("@pimd/html-injector-plugin")
const idPlugin = require("@pimd/id-plugin")
const previewPlugin = require("@pimd/preview-plugin")
const prismPlugin = require("@pimd/prism-plugin")
const showmorePlugin = require("@pimd/showmore-plugin")

module.exports = function(config) {
// Order does matter:
config.use(htmlInjectorPlugin)
// Order does not matter:
config.use(classesPlugin)
config.use(highlightPlugin)
config.use(idPlugin)
config.use(previewPlugin)
config.use(prismPlugin)
config.use(showmorePlugin)
}
25 changes: 25 additions & 0 deletions plugins/allinc/package.json
@@ -0,0 +1,25 @@
{
"name": "@pimd/allinc-plugin",
"version": "0.0.0",
"description": "Loads all plugins at once",
"main": "index.js",
"author": "Nico Hagenburger <nico@hagenburger.net> (https://twitter.com/hagenburger)",
"keywords": [
"markdown",
"pimd-plugin"
],
"publishConfig": {
"access": "public"
},
"license": "MIT",
"devDependencies": {
"@pimd/classes-plugin": "0.1.5",
"@pimd/highlight-plugin": "0.1.3",
"@pimd/html-injector-plugin": "0.1.1",
"@pimd/id-plugin": "0.1.4",
"@pimd/preview-plugin": "0.1.5",
"@pimd/prism-plugin": "0.1.1",
"@pimd/showmore-plugin": "0.1.1",
"pimd": "^0.5.0"
}
}
23 changes: 23 additions & 0 deletions plugins/allinc/test.js
@@ -0,0 +1,23 @@
const { Document } = require("../..")
const plugin = require(".")

describe("Allinc", () => {
it("should have all plugins loaded", () => {
const input = unindent`
# Test <?: .my-class #my-id ?>
~~~html +preview +highlight="x" +showmore=1
<p>x</p>
~~~
`
const doc = new Document(input)
doc.config.use(plugin)
const html = doc.render()
expect(html).to.have.selector("h1.my-class")
expect(html).to.have.selector("h1#my-id")
expect(html).to.have.selector(".pimd-preview p")
expect(html).to.have.selector(".pimd-highlight")
expect(html).to.have.selector(".pimd-example div[style='display: none']")
expect(html).to.have.selector("code span.token.punctuation")
})
})

0 comments on commit cc5fc45

Please sign in to comment.