Active Markdown, v0.3.2

Active Markdown is a tool for making reactive documents using a plain text markdown source, with a special notation for adding interactive controls and variables. The logic is determined by the contents of the code blocks, which are actually executed on-the-fly to update the variables. Think Literate CoffeeScript meets Tangle.

For example

Click and drag on “500 miles”: I would walk 500. miles and I would walk 500 more…

And edit this CoffeeScript to say @walk_distance * 3:


  @second_walk = @walk_distance * 1

That was generated from this markdown:

I would walk [500. miles]{walk_distance: 100..1000 by 10} and I would walk [500]{second_walk} more… @second_walk = @walk_distance * 1

Getting Started

The activemd command is written in CoffeeScript, and runs using Node.

  1. Install using npm: $ npm install -g active-markdown
  2. Generate a sample document using $ activemd --sample
  3. Compile sample.md file into sample.html: $ activemd sample.md
  4. View sample.html in your favorite browser: $ open sample.html

View the source and hack away, file issues, and suggest notation improvements on GitHub.

Reference

See the reference for a thorough breakdown of the possible elements and their configurations. (Raw markdown source, naturally.)

API

See the API docs for information about using the ActiveMarkdown module for programmatic parsing on the server and in the browser.

Example file

A sample raw Active Markdown file looks like this:

# St Ives An old riddle. > As [I]{travelers: we or I} [was]{verb} going to *St Ives* > I met a man with [7 wives]{wives: 1..10} > Every wife had [7 sacks]{sacks: 1..10} > Every sack had [7 cats]{cats: 1..10} > Every cat had [7 kits]{kits: 1..10} > Kits, cats, sacks, wives > How many were going to St Ives? total_sacks = @wives * @sacks total_cats = total_sacks * @cats total_kits = total_cats * @kits man = 1 if @travelers narrator = 2 @verb = 'were' else narrator = 1 @verb = 'was' The first guess is often [2753]{first_guess}… @first_guess = man + @wives + total_cats + total_kits + narrator …but the correct answer is **[1]{answer}**. @answer = narrator

which the activemd command turns into:


By Alec Perkins