markdown-it-concat-code

1.0.0 • Public • Published

markdown-it-concat-code

Concatenate all or some fenced code blocks from a markdown file.

Usage

const md = require('markdown-it')()
  .use(require('markdown-it-concat-code'), opts, src);

The opts object can contain:

Name Type Description
lang string Only include code blocks specifying `lang' as the language. If not specified, null or empty string then return all fenced code blocks.
separator string Append this string after each code block included in output. Defaults to '\n'.

src is an object whose value will be filled with the concatenated code blocks.

Example

const mdconcat = require('./').default

var mds = fs.readFileSync('README.md', 'utf8');
var src = {};

// all code blocks
md().use(mdconcat, {}, src).parse(mds, {});

console.log(src.value);

// with `lang` specified
md().use(mdconcat, { lang: 'c' }, src).parse(mds, {});

console.log(src.value);

Testing

npm run test

// Some C code for test case

Package Sidebar

Install

npm i markdown-it-concat-code

Weekly Downloads

2

Version

1.0.0

License

Unlicense

Unpacked Size

4.97 kB

Total Files

5

Last publish

Collaborators

  • matjp