lit-node is a lightweight wrapper for Node.js which allows you to import code blocks from Markdown documents using the
require() function. This enables first-class support for simple literate programming, a software development technique which emphasizes clear written documentation. It's sort of like Jupyter notebooks for Node. Jupyter... nodebooks? [todo: should we delete this pun? it's really stupid.]
# install $ npm install --global lit-node # lit-node is just node with direct # support for importing modules from # Markdown code blocks $ lit-node
lit-node; a global install is probably most useful:
# install $ npm install --global lit-node
Create a Markdown file into which to save your code and its Markdown documentation:
# create a file $ touch test.md
Now you can execute your Markdown file!
$ lit-node ./test.md
You must include
From within a script being executed by
lit-node, you can
require() other Markdown files, which will be parsed and executed just like any other module. The
.md file extension is optional.
Assuming you've installed globally as mentioned above, you can also launch an interactive REPL which will support Markdown imports.
$ lit-node > const thing = require('./thing.md'); // import module from a Markdown file
Top Level Await
Top-level use of
await is generally a bad idea, but allowed in this case because it can be useful for short scripts.
lit-nodeis just running Node.js internally and for a whole slew of complicated reasons Node.js doesn't yet support ES modules, so for now
- Docco and its many variants render literate source code into beautiful browsable HTML