Skip to content

Commit 2f68028

Browse files
Bart LedouxBart Ledoux
authored andcommitted
fix: make plugin a normal remark plugin
1 parent e8efc93 commit 2f68028

File tree

5 files changed

+3882
-4087
lines changed

5 files changed

+3882
-4087
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ branches:
1111

1212
stages:
1313
- test
14-
- name: demo
15-
if: type != pull_request AND branch = main
1614
- name: release
1715
if: type != pull_request AND branch = main
1816

@@ -21,6 +19,7 @@ jobs:
2119
- stage: test
2220
script:
2321
- npx danger ci
22+
- yarn test
2423

2524
- stage: release
2625
script:

index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ const { parseComponent } = require("vue-template-compiler");
33
const { isCodeVueSfc } = require("vue-inbrowser-compiler-utils");
44
const getImports = require("./getImports");
55

6-
function getAttacher({ liveFilter } = {}) {
6+
module.exports = function attacher({ liveFilter } = {}) {
7+
return (ast) => visit(ast, "code", visitor);
8+
79
function visitor(node) {
810
let { lang, meta } = node;
911

@@ -64,10 +66,4 @@ function getAttacher({ liveFilter } = {}) {
6466
node.type = "html";
6567
node.value = markdownGenerated;
6668
}
67-
68-
return function attacher() {
69-
return (ast) => visit(ast, "code", visitor);
70-
};
71-
}
72-
73-
module.exports = getAttacher;
69+
};

index.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const plugin = require("./index.js");
33

44
test("transform fenced into vue-live with live flag", () => {
55
remark()
6-
.use(plugin())
6+
.use(plugin)
77
.process(
88
`
99
\`\`\`vue live
@@ -26,7 +26,7 @@ test("transform fenced into vue-live with live flag", () => {
2626

2727
test("avoid transform fenced into vue-live", () => {
2828
remark()
29-
.use(plugin())
29+
.use(plugin)
3030
.process(
3131
`
3232
\`\`\`vue
@@ -49,7 +49,7 @@ test("avoid transform fenced into vue-live", () => {
4949

5050
test("transform custom fenced into vue-live", () => {
5151
remark()
52-
.use(plugin({ liveFilter: (lang) => /pizza/.test(lang) }))
52+
.use(plugin, { liveFilter: (lang) => /pizza/.test(lang) })
5353
.process(
5454
`
5555
\`\`\`pizza
@@ -72,7 +72,7 @@ test("transform custom fenced into vue-live", () => {
7272

7373
test("transform require and import statements", () => {
7474
remark()
75-
.use(plugin())
75+
.use(plugin)
7676
.process(
7777
`
7878
\`\`\`js live
@@ -100,7 +100,7 @@ const a = require('test/req')
100100

101101
test("transform require and import statements", () => {
102102
remark()
103-
.use(plugin())
103+
.use(plugin)
104104
.process(
105105
`
106106
\`\`\`js live {"lineNumbers": true}

0 commit comments

Comments
 (0)