README.md Reuse
12/06/2016, TueCommon Help Information
All NPM and Github repos have README.md as the primary means of communicating the purpose of a specific module or project. In some situations, such as a CLI module, there is almost always a command to list help for the module’s use.
Since there is an overlap of providing information in the module and CLI output, it would be beneficial if one can leverage the README.md to display the help text on the console for CLI modules.
One of the ways that this can be done is to use the ansimd module. This module takes raw markdown input and converts it into an ansi format that is suitable for displaying on the console.
When used with Webpack, this code example will show how ansimd handles markdown for console output:
One will need to use the raw-loader module because ansimd operates on raw markdown text.
// webpack.config.js: Loaders Section
test: /\.md/,
loader: 'raw-loader'
In your specific JavaScript file to display output:
// Console ANSI Output
import ansimd from "ansimd";
import helpText from "../README.md";
console.log(ansimd(helpText));