Implement balanced word wrapping for index images

This makes any lines that get wrapped balanced so that every line is of
a similar length. Explicit newlines in the source are not balanced, only
lines that get wrapped.

This should stop some of the titles wrapping at silly places, like:

"Journal Entry from Dr Sanchez
3"
communitypatch: Fix for mislabelled index on endurance emphasis document