Skip to content

A small script to inject code snippets into Markdown files.

License

Notifications You must be signed in to change notification settings

cpearce31/add-code-block

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Add Code Block

This is a small script to inject code blocks into Markdown files. This is useful when you want to be able to lint or test code that appears in READMEs or other documentation.

Installation

npm install -g add-code-block

Use

With this in the markdown of a file called README.md:


<!-- start code block file="./example.js" -->

This gets replaced with the contents of `./example.js`

<!-- end code block -->

running:

cp README.md README.bak
add-code-block README.bak >README.md

produces:

<!-- start code block file="./example.js" -->
```js
'use strict'

module.exports = {
  sync: (value) => value,
  async: (value, cb) => setTimeout(() => cb(null, value), 0),
  promise: (value) => Promise.resolve(value)
}
```
<!-- end code block -->

About

A small script to inject code snippets into Markdown files.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published