MD Minify
Markdown Minification
command line tool and requirable module
npm install md-minify -g
Why?
- Wanted to convert markdown to a string
- Wanted to be able to inject markdown into json config files as a property.
Usage
There are two ways to use mdm. You can install it globally and use it from the command line, or you can require it in your project.
From the command line:
You can use the mdm
command on a markdown file
and it will output the results to the console:
mdm example-readme.md
Pipe the results to a file:
mdm example-readme.md > example-readme.txt
If you include a json file as a second argument it will add a property of "readme":
mdm example-readme.md example-json.json
Example usage in your project:
var express = mdm = ; mdm ;
Methods
read(Path)
read
is a wrapper around [q-io/fs read], it takes a markdown file and reads its entire contents into memory. It returns a promise for the whole file contents.
return mdm
parse(Buffer) & parseEsc(Buffer)
parse
replaces line returns with \r\n
and returns string.
var parsedContent = mdm;
parseEsc
escapes line returns (\\r\\n
) and returns string.
var parsedEscContent = mdm;
saveConfig(Path, String)
saveConfig
takes a path to a config file and the parsed content, and adds a readme property to the config file.
It returns a promise for the whole file contents.
return mdm
compare([String|Object], Object)
compare
an object or JSON.parsable string against another object. It returns true or false.
mdm// returns true or false