Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
front-matter-markdown
Advanced tools
Get the config object from a markdown string. It will extract configuration from front-matter.
And get the directory(contents
) from the list of heading TOC/Table Of Content/Summary
.
It will generate a TOC from the markdown string if the list is empty
parseMarkdown = require('front-matter-markdown')
markdownStr = """
---
title: this is a title
---
# table of contents
* [Directory](./dir1)
* [Directory2](/dir2)
* [Directory3](#inline)
# this is a inline heading {#inline}
"""
console.log(JSON.stringify parseMarkdown(markdownStr), null, 1)
the results:
{
"title": "this is a title",
"skipSize": 31,
"ordered": false,
"contents": [
{
"title": "Directory",
"path": "./dir1",
"ordered": false,
"contents": [
{
"title": "Directory2",
"path": "/dir2"
}
]
},
{
"title": "Directory3",
"path": "#inline"
}
]
}
var parseMarkdown = require('front-matter-markdown');
parseMarkdown(aMarkdownString, aOptions)
: parse a markdown string to a plain object.
aOptions
(Object):
content
(Boolean): whether extract the markdown content from configuration.
defaults to true. it will store the compiled markdown to $compiled
too.
content
and $compiled
attributes are non-enumerable.toc
(Boolean): whether extract the directory from the list in the specified heading.
defaults to false. the 'directoy' is put into contents
attributes.links
(Boolean): merge the markdown links label to the result, default to false.heading
(String|RegExp|ArrayOf(String)): the toc list in the heading(s) to extract the directory.
defaults to ['TOC', 'Table Of Content', 'Summary']headingsAsToc
(Boolean|Object): whether generate
the directory from the headings of markdown.
defaults to false. It will generate
the toc if no toc list in the specified heading(toc
enabled).
maxDepth
(Number): Use headings whose depth is at most max depth for generate
.
defaluts to 3.firstLevel
(Number): the first level to generate
the directory from the headings of markdown.
defaluts to 1.Returns
:
skipSize
Number: the front-matter configuration size if existscontent
String: the markdown string after removing the front-matter configuration. (available on content
is true)$compiled
Object: the compiled markdown tree.(available on content
is true)contents
Object: the directory from the list in the specified heading. (available on toc
)markdownStr = """
---
title: this is a title
toc: false
headingsAsToc: false
heading: Category
---
# Category
* [Directory](./dir1)
* [Directory2](/dir2)
* [Directory3](#inline)
# this is a inline heading {#inline}
[linkLabel1]: hi
[linkLabel2]: url "with title text"
"""
result = parseMarkdown(markdownStr) #= parseMarkdown markdownStr,
# toc:false
# headingsAsToc: false
# heading: 'Category'
MIT
FAQs
get the config and toc object from the markdown string.
We found that front-matter-markdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.