0.0.6 • Published 4 years ago

@matjp/markdown-it-concat-code v0.0.6

Weekly downloads
-
License
Unlicense
Repository
github
Last release
4 years ago

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:

NameTypeDescription
langstringOnly include code blocks specifying `lang' as the language. If not specified, null or empty string then return all fenced code blocks.

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
0.0.6

4 years ago

0.0.1

4 years ago