Skip to content

Commit e3a6d9a

Browse files
committed
Added initial header detection
1 parent b98ae83 commit e3a6d9a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

example/example.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {remark} from 'remark'
2+
import {is} from 'unist-util-is';
23
import replaceBetween from '../index.js';
34

45
const markdown = `
@@ -42,10 +43,17 @@ const plugin = () => (tree) => {
4243

4344
// Get lists between `start` and `end`
4445
replaceBetween(tree, start, end, list => {
45-
console.log(list)
46+
// Remove both `tabs` mention
47+
list.shift();
48+
list.pop()
49+
50+
const headerIndexes = list
51+
.map((node, i) => is(node, {type: 'heading'}) && i)
52+
.filter(Number.isInteger)
53+
4654
return [{
4755
type: 'html',
48-
value: '<p>Testing</p>'
56+
value: headerIndexes
4957
}]
5058
});
5159

0 commit comments

Comments
 (0)