extract_toc: fix markdown case when toc not found

The guard is needed to avoid:

  'NoneType' object has no attribute 'extract'

This fixes the bug introduced in the parent commit.