First of all, if you're doing this, you may be better served using external code samples, and having some naming convention which indicates whether you should execute the code or not.

Now, if you just want to do it anyway (writing parsers is fun, after all!), you can do something like this if your book is using Markua:

{format: ruby, execute: false}

Leanpub does not understand the execute  attribute, so it just ignores it. However, you can use this attribute when parsing the document yourself...

Did this answer your question?