Fix issue308 and fix (unrelated) failure to break out of nest loop.

- fix issue 308 (preprocessors.py lines 178-179)
- fix unending `while` loop (extra.py line 78/79)
- test issue 308
- cleaner `MarkdownInHtmlProcessor` class