chore: format curriculum (#37912)
This commit is contained in:
committed by
GitHub
parent
45fe3d8814
commit
22fbc62f88
19
tools/scripts/formatter/md-to-mdx/utils/get-all-between.js
Normal file
19
tools/scripts/formatter/md-to-mdx/utils/get-all-between.js
Normal file
@@ -0,0 +1,19 @@
|
||||
const between = require('unist-util-find-all-between');
|
||||
const find = require('unist-util-find');
|
||||
const findAfter = require('unist-util-find-after');
|
||||
const findAllAfter = require('unist-util-find-all-after');
|
||||
|
||||
function getAllBetween(tree, testStart, testEnd) {
|
||||
const start = find(tree, testStart);
|
||||
|
||||
if (!start) return [];
|
||||
|
||||
const end = findAfter(tree, start, testEnd);
|
||||
|
||||
const targetNodes = end
|
||||
? between(tree, start, end)
|
||||
: findAllAfter(tree, start);
|
||||
return targetNodes;
|
||||
}
|
||||
|
||||
module.exports = getAllBetween;
|
Reference in New Issue
Block a user