Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
mdast-comment-marker
Advanced tools
mdast utility to parse comment markers.
This package is a utility that tries to parse a structured marker from a comment.
Comments are a hidden part of markdown, so they can be used as processing
instructions.
For example, this utility is used in remark-lint
to control
whether lint rules are turned on or ignored, and by mdast-zone
to replace sections between two markers.
This package is ESM only. In Node.js (version 14.14+ and 16.0+), install with npm:
npm install mdast-comment-marker
In Deno with esm.sh
:
import {commentMarker} from 'https://esm.sh/mdast-comment-marker@2'
In browsers with esm.sh
:
<script type="module">
import {commentMarker} from 'https://esm.sh/mdast-comment-marker@2?bundle'
</script>
import {commentMarker} from 'mdast-comment-marker'
console.log(commentMarker({type: 'html', value: '<!--foo-->'}));
console.log(commentMarker({
type: 'html',
value: '<!--foo bar baz=12.4 qux="test test" quux=\'false\'-->'
}));
console.log(commentMarker({type: 'html', value: '<!doctype html>'}));
// Also supports MDX expressions:
console.log(commentMarker({
type: 'mdxFlowExpression',
value: '/* lint disable heading-style */'
}));
Yields:
{
name: 'foo',
attributes: '',
parameters: {},
node: { type: 'html', value: '<!--foo-->' }
}
{
name: 'foo',
attributes: `bar baz=12.4 qux="test test" quux='false'`,
parameters: { bar: true, baz: 12.4, qux: 'test test', quux: false },
node: {
type: 'html',
value: `<!--foo bar baz=12.4 qux="test test" quux='false'-->`
}
}
null
{
name: 'lint',
attributes: 'disable heading-style',
parameters: { disable: true, 'heading-style': true },
node: {
type: 'mdxFlowExpression',
value: '/* lint disable heading-style */'
}
}
This package exports the identifier commentMarker
.
There is no default export.
commentMarker(value)
Parse a comment marker.
value
(unknown
)
— thing to parse, typically Node
Info (Marker
) when applicable or null
.
Marker
Comment marker (TypeScript type).
name
(string
)
— name of markerattributes
(string
)
— value after nameparameters
(MarkerParameters
)
— parsed attributesnode
(Node
)
— reference to given nodeMarkerParameters
Parameters (TypeScript type).
type MarkerParameters = Record<string, MarkerParameterValue>
MarkerParameterValue
Value (TypeScript type).
If it looks like a number (to JavaScript), it’s cast as number.
The strings true
and false
are turned into their corresponding
booleans.
The empty string is also considered the true
boolean.
type MarkerParameterValue = string | number | boolean
This package is fully typed with TypeScript.
This package exports the types Marker
,
MarkerParameters
, and
MarkerParameterValue
Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.
Use of mdast-comment-marker
does not involve hast, user content, or change
the tree, so there are no openings for cross-site scripting (XSS)
attacks.
mdast-zone
— change or replace a section marked by commentsSee 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, organization, or community you agree to abide by its terms.
FAQs
mdast utility to parse a comment marker
The npm package mdast-comment-marker receives a total of 102,580 weekly downloads. As such, mdast-comment-marker popularity was classified as popular.
We found that mdast-comment-marker demonstrated a not healthy version release cadence and project activity because the last version was released 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
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.