Pasta

À la carte markdown parsing.

There's no such thing as markdown, only markdowns. Multi-Markdown, Github Flavoured, Pandoc, or Stack Overflow style...each implementation makes subtle changes to Gruber's original in order to better address the needs of their users.

It might be nice to have one true standard but that just ain't gonna happen. And it shouldn't. One of the great strengths of writing in plain text is that it can easily be adapted to specific needs through different flavours or dialects.

Pasta allows you to choose the flavour of markdown that best meets your needs, or to whip a new one up as needed.

Ingredients

  • 1 pasta gem
  • A handful of text
  • A sprig of file references

Directions

Ensure your pasta gem is ready to go with

$ gem install pasta

Then use Pasta as a tasty addition to your ruby code:

Pasta.prepare('a handful of text').with(:markdown).make(:html)

Alternatively, you can use Pasta as a binary:

$ pasta a-tasty-file.txt --recipe gruber

Recipes

Choose a recipe from the menu or make your own - extensibility is Pasta's raison d'être.

Works in Progress

  • Github Github flavoured markdown.
  • Latin Markdown for scholars.
  • Reveal Generate slide decks from markdown.

Rolling your own

Creating your own recipe for a markdown flavour is simple. First up, write a test suite for your recipe and add it to the specs directory. Use the yaml format like the others.

Next, extend Pasta::Recipe::Base and use the DSL to declare your recipe's grammar. For example:

grammar(:html) { [:headings, :paragraphs] }
grammar(:pdf)  { [:meta, :headings, :paragraphs] }

Each grammar rule creates a to_x method and invokes the code in Pasta::Ingredients of the same name. You can either create your own ingredients or use existing ones. Extensibility is the name of the game here.

Grammars are order sensitive and use a depth-first strategy allowing you to nest rules.

Finally, add your recipe to the Pasta::Menu so in order to create a delicious new Pasta::Dish.