1.0.3 • Published 2 months ago

@zaeny/literate v1.0.3

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 months ago

@zaeny/literate

npm version npm downloads

literate programming, extract code blocks from markdown file

Getting Started

npm install @zaeny/literate

Usage

var {extractCode}  = require('@zaeny/literate');
var testMdFile = fs.readFileSync('./test.md', 'utf8');

extractCode(testMdFile);

/ { path: 'index.js', lang: 'js', code: "console.log('welcome');" }, { path: 'index.js', lang: 'js', code: "console.log('hai');" } /

var {eval} = require('@zaeny/literate/eval'); eval(testMdFile); / welcome hai /

var {tangle} = require('@zaeny/literate/tangle'); tangle(testMdFile); / 'tangle files: #1 index.js' /

**More example**
```js
eval(string, validatorFn)
eval(testMdFile, (file) => (file.code && file.lang === "js" && file.eval===1));
// welcome
// hai

tangle(testMdFile, (file) => (file.path && file.lang === "js"));
//  'tangle files: #1 index.js'

Changes

  • 1.0.2 tangle and eval now return object of inputed
1.0.3

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago