Преглед на файлове

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.
Jed Brown преди 10 години
родител
ревизия
b2eab9406f
променени са 1 файла, в които са добавени 1 реда и са изтрити 1 реда
  1. 1 1
      extract_toc/extract_toc.py

+ 1 - 1
extract_toc/extract_toc.py

@@ -23,7 +23,7 @@ def extract_toc(content):
     # if it is a Markdown file
     if extension in readers.MarkdownReader.file_extensions:
         toc = soup.find('div', class_='toc')
-        toc.extract()
+        if toc: toc.extract()
     # else if it is a reST file
     elif extension in readers.RstReader.file_extensions:
         toc = soup.find('div', class_='contents topic')