stevedonovan/LDoc — pull request #188 by mooffie (2014-12-24 15:58:59+00:00)
Title: Have postprocess_html

This simple patch introduces a hook that lets one perform last-minute modification of the HTML.

(Purists may not like having people manipulate a HTML string, preferring them to manipulate some data structure instead, and they're right, but ldoc doesn't readily have the required infrastructure for this, and this somewhat inelegant solution, in this patch, of modifying HTML, is better than nothing.)

So, what can one do with this hook?

- One can add a link to a CSS or JS file to the `

`er.

- One can convert simple tokens and "macros" to nice markup. For example, here's how to make any paragraph that starts with "Note:" stand out:

```lua
function postprocess_html(s)
s = s:gsub("

%s*Note:(.-)

", '

%1

')
return s
end
```

You can see the result of a similar manipulation here:

http://typo.co.il/~mooffie/tmp/ldoc/postprocess_html/tty.html

Here I used postprocess_html to support 3 types of paragraphs: notes, ideas, infos, each having a different icon in their boxes.

(The hook is named postprocess_html, not html_postprocess, because in the future we may have postprocess_item etc. and putting the "postprocess" first could make the documentation more organized.)