Check that titles are correctly formatted

In Markdown, the sharps at the end of the title line can be elided
but they may not be followed by spaces. Otherwise, the sharps are
rendered in the title.
Check the number of declared figures in each chapter

If the number of declared figures is greater that the number of available
figures, processing errors occur while converting to html or pdf. The error
messages are not obvious, so it is safer to catch the mistake before.
Merge pull request #390 from progit/advanced_tests

Advanced tests