summaryrefslogtreecommitdiff
path: root/markdown/extensions/toc.py
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Fix #4. Links in headers no longer munge up table of contents in TOC extension.Waylan Limberg2011-05-041-3/+10
|
* Extension.getConfigs returns a dict and is used by the extensions that use ↵Waylan Limberg2011-05-041-6/+6
| | | | configs. No more self.config['name'][0] weirdness anymore.
* Rename misc.py to util.py at the request of upstreamToshio Kuratomi2010-07-051-1/+1
|
* Break cyclic import of markdown. This allows people to embed markdownToshio Kuratomi2010-07-051-1/+1
| | | | if they desire.
* Fix the TOC extension for TOCs starting at levels other than 1.Steve Losh2009-12-251-1/+4
|
* Fixed TOC extension to properly nest multiple header levels in the table of ↵Waylan Limberg2009-07-211-7/+3
| | | | contents. Specificly, when stepping back multiple levels, the nestsed listed now follow suite. Test included. Thanks for the patch Jack Miller.
* Fixed bug in toc extension and added a test. We now disallow the marker in ↵Waylan Limberg2009-03-181-1/+4
| | | | any headers (h1-6) as this crashes markdown with an infinite loop trying to build the toc. Thanks for the report Holger Rapp.
* Getting rid of has_key for compatibility with python3k.Yuri Takhteyev2008-12-041-2/+2
|
* Updated toc extension for new refactor.Waylan Limberg2008-11-201-5/+5
|
* Moved markdown_extensions/ to markdown/extensions. Markdown is now one ↵Waylan Limberg2008-11-201-0/+137
package instead of two.