| 416 | |
| 417 | |
| 418 | class TocExtension(Extension): |
| 419 | |
| 420 | TreeProcessorClass = TocTreeprocessor |
| 421 | |
| 422 | def __init__(self, **kwargs): |
| 423 | self.config = { |
| 424 | 'marker': [ |
| 425 | '[TOC]', |
| 426 | 'Text to find and replace with Table of Contents. Set to an empty string to disable. ' |
| 427 | 'Default: `[TOC]`.' |
| 428 | ], |
| 429 | 'title': [ |
| 430 | '', 'Title to insert into TOC `<div>`. Default: an empty string.' |
| 431 | ], |
| 432 | 'title_class': [ |
| 433 | 'toctitle', 'CSS class used for the title. Default: `toctitle`.' |
| 434 | ], |
| 435 | 'toc_class': [ |
| 436 | 'toc', 'CSS class(es) used for the link. Default: `toclink`.' |
| 437 | ], |
| 438 | 'anchorlink': [ |
| 439 | False, 'True if header should be a self link. Default: `False`.' |
| 440 | ], |
| 441 | 'anchorlink_class': [ |
| 442 | 'toclink', 'CSS class(es) used for the link. Defaults: `toclink`.' |
| 443 | ], |
| 444 | 'permalink': [ |
| 445 | 0, 'True or link text if a Sphinx-style permalink should be added. Default: `False`.' |
| 446 | ], |
| 447 | 'permalink_class': [ |
| 448 | 'headerlink', 'CSS class(es) used for the link. Default: `headerlink`.' |
| 449 | ], |
| 450 | 'permalink_title': [ |
| 451 | 'Permanent link', 'Title attribute of the permalink. Default: `Permanent link`.' |
| 452 | ], |
| 453 | 'permalink_leading': [ |
| 454 | False, |
| 455 | 'True if permalinks should be placed at start of the header, rather than end. Default: False.' |
| 456 | ], |
| 457 | 'baselevel': ['1', 'Base level for headers. Default: `1`.'], |
| 458 | 'slugify': [ |
| 459 | slugify, 'Function to generate anchors based on header text. Default: `slugify`.' |
| 460 | ], |
| 461 | 'separator': ['-', 'Word separator. Default: `-`.'], |
| 462 | 'toc_depth': [ |
| 463 | 6, |
| 464 | 'Define the range of section levels to include in the Table of Contents. A single integer ' |
| 465 | '(b) defines the bottom section level (<h1>..<hb>) only. A string consisting of two digits ' |
| 466 | 'separated by a hyphen in between (`2-5`) defines the top (t) and the bottom (b) (<ht>..<hb>). ' |
| 467 | 'Default: `6` (bottom).' |
| 468 | ], |
| 469 | } |
| 470 | """ Default configuration options. """ |
| 471 | |
| 472 | super().__init__(**kwargs) |
| 473 | |
| 474 | def extendMarkdown(self, md): |
| 475 | """ Add TOC tree processor to Markdown. """ |
no outgoing calls
searching dependent graphs…