Closed rohanashik closed 1 year ago
Example:
Mardown table:
## Table of Contents - [Introduction](#introduction) - [Subtopic 1](#subtopic-1) - [Subtopic 2](#subtopic-2) - [Main Content](#main-content) - [Chapter 1](#chapter-1) - [Section 1.1](#section-11) - [Section 1.2](#section-12) - [Chapter 2](#chapter-2) - [Conclusion](#conclusion)
The above should be pointing to the corresponding heading:
# Introduction ## Subtopic 1 ## Subtopic 2 # Main Content ## Chapter 1 ### Section 1.1 ### Section 1.2 ## Chapter 2 # Conclusion
Output should be:
<h2>Table of Contents</h2> <ul> <li><a href="#introduction">Introduction</a> <ul> <li><a href="#subtopic-1">Subtopic 1</a></li> <li><a href="#subtopic-2">Subtopic 2</a></li> </ul> </li> <li><a href="#main-content">Main Content</a> <ul> <li><a href="#chapter-1">Chapter 1</a> <ul> <li><a href="#section-11">Section 1.1</a></li> <li><a href="#section-12">Section 1.2</a></li> </ul> </li> <li><a href="#chapter-2">Chapter 2</a></li> </ul> </li> <li><a href="#conclusion">Conclusion</a></li> </ul> <h1 id="introduction">Introduction</h1> <h2 id="subtopic-1">Subtopic 1</h2> <h2 id="subtopic-2">Subtopic 2</h2> <h1 id="main-content">Main Content</h1> <h2 id="chapter-1">Chapter 1</h2> <h3 id="section-11">Section 1.1</h3> <h3 id="section-12">Section 1.2</h3> <h2 id="chapter-2">Chapter 2</h2> <h1 id="conclusion">Conclusion</h1>
But the id is not parsed in the django template. Even added the ID in whitelisting
"WHITELIST_ATTRS": [ 'href', 'src', 'alt', 'class', 'id' ],
If you add "markdown.extensions.toc" to MARKDOWN_EXTENSIONS, it will work. See the docs about extensions.
"markdown.extensions.toc"
MARKDOWN_EXTENSIONS
Example:
Mardown table:
The above should be pointing to the corresponding heading:
Output should be:
But the id is not parsed in the django template. Even added the ID in whitelisting