Skip to content

✂️ Interpolate the output of shell commands into Markdown

License

Notifications You must be signed in to change notification settings

yuanqing/markdown-interpolate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-interpolate npm Version build

Interpolate the output of shell commands into Markdown

  • Useful for inlining entire files (eg. cat file.md) or inserting dynamically-generated documentation (eg. node script.js) into Markdown

Quick start

Requires Node.js.

Given the following toy README.md file:

# Example

<!-- markdown-interpolate: cat file.md -->
<!-- end -->

<!-- ```json markdown-interpolate: node script.js -->
<!-- ``` end -->

…with the following file.md:

foo

…and script.js:

console.log('{ "bar": 42 }')

Do:

$ npx markdown-interpolate README.md

This will execute the shell commands marked by each markdown-interpolate: HTML comment, and interpolate the stdout between each corresponding pair of markdown-interpolate: and end HTML comments.

Our README.md will then be as follows:

# Example

<!-- markdown-interpolate: cat file.md -->
foo
<!-- end -->

<!-- ```json markdown-interpolate: node script.js -->
```json
{ "bar": 42 }
```
<!-- ``` end -->

See that:

  • Specify a string (eg. ```json) before markdown-interpolate: to insert it before the shell command’s `stdout`.
  • Specify a string (eg. ```) before end to insert it after the shell command’s `stdout`.

If file.md or script.js was changed, simply execute npx markdown-interpolate README.md again to automatically update README.md.

Usage


  Description
    Interpolate the output of shell commands into Markdown

  Usage
    $ markdown-interpolate <pattern> [options]

  Options
    -v, --version    Displays current version
    -h, --help       Displays this message

Installation

$ npm install --dev markdown-interpolate

License

MIT

About

✂️ Interpolate the output of shell commands into Markdown

Topics

Resources

License

Stars

Watchers

Forks