| 103 | |
| 104 | class TocExtension(markdown.Extension): |
| 105 | def __init__(self, configs): |
| 106 | self.config = { "marker" : ["[TOC]", |
| 107 | "Text to find and replace with Table of Contents -" |
| 108 | "Defaults to \"[TOC]\""], |
| 109 | "slugify" : [self.slugify, |
| 110 | "Function to generate anchors based on header text-" |
| 111 | "Defaults to a built in slugify function."], |
| 112 | "title" : [None, |
| 113 | "Title to insert into TOC <div> - " |
| 114 | "Defaults to None"], |
| 115 | "anchorlink" : [0, |
| 116 | "1 if header should be a self link" |
| 117 | "Defaults to 0"]} |
| 118 | |
| 119 | for key, value in configs: |
| 120 | self.setConfig(key, value) |
| 121 | |
| 122 | # This is exactly the same as Django's slugify |
| 123 | def slugify(self, value): |