Easier Literate Programming

The tools I’ve been building for literate programming, such as lit and the Markdown import plugin for Rollup, are powerful and can help you fit literate programming into a serious application build process. But what if you don’t want to bother with a build process?

Here’s a quick-and-dirty alternative for JavaScript on the web: lit-web.js. It lets you load Markdown files as script tags, like this:

<script type="text/markdown" src="//path/to/literate/programming.md"></script>

If lit-web.js is loaded on the page, it will find these “Markdown scripts,” fetch their content, parse the Markdown to remove everything but the code blocks, and execute the resulting code string in JavaScript. My goal with this was to create a tool that presents the lowest possible barrier to entry into literate programming. Here’s an example I’ve written for the D3.js demo site bl.ocks in which the data visualization uses its own README.md documentation as the source code.