md-frontmatter-splitter-cli-0.1.0 is not a library.
md-frontmatter-splitter-cli
This is a CLI tool that reads a Markdown file, splits the YAML front matter and the body, and outputs them as JSON.
Usage
Pass a Markdown file as an argument or pipe the content of a Markdown file to the tool.
The output will be a JSON object with two keys: frontmatter and content.
# File input
# Pipe input
|
Example using sample.md:
% cat sample.md
---
title: Sample Document
list:
- item1
- item2
---
# This is a sample markdown Document
hello!
% md-frontmatter-splitter-cli sample.md
{
"content": "# This is a sample markdown Document\n\nhello!",
"frontmatter": {
"list": [
"item1",
"item2"
],
"title": "Sample Document"
}
}
If the input Markdown file does not contain a front matter, the frontmatter key will be null.
This tool works well with jq or Nushell like this:
# in Nushell
| | |
Installation
You can install from crates.io using cargo:
Or you can build and install from source:
#=> ~/.cargo/bin/md-frontmatter-splitter-cli
# or build only, no installation
#=> ./target/release/md-frontmatter-splitter-cli
Development
You can build, format, lint, and test the project using the following command:
&& && &&
If you have just installed, you can also run the following command to build, format, lint, and test the project: