Issue #365 Bold/Italic nesting fix

The logic for the current regex for strong/em and em/strong was sound,
but the way it was implemented caused some unintended side effects.
Whether it is a quirk with regex in general or just with Python’s re
engine, I am not sure.  Put basically `(\*|_){3}`  causes issues with
nested bold/italic. So, allowing the group to be defined, and then
using the group number to specify the remaining sequential chars is a
better way that works more reliably `(\*|_)\2{2}.  Test from issue #365
was also added to check for this case in the future.
Issue #366 Recursion error in toc ext

This reworks the toc ordering to be done in a single pass with no
recursion.  Very long documents with lots of headers can actually
exceed Python’s max recursion limit.  By handling the toc ordering with
no recursion, large documents can no longer cause toc to fail with
recursion erros.