GitbookIO/gitbook — pull request #354 by citizenmatt (2014-07-09 16:24:48+00:00)
Title: Plugin hooks for summary data

Provide `"summary:before"` and `"summary:after"` hooks for plugins to allow manipulating the summary data in the same way plugins can manipulate page data.

The `"summary:before"` hook is called after reading the `SUMMARY.md` file, but before parsing. It passes in an object with a `content` property that contains the raw content of the `SUMMARY.md` file. A plugin hook can edit or replace this text.

The `"summary:after"` hook is called after parsing the summary text. It receives an object with a `content` property that contains the parsed summary object model - nested arrays of chapters and articles. The plugin can modify or replace this object.

This is useful so a plugin can allow the `SUMMARY.md` file to be in a different format (e.g. multiple lists split by `##` h2 headers - see #306), or it can manipulate the object model to add or remove nodes, perhaps based on the contents of the files being pointed to (e.g. add chapters for sub-headings in a single file - see #331)