Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
42 lines (30 sloc) 944 Bytes

Example 1, write code as a series of blocks

One of the tenants of literate programing is the ability to write prose then generate code. mweae uses Markdown's code blocks for that.

Here is our first block

    /**
     * example-1.js
     */
    /*jslint node: true, indent: 4 */

In this block I just setup a command header and a jslint directive.

Now lets get some code going

    console.log("Caculating 1 + 1");
    var accumulator = 0;
    accumulator = 1 + 1;

Now that we done a caculation let us send that to the console.

Write the results

    console.log("And the answer is", accumulator);

Finally let us tell the viewer we are done.

Last bits of program

    console.log("All done!");
    process.exit(0);

Running this through mweave should produce a single file called example-1.js