Skip to content

Commit 26d3642

Browse files
committed
First step
1 parent 661eae1 commit 26d3642

File tree

2 files changed

+357
-32
lines changed

2 files changed

+357
-32
lines changed

example/example.js

Lines changed: 31 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
11
const remark = require('remark');
2-
const between = require('..');
2+
const replaceBetween = require('..');
33

44
const markdown = `
5-
# Example
5+
# Hello World!
66
7-
**List one:**
8-
- 1
9-
- 2
7+
This is a [Real page](https://google.com)
108
11-
**List two:**
12-
- 3
13-
- 4
14-
- 5
9+
<!-- tabs:start -->
1510
16-
# End
11+
#### **English**
1712
18-
**List three:**
19-
- 6
20-
- 7
13+
Hello!
14+
15+
#### **French**
16+
17+
Bonjour!
18+
19+
#### **Italian**
20+
21+
Ciao!
22+
23+
<!-- tabs:end -->
24+
25+
Testing
26+
27+
# Test
2128
`;
2229

2330
// Create a plugin for remark
2431
const plugin = () => (tree) => {
2532
// `start` and `end` nodes to look for, and find between.
2633
const start = {
27-
type: 'heading',
28-
children: [
29-
{
30-
value: 'Example'
31-
}
32-
]
34+
type: 'html',
35+
value: '<!-- tabs:start -->'
3336
};
3437

3538
const end = {
36-
type: 'heading',
37-
children: [
38-
{
39-
value: 'End'
40-
}
41-
]
39+
type: 'html',
40+
value: '<!-- tabs:end -->'
4241
};
4342

44-
// Test for list types and paragraph types
45-
const test = (node) => node.type === 'list' || node.type === 'paragraph';
46-
4743
// Get lists between `start` and `end`
48-
const lists = between(tree, start, end, test);
49-
50-
// Store lists and their labels
51-
tree.children = lists;
44+
replaceBetween(tree, start, end, list => {
45+
console.log(list)
46+
return [{
47+
type: 'html',
48+
value: '<p>Testing</p>'
49+
}]
50+
});
5251

5352
// Return new tree
5453
return tree;

0 commit comments

Comments
 (0)