Move outline logic to a module

As much code as possible is moved from document
and to_prawn.