This may be much easier with a markdown filter: http://haml.info/docs/yardoc/file.REFERENCE.html#markdown-filter