summaryrefslogtreecommitdiff
path: root/markdown/util.py
Commit message (Collapse)AuthorAgeFilesLines
* Use pyspelling to check spelling.Waylan Limberg2023-04-061-11/+11
| | | In addition to checking the spelling in our documentation, we are now also checking the spelling of the README.md and similar files as well as comments in our Python code.
* Consider <html> a block-level HTML element (#1309)kernc2022-12-021-2/+2
|
* Remove previously deprecated objectsWaylan Limberg2022-05-271-106/+0
| | | This completely removes all objects which were deprecated in version 3.0 (this change will be included in version 3.4). Given the time that has passed, and the fact that older unmaintained extensions are not likely to support the new minimum Python version, this is little concern about breaking older extensions.
* Drop support for PY36Waylan Limberg2022-05-241-9/+1
| | | | | | | | Python dropped support on 2021-12-23. Our policy (#760) is to drop support on the next point release after Python does. * Remove py36 tests * Test multiple recent versions of pypy * Remove pep562 backport
* Only enumerate extension entry points when requiredAarni Koskela2022-05-241-9/+11
|
* Use `@deprecated` for __setitem__ and __delitem__ of Registry.L2022-05-161-12/+2
|
* Use `@deprecated` for Registry.add()L2022-05-161-6/+1
|
* [style]: fix various typos in docstrings and commentsFlorian Best2022-03-181-3/+3
|
* Support Python 3.10Waylan Limberg2021-11-161-4/+4
| | | Fixes #1124.
* Remove SO attributions to sidestep licensing greynessJarek Głowacki2021-07-011-9/+12
|
* Unify all block-level tags. (#1048)Waylan Limberg2020-10-201-4/+5
| | | | | | Use the list of tags defined in the core by the md_in_html extension. This ensures that the lists do not diverge and allows users and/or extensions to expand the list in the core and have that change affect the extension. Fixes #1047.
* Limit depth of blockquotes using Python's recursion limit. (#991)Waylan Limberg2020-06-291-0/+18
| | | | | | | | | | | | | | | | | If the Python stack comes within 100 frames of the recursion limit, then the nesting limit of blockquotes is met. Any remaining text, including angle brackets, are simply wrapped in a paragraph. To increasing the nesting depth, increase Python's recursion limit. However, be aware that each level of recursion will likely result in multiple frames being added to the Python stack. Therefore, the recursion depth and nesting depth are not one-to-one. Performance is an concern here. However, the current solution seems like a reasonable compromise. It doesn't slow things down too much, but also avoids Markdown input resulting in an error. This is mostly only a concern with contrived input anyway. For the average Markdown document, this will likely never be an issue. Fixes #799.
* Correctly report if an extension raises a `TypeError`.Charles Merriam2020-04-191-1/+1
| | | Also Raise a `KeyError` when attempting to delete a nonexistent key from the extension registry.
* Load entry_points once using importlib.metadata.Waylan Limberg2020-04-181-0/+7
| | | | This should be more performant. Fixes #942.
* Simplify xml.etree.ElementTree loading (#902)Dmitry Shachnev2020-02-031-17/+2
| | | | | | | | cElementTree is a deprecated alias for ElementTree since Python 3.3. Also drop the recommendation to import etree from markdown.util, and deprecate markdown.util.etree.
* Drop support for Python 2.7 (#865)Hugo van Kemenade2019-10-241-27/+37
| | | | | | | * Python syntax upgraded using `pyupgrade --py3-plus` * Travis no longer uses `sudo`. See https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration See #760 for Python Version Support Timeline and related dicussion.
* Use https:// links where availableJon Dufresne2019-06-121-1/+1
|
* Use a PEP562 implementation for deprecating attributes (#757)Isaac Muse2018-12-221-38/+1
| | | Use a vendored Pep562 backport to simulate Python 3.7's new PEP 562 feature. For Python3.7 and later, default to the official implementation.
* add: use stacklevel=2 with warningDaniel Hahler2018-11-141-3/+9
|
* Deprecate version and version_info (#740)Isaac Muse2018-10-251-2/+40
| | | | This essentially implements the closest we can get to PEP 562 which allows for modules to control `__dir__` and `__getattr__` in order to deprecate attributes. Here we provide a wrapper class for the module in `util`. If a module has attributes that need to deprecated, we derive from the wrapper class and define the attributes as functions with the `property` decorator and the provided `deprecated` decorator. The class is instantiated with the module's `__name__` attribute and the class will properly replace the module with the wrapped module. When accessing the depracted attributes, a warning is raised. Closes #739.
* Move isBlockLevel to class. (#693)Waylan Limberg2018-07-311-19/+20
| | | | | Allows users and/or extensions to alter the list of block level elements. The old implementation remains with a DeprecationWarning. Fixes #575.
* Fix double escaping of amp in attributes (#670)Isaac Muse2018-07-291-0/+11
| | | | | | | | | | Serializer should only escape & in attributes if not part of &amp; Better regex avoid Unicode and `_` in amp detection. In general, we don't want to escape already escaped content, but with code content, we want literal representations of escaped content, so have code content explicitly escape its content before placing in AtomicStrings. Closes #669.
* Consistent copyright headers.Waylan Limberg2018-07-271-0/+21
| | | | Fixes #435.
* All Markdown instances are now 'md'. (#691)Waylan Limberg2018-07-271-3/+28
| | | | | | | | | | | | 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).
* Add 'style' to block level elementsWaylan Limberg2018-07-271-1/+1
| | | Fixes #689.
* Replace homegrown OrderedDict with purpose-built Registry. (#688)Waylan Limberg2018-07-271-0/+215
| | | | | | | | | | | | | | | | | | | 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.
* Update block level elements.Waylan Limberg2018-03-161-10/+13
| | | | | Also refactor from regex to a list and add comments to explain why the elements are in the list for future reference. Fixes #543.
* Flexible inline (#629)Isaac Muse2018-01-171-0/+2
| | | | 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.
* Removed deprecated safe_mode.Waylan Limberg2018-01-111-3/+2
|
* Make sure regex patterns are raw strings (#614)Isaac Muse2018-01-021-6/+6
| | | 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.
* Recognize <main> as an HTML5 block level tag. (#525)daniel-j-mac2017-01-171-1/+1
|
* flake8ifyMarc Abramowitz2014-12-091-3/+3
|
* Flake8 cleanup (mostly whitespace).Waylan Limberg2014-11-201-19/+27
| | | | | | 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.
* Fixed a bug in markdown.util.parseBoolValueWaylan Limberg2014-08-251-3/+3
| | | | | A couple scenarios with "None" were previously not accounted for. Also updated tests which guives us 100% for markdown/util.py
* Update extensions for Extension.__init__ refactorWaylan Limberg2014-07-311-3/+8
| | | | | | | | | | | | | | | | | 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).
* Marked a bunch of lines as 'no cover'. Coverage at 91%Waylan Limberg2014-07-111-4/+5
|
* added nav-tag as block level elementDavid2014-03-021-1/+1
|
* No longer restrict INLUNE_PLACEHOLDER to 4 digits.Waylan Limberg2014-02-021-1/+1
| | | | | | This was limiting the parser to only 10,000 placeholders (0-9999) per document. removing this limitation allows longer documents ot be parsered correctly. Fixes #255.
* Issue #52ryneeverett2013-10-141-3/+14
|
* Add new "permalink" option to toc extensionDmitry Shachnev2013-09-251-1/+1
| | | | and use it in our docs
* Add new utility function parseBoolValue()Dmitry Shachnev2013-09-251-0/+13
| | | | and use it in all extension that need parsing bool config values.
* Typo in util.pyGrahack2013-08-241-1/+1
| | | implemenation -> implementation
* HeaderID Ext now handles raw html in ids. Fixes #232Waylan Limberg2013-07-281-1/+4
|
* Now using universal code for Python 2 & 3.Waylan Limberg2013-02-271-9/+22
| | | | | | | | | | 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.
* Simlify importing ElementTreeWaylan Limberg2013-02-261-2/+13
| | | | | | As we no longer support older python versions, importing ElementTree is much simpler. The documented way for extensions to use etree still remains the same.
* Fix all pyflakes unused-import/unused-variable warningsDmitry Shachnev2012-11-091-2/+0
|
* Fixed #151. Raw html matching is now case-insensitive.Waylan Limberg2012-10-211-1/+1
|
* Remove `<ins>` and `<del>` from html block element listfin2012-04-111-1/+1
| | | | They are span elements. `<del>` is explicitly mentioned as such in the [markdown syntax document](http://daringfireball.net/projects/markdown/syntax)
* Fixed #77. util.isBlockLevel() needs to check entire tag passed to it.Waylan Limberg2012-01-301-2/+2
|
* Partial fix of issue #14. hrefs (and titles) are now unescaped, but it ↵Waylan Limberg2011-06-021-0/+1
| | | | uppears that we are loosing escaped backslashes (both in the href and in the link label in the example given in issue 14.