![New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions](https://cdn.sanity.io/images/cgdhsj6q/production/86e6ebdea652d20da070ebbda20134b839972db7-1024x1024.webp?w=800&fit=max&auto=format)
Security News
New axobject-query Maintainer Faces Backlash Over Controversial Decision to Support Legacy Node.js Versions
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
mdast-util-heading-range
Advanced tools
Readme
mdast utility to use headings as ranges.
npm:
npm install mdast-util-heading-range
Say we have the following file, example.md
:
# Foo
Bar.
# Baz
And our script, example.js
, looks as follows:
var vfile = require('to-vfile')
var remark = require('remark')
var heading = require('mdast-util-heading-range')
remark()
.use(plugin)
.process(vfile.readSync('example.md'), function(err, file) {
if (err) throw err
console.log(String(file))
})
function plugin() {
return transform
function transform(tree) {
heading(tree, 'foo', mutate)
}
function mutate(start, nodes, end) {
return [
start,
{type: 'paragraph', children: [{type: 'text', value: 'Qux.'}]},
end
]
}
}
Now, running node example
yields:
# Foo
Qux.
# Baz
heading(tree, test|options, onrun)
Search tree
(Node
) and transform a section without affecting other
parts with onrun
(Function
).
A “section” is a heading that passes test
, until the next heading of the same
or lower depth, or the end of the document.
If ignoreFinalDefinitions: true
, final definitions “in” the section are
excluded.
options
options.test
Heading to look for (string
, RegExp
, Function
).
When string
, wrapped in new RegExp('^(' + value + ')$', 'i')
;
when RegExp
, wrapped in function (value) {expression.test(value)}
options.ignoreFinalDefinitions
Ignore final definitions otherwise in the section (boolean
, default: false
).
function test(value, node)
Function invoked for each heading with its content (string
) and node
itself (Heading
) to check if it’s the one to look for.
Boolean?
, true
if this is the heading to use.
function onrun(start, nodes, end?, scope)
Callback invoked when a range is found.
start
Start of range (Heading
).
nodes
Nodes between start
and end
(Array.<Node>
).
end
End of range, if any (Node?
).
scope
Extra info (Object
):
parent
(Node
) — Parent of the rangestart
(number
) — Index of start
in parent
end
(number?
) — Index of end
in parent
See contributing.md
in syntax-tree/.github
for ways to get
started.
See support.md
for ways to get help.
This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.
FAQs
mdast utility to use headings as ranges in mdast
The npm package mdast-util-heading-range receives a total of 5,613 weekly downloads. As such, mdast-util-heading-range popularity was classified as popular.
We found that mdast-util-heading-range demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.
Security News
Results from the 2023 State of JavaScript Survey highlight key trends, including Vite's dominance, rising TypeScript adoption, and the enduring popularity of React. Discover more insights on developer preferences and technology usage.
Security News
The US Justice Department has penalized two consulting firms $11.3 million for failing to meet cybersecurity requirements on federally funded projects, emphasizing strict enforcement to protect sensitive government data.