aboutsummaryrefslogtreecommitdiffstats
path: root/markdown/treeprocessors.py
Commit message (Collapse)AuthorAgeFilesLines
* Move isBlockLevel to class. (#693)Waylan Limberg2018-07-311-3/+3
| | | | | Allows users and/or extensions to alter the list of block level elements. The old implementation remains with a DeprecationWarning. Fixes #575.
* Consistent copyright headers.Waylan Limberg2018-07-271-0/+22
| | | | Fixes #435.
* All Markdown instances are now 'md'. (#691)Waylan Limberg2018-07-271-4/+10
| | | | | | | | | | | | 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-6/+5
| | | | | | | | | | | | | | | | | | | 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.
* Moved enable_attributes keyword to extension: legacy_attrs.Waylan Limberg2018-07-241-18/+1
| | | | | | | If you have existing documents that use the legacy attributes format, then you should enable the legacy_attrs extension for those documents. Everyone is encouraged to use the attr_list extension going forward. Closes #643. Work adapted from 0005d7a of the md3 branch.
* Flexible inline (#629)Isaac Muse2018-01-171-7/+28
| | | | Add new InlineProcessor class that handles inline processing much better and allows for more flexibility. This adds new InlineProcessors that no longer utilize unnecessary pretext and posttext captures. New class can accept the buffer that is being worked on and manually process the text without regex and return new replacement bounds. This helps us to handle links in a better way and handle nested brackets and logic that is too much for regular expression. The refactor also allows image links to have links/paths with spaces like links. Ref #551, #613, #590, #161.
* Correct spelling mistakes.Edward Betts2018-01-131-2/+2
|
* Avoid DeprecationWarnings for etreeWaylan Limberg2018-01-041-3/+3
| | | | Fixes #618.
* Feature ancestry (#598)Isaac Muse2017-11-231-11/+46
| | | | | Ancestry exclusion for inline patterns. Adds the ability for an inline pattern to define a list of ancestor tag names that should be avoided. If a pattern would create a descendant of one of the listed tag names, the pattern will not match. Fixes #596.
* Replace `getiterator` function for Python 3.6 Brandon Chinn2016-09-291-2/+2
| | | | | | `getiterator` has been deprecated since Python 2.7, when `iter` was added. Fixes #499.
* Flake8 cleanup (mostly whitespace).Waylan Limberg2014-11-201-23/+30
| | | | | | 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.
* Fix tail out of order issuefacelessuser2014-10-181-1/+1
| | | | | | | | | | | | This issue was discovered when dealing with nested inlines. In treeprocessors.py it was incorrectly handling tails. In short, tail elements were being inserted earlier than they were supposed to be. In order to fix this, the insertion index should be incremented by 1 so that when the tails are inserted into the parent, they will be just after the child they came from. Also added a test in nested-patterns to catch this issue.
* Fix the lost tail issue in inlineprocessors.facelessuser2014-09-261-15/+18
| | | | | | See #253. Prior to this patch, if any inline processors returned an element with a tail, the tail would end up empty. This resolves that issue and will allow for #253 to be fixed. Thanks to @facelessuser for the work on this.
* Code Blocks must always be AtomicStringsWaylan Limberg2014-09-081-1/+1
| | | | | | | | | | | | | | | | | | Fixes #340. The "inline" TreeProcessor runs before the "prettify" TreeProcessor, but the "smarty" TreeProcessor (wich is just another instance of `InlineProcessor`) runs after the "prettify" TreeProcessor. The problem was that the "prettify" TreeProcessor was losing the AtomicString quality of the text of code blocks (any operation on a string creates a new string. When that string is an AtomicString, the new string must explicitly be declared as an AtomicString. As the "prettify" TreeProcessor cleans up newlines on code blocks, it was changing the AtomicString to a normal string. And as `InlineProcessor` identifies what elements to skip solely by whether the text is an AtomicString, the "smarty" instance was running on code blocks. Importantly, I added a test of code blocks and spans for smarty, so this shouldn't break again.
* Marked a bunch of lines as 'no cover'. Coverage at 91%Waylan Limberg2014-07-111-1/+1
|
* Make it easier to override list of inline patterns for InlineProcessorDmitry Shachnev2014-05-261-2/+3
|
* Address various depreciated APIs in PythonWaylan Limberg2014-01-081-6/+6
| | | | | This mostly revolves around old APIs for ElementTree, but includes a few others as well. Fixes #254. Thanks for the report.
* Ensure handleAttributes doesn't lose AtomicStrings.Waylan Limberg2013-03-181-3/+3
| | | | | | | | | | | | | | | Fixes #204. This was a real pain to debug. But I think the problem stemmed from the fact that the footnote extension inserted a etree link into the footnotes last p element. Then when inline patterns are run, the inline code in that p element is processed. Normally, code would be the first child found, but with the pre-existing link, that wasn't the case and the parser took a slightly differant path which would never be encountered in any other situation. It was this slightly differant path that made the lose of the AtomicString status of the inline code matter. Since any AtomicString (including inline code) doesn't need to be run though hanldeAttributes anyway, we can just skip over it and preserve the AtomicString. Whew!
* Now using universal code for Python 2 & 3.Waylan Limberg2013-02-271-11/+7
| | | | | | | | | | 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.
* Cleaned up fixes for #183Waylan Limberg2013-02-081-0/+5
| | | | | | | | | My previous commit (d5a94c2) broke a few things badly. Unfortunately I failed to run the complete test suite and didn't catch it. A bad regex was crashing the test suite. Also cleaned up a few other odds and ends from previous work on #183. Still loosing a few random empty lines in code blocks though. I suspect this may also fix #188.
* Fix all pyflakes unused-import/unused-variable warningsDmitry Shachnev2012-11-091-1/+0
|
* Fixed #87Catalin Iacob2012-04-161-6/+7
| | | | Elements should be inserted in the tree regardless of enable_attributes
* Fixed #31. Headers in tight lists now get inline patterns run on their ↵Waylan Limberg2011-07-211-1/+12
| | | | tails. Tests included.
* Partial fix of issue #14. hrefs (and titles) are now unescaped, but it ↵Waylan Limberg2011-06-021-2/+1
| | | | uppears that we are loosing escaped backslashes (both in the href and in the link label in the example given in issue 14.
* Fixed Ticket 74. AtomicStrings should now be ackowledged (and preserved) in ↵Waylan Limberg2010-11-041-1/+6
| | | | all instances. This was a real pain to debug, but an easy fix once I found it. Thanks to obs for the report.
* Cleaned up whitespace and linewrap issues in treeprocessorspy and fixed a ↵Waylan Limberg2010-11-011-15/+17
| | | | few typos in docs.
* A better implementation of globals as attributes on the Markdown class. This ↵Waylan Limberg2010-07-071-1/+1
| | | | should be more future proof.
* Factored out the building of the various processors and patterns into ↵Waylan Limberg2010-07-071-0/+10
| | | | utility functions called by a build_parser method on the Markdown class. Editing of the processors and patterns now all happen in one file for each type. Additionaly, a subclass of Markdown could potentially override the build_parser method and build a parser for a completely differant markup language without first building the default and then overriding it.
* Moved a bunch of global variables to the instance of the Markdown class.Waylan Limberg2010-07-061-1/+1
|
* Rename misc.py to util.py at the request of upstreamToshio Kuratomi2010-07-051-12/+12
|
* Break cyclic import of markdown. This allows people to embed markdownToshio Kuratomi2010-07-051-15/+17
| | | | if they desire.
* Fix for undefined variables that need to be importedToshio Kuratomi2010-07-051-1/+1
|
* The ENABLE_ATTRIBUTES global setting is now ackowledged.Waylan Limberg2009-10-211-17/+18
|
* Getting rid of has_key for compatibility with python3k.Yuri Takhteyev2008-12-041-1/+1
|
* Cleaned up recent refactor into a package from a single file.Waylan Limberg2008-11-201-9/+15
|
* Attempting a refactoring, breaking markdown into multiple files.Yuri Takhteyev2008-11-171-0/+323