Skip to content

📔 A lightweight literary programming system for node.js

License

Notifications You must be signed in to change notification settings

richorama/literate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

literate

Write your code in markdown, then use literate to 'require' the module. The JavaScript you have written in code blocks will be scraped out and returned as the module at runtime.

Install

$ npm install literate

Example Usage

Creating a markdown module

Create a markdown file for you documenation and code (your_module.md):

# This is an example module.

First it logs to the console:

    console.log("hello world")

It exports a function as an example.

    module.exports.useAsNormal = function(){
      return "foo";
    }

You can also set a variable like this `var x = 2`, 
and write it out with a `console.log(x)`.

Calling the module

In your main file (server.js), instead of using require directly, use literate to load the module:

var your_module = require('literate')('./your_module');
your_module.useAsNormal();

Runtime inspection of the Markdown

The markdown is available to the module at runtime on a __markdown variable:

# Retrieve documentation at runtime

    module.exports.markdown = function(){
      return __markdown;
    }

Todo

At the moment block are not supported, so you have to write your program in sequence.

License

MIT

About

📔 A lightweight literary programming system for node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published