summaryrefslogtreecommitdiff
path: root/markdown/extensions/toc.py
Commit message (Collapse)AuthorAgeFilesLines
* Add support for a range to toc_depth.Klaus Mueller2019-02-221-4/+12
| | | | Closes #786.
* Support custom labels in TOC. (#700)Waylan Limberg2018-09-051-2/+9
| | | | | | | | New `toc_tokens` attribute on Markdown class. Contains the raw tokens used to build the Table of Contents. Users can use this to build their own custom Table of Contents rather than needing to parse the HTML available on the `toc` attribute of the Markdown class.
* Deprecate md_globals from extension API. (#697)Waylan Limberg2018-07-311-1/+1
| | | | | | In the past, most of the config was defined using globals. Today all of the config is held on the class instance. Therefore, the `md_globals` parameter is no longer necessary.
* All Markdown instances are now 'md'. (#691)Waylan Limberg2018-07-271-6/+6
| | | | | | | | | | | | Previously, instances of the Markdown class were represented as any one of 'md', 'md_instance', or 'markdown'. This inconsistency made it difficult when developing extensions, or just maintaining the existing code. Now, all instances are consistently represented as 'md'. The old attributes on class instances still exist, but raise a DeprecationWarning when accessed. Also on classes where the instance was optional, the attribute always exists now and is simply None if no instance was provided (previously the attribute wouldn't exist).
* Replace homegrown OrderedDict with purpose-built Registry. (#688)Waylan Limberg2018-07-271-5/+6
| | | | | | | | | | | | | | | | | | | All processors and patterns now get "registered" to a Registry. Each item is given a name (string) and a priority. The name is for later reference and the priority can be either an integer or float and is used to sort. Priority is sorted from highest to lowest. A Registry instance is a list-like iterable with the items auto-sorted by priority. If two items have the same priority, then they are listed in the order there were "registered". Registering a new item with the same name as an already registered item replaces the old item with the new item (however, the new item is sorted by its newly assigned priority). To remove an item, "deregister" it by name or index. A backwards compatible shim is included so that existing simple extensions should continue to work. DeprecationWarnings will be raised for any code which calls the old API. Fixes #418.
* Add toc_depth parameter to toc extensionJesús Fernández2018-07-241-2/+7
|
* Better check of allowed TOC location #639 (#641)Charles de Beauchesne2018-03-081-10/+12
|
* Remove deprecated support for Extension args.Waylan Limberg2018-01-131-4/+4
| | | | | | | | In the past Markdown used to pass extension config settings to the Extension class via a positional argument named `config`. That was deprecated in 2.6 in favor of using keyword arguments (`**kwargs`). Support has been completely dropped. Only keyword arguments are accepted.
* Improve test coverage.Waylan Limberg2018-01-131-2/+2
|
* Removed deprecated safe_mode.Waylan Limberg2018-01-111-3/+1
|
* Make sure regex patterns are raw strings (#614)Isaac Muse2018-01-021-2/+2
| | | Python 3.6 is starting to reject invalid escapes. Regular expression patterns should be raw strings to avoid having regex escapes being mistaken for invalid string escapes. Fixes #611.
* Switch docs to MKDocs (#602)Waylan Limberg2017-12-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fixes #601. Merged in 6f87b32 from the md3 branch and did a lot of cleanup. Changes include: * Removed old docs build tool, templates, etc. * Added MkDocs config file, etc. * filename.txt => filename.md * pythonhost.org/Markdown => Python-Markdown.github.io * Markdown lint and other cleanup. * Automate pages deployment in makefile with `mkdocs gh-deploy` Assumes a git remote is set up named "pages". Do git remote add pages https://github.com/Python-Markdown/Python-Markdown.github.io.git ... before running `make deploy` the first time.
* toc: Remove children from header element after iteratingDmitry Shachnev2016-03-171-1/+2
| | | | Removing items while iterating can result in wrong behavior. Refs #461.
* Add Comment support to toc.Waylan Limberg2015-03-141-2/+2
| | | | | | A etree can contain Comments, PIs or other Elements which do not have a string for a tag. Must always check that a tag is a string before doing string processing on it. Otherwise, things will crash.
* Use newer ElementTree API to avoid future breakage.Waylan Limberg2015-01-311-1/+1
|
* More refactor of TOC Extension.Waylan Limberg2015-01-011-24/+24
| | | | | | Mostly just code cleanup so it reads better. Renamed a few internal things. I didn't write this extension originally so most of this would have been done a long time ago. I just havn't touched this code much till now.
* HeaderId Extension marked as Pending Deprecation.Waylan Limberg2015-01-011-13/+64
| | | | | | | | | | | | | | | | | | | | Use the Table of Contents Extension instead. The HeaderId Extension will raise a PendingDeprecationWarning. The last few features of the HeaderID extension were mirgrated to TOC including the baselevel and separator config options. Also, the marker config option of TOC can be set to an empty string to disable searching for a marker. The `slugify`, `unique` and `stashedHTML2text` functions are now defined in the TOC extension in preperation for the HeaderId extension being removed. All coresponding tests are now run against the TOC Extension. The meta-data support of the HeaderId Extension was not migrated and no plan exists to make that migration. The `forceid` config option makes no sense in the TOC Extension and the only other config setting supported by meta-data was the `header_level`. However, as that depends on the template, it makes more sense to not be defined at the document level.
* PendingDeprecationWarning (v2.5) => DeprecationWarning (v2.6)Waylan Limberg2014-12-301-4/+4
|
* Preserve order of nested headers in TOCWaylan Limberg2014-12-301-49/+55
| | | | | | | | | Fixes #380. The TOC replacement is now seperate from building the TOC, which allows us to iter through the doc in order rather than with the non-order-preserving interparent pethod. This is almost a complete refactor of the run method. Also cleaned up the config stuff. Thanks to @colewerner for the report and test case.
* Complete test coverage of TOC ExtensionWaylan Limberg2014-12-301-8/+6
|
* Always add toc to Markdown Class InstanceWaylan Limberg2014-12-301-6/+6
| | | | | | | | Previously, we only added the toc attribute (md.toc) if no Marker was found within the document. However, that has caused framworks to do things like force insert a marker, run convert, then extract the toc from the body of the document. This is much cleaner. And if the user wants to add the toc to the document also, they still can.
* Add reset support to TOC extension.Waylan Limberg2014-12-301-0/+6
| | | | | | Now, whenever the TOC extensiuon is loaded, the Markdown class instance will always have a toc attribute (md.toc). Calling md.reset() will also reset the toc attribute which defaults to an empty string.
* Flake8 cleanup (mostly whitespace).Waylan Limberg2014-11-201-44/+49
| | | | | | Got all but a couple files in the tests (ran out of time today). Apparently I have been using some bad form for years (although a few things seemed to look better before the update). Anyway, conformant now.
* Issue #366 Recursion error in toc extfacelessuser2014-11-171-48/+47
| | | | | | | | This reworks the toc ordering to be done in a single pass with no recursion. Very long documents with lots of headers can actually exceed Python’s max recursion limit. By handling the toc ordering with no recursion, large documents can no longer cause toc to fail with recursion erros.
* Fixed TOC Option parsing.Waylan Limberg2014-09-251-2/+2
| | | | | | The new option parser assumes bool values if the default is bool or None. As the "title" option is not a bool value, it should default to an empty string rather than None. Fixes #347.
* Standardized all extension header comments to a uniform format.Waylan Limberg2014-08-211-4/+8
|
* 'http://packages.python.org/Markdown/' => ↵Waylan Limberg2014-08-211-1/+1
| | | | 'https://pythonhosted.org/Markdown/'. The former redirects to the latter anyway. Might as well point to the actual destination.
* Update extensions for Extension.__init__ refactorWaylan Limberg2014-07-311-22/+22
| | | | | | | | | | | | | | | | | Fixes #325. All extensions can now accept a dict of configs or **kwargs, not just a list of tuples. Third party extensions may want to follow suite. Extensions may only accept keyword arguments in the future. These changes still need to be documented. A couple things of note: The CodeHilite extension previously issued a DeprecationWarning if the old config key `force_linenos` was used. With thins change, a KeyError will now be raised. The `markdown.util.parseBoolValue` function gained a new argument: `preserve_none` (defaults to False), which when set to True, will pass None through unaltered (will not convert it to False).
* toc: insert `¶` instead of raw unicode characterDmitry Shachnev2013-09-291-3/+3
|
* Add new "permalink" option to toc extensionDmitry Shachnev2013-09-251-13/+31
| | | | and use it in our docs
* Add new utility function parseBoolValue()Dmitry Shachnev2013-09-251-2/+2
| | | | and use it in all extension that need parsing bool config values.
* Extended headerid's rawHTML in id handling to toc ext.Waylan Limberg2013-08-111-2/+3
|
* Future imports go after the docstringsAdam Dinwoodie2013-03-181-1/+1
| | | | | | | | | A `from __future__ import ...` statement must go after any docstrings; since putting them before the docstring means the docstring loses its magic and just becomes a string literal. That then causes a syntax error if there are further future statements after the false docstring. This fixes issue #203, using the patch provided by @Arfrever.
* Merge branch '2and3'Waylan Limberg2013-02-271-5/+8
|\
| * Now using universal code for Python 2 & 3.Waylan Limberg2013-02-271-5/+8
| | | | | | | | | | | | | | | | | | | | The most notable changes are the use of unicode_literals and absolute_imports. Actually, absolute_imports was the biggest deal as it gives us relative imports. For the first time extensions import markdown relative to themselves. This allows other packages to embed the markdown lib in a subdir of their project and still be able to use our extensions.
* | Missed a set.append -> set.add.Waylan Limberg2013-02-251-1/+1
|/
* Change `set.append` -> `set.add` in `headerid.unique`Waylan Limberg2013-02-221-1/+1
| | | | | | | | | Fixes #195. This was getting missed because the HeadrerId extension's reset method was resetting the IDs to a list. However, some third party extensions may want to call the unique function and it should work as documented. Interestingly, the TOC extension was using it and passing in a list as well. All fixed now. Also added a test of the `unique` function directly so we shouldn't repeat this in the future.
* More TOC cleanup and added tests.Waylan Limberg2013-02-191-2/+2
|
* TOC list item names must use text from all children.Waylan Limberg2013-02-191-1/+1
|
* Updated toc extension to work with changes @ 4ff74e3.Waylan Limberg2013-02-191-2/+2
|
* Ensure toc attribute is available on Markdown class.Waylan Limberg2013-02-191-3/+3
| | | | | | This appears to have recently been broken with the fixes in #191. This time I've added tests to prevent future breakage and added documentation to explain the behavior.
* Do not use assigned names "next" and "id", rename to order_toc_list and ↵benjaoming2013-02-181-18/+20
| | | | clean up code
* code cleanupbenjaoming2013-02-181-13/+12
|
* Make TocTreeprocessor extendable and be more gentle on badly structured headingsbenjaoming2013-02-171-63/+126
|
* Fixed #106. Replaced all references to freewisdom.org (except for Yuri's ↵Waylan Limberg2012-06-281-1/+1
| | | | homepage).
* Fixed #49. Don't crash on poorly/randomly ordered header levels. Maybe ↵Waylan Limberg2011-10-301-42/+46
| | | | someday we will better support any input (patches welcome), but we should never crash on poorly formatted input text. With this fix, we catch the exception and skip over it. The TOC up to the point (and perhaps after) still gets rendered. The incomplete TOC should be the clue to the document author that s/he has a formatting error in the document.
* Fixed #44. The TOC extension will now except True/False in addition to 1/0 ↵Waylan Limberg2011-10-061-1/+1
| | | | from the command line style syntax for passing in bool type extension configs. In order words, we now except strings in addition to booleans and integers.
* TOC extension now attaches toc to Markdown instance (Markdown.toc), but only ↵Waylan Limberg2011-08-041-0/+11
| | | | if a marker was not found in the document.
* Updated toc extension's anchorlink option to work properly with recent refactor.Waylan Limberg2011-07-141-2/+6
|
* Refactored the toc extension. Fixes #33: The [TOC] marker is now ignored in ↵Waylan Limberg2011-07-141-28/+17
| | | | code blocks/spans. A better fix for #4: Only the *text* from the header is caried over to the toc (without *any* inline formatting). Also refactored the extension to better work in tandem with the refactored headerid extension and the new attr_list extension.