summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix unescaping of HTML characters <> in CodeHilite. (#990)Rohitt Vashishtha2020-06-291-0/+23
| | | | | | | | | | | Previously, we'd unescape both `&amp;gt;` and `&gt;` to the same string because we were running the &amp; => & replacement first. By changing the order of this replacement, we now convert: `&amp;gt; &gt;` => `&gt; >` as expected. Fixes #988.
* Limit depth of blockquotes using Python's recursion limit. (#991)Waylan Limberg2020-06-291-0/+51
| | | | | | | | | | | | | | | | | 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.
* Refactor fenced_code & codehilite options (#816)Waylan Limberg2020-06-237-455/+1303
| | | | | | | | | | | | | | | | | | | | * Add `language-` prefix to output when syntax highlighting is disabled for both codehilite and fenced_code extensions. * Add `lang_prefix` config option to customize the prefix. * Add a 'pygments' env to tox which runs the tests with Pygments installed. Pygments is locked to a specific version in the env. * Updated codehilite to accept any Pygments options. * Refactor fenced code attributes. - ID attr is defined on `pre` tag. - Add support for attr_list extension, which allows setting arbitrary attributes. - When syntax highlighting is enabled, any pygments options can be defined per block in the attr list. - For backward compatibility, continue to support `hi_lines` outside of an attr_list. That is the only attr other than lang which is allowed without the brackets (`{}`) of an attr list. Note that if the brackets exist, then everything, including lang and hl_lines, must be within them. * Resolves #775. Resolves #334. Addresses #652.
* Fix issues with complex emphasisfacelessuser2020-06-222-0/+28
| | | | | Resolves issue that can occur with complex emphasis combinations. Fixes #979
* Avoid importing packaging or pkg_resources for version validation (#948)Ran Benita2020-04-271-0/+24
| | | | | | | | | | | | | | Importing the `pkg_resources` module has high memory and startup time cost. A recent change in 102e01c already avoided it for loading extensions, but it's still used for validating that __version__ is correctly formatted. It is possible to avoid it by installing the `packaging` package, but that adds a dependency for something quite trivial. Instead, remove the validation and add tests which check the output is as expected. Since `setuptools` is no longer required at runtime, remove it from `install_required`.
* Correctly report if an extension raises a `TypeError`.Charles Merriam2020-04-191-2/+2
| | | Also Raise a `KeyError` when attempting to delete a nonexistent key from the extension registry.
* Fix typo, in the ten cut and pasted versionsCharles Merriam2020-04-1916-26/+26
|
* TOC fix for AtomicString handling (#934)Isaac Muse2020-04-061-0/+22
| | | Fixes #931.
* Fix escaping of HTML special chars (<, >, &) in `.toc_tokens`Jim Porter2020-02-121-13/+37
| | | | Fixes #906.
* Simplify xml.etree.ElementTree loading (#902)Dmitry Shachnev2020-02-031-50/+47
| | | | | | | | 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.
* Don't emit stashed HTML tag placeholders in `.toc_tokens` (#901)Jim Porter2020-01-311-24/+78
| | | | | | Note: this slightly changes existing behavior in that raw HTML tags are no longer included in the HTML `.toc`. However, the fact that that worked before was an oversight. The intention was always to strip all markup. Resolves #899.
* Add permalink_title option (#886)Waylan Limberg2019-11-261-0/+20
| | | | | Addes a new `permalink_title` option to the TOC extension, which allows the title attribute of a permalink to be set to something other than the default English string "Permanent link". Fixes #781.
* Add anchorlink_class and permalink_class options to TOCWaylan Limberg2019-11-261-0/+67
| | | | | | | | | Two new configuration options have been added to the toc extension: `anchorlink_class` and `permalink_class` which allows class(es) to be assigned to the `anchorlink` and `permalink` HTML respectively. This allows using icon fonts from CSS for the links. Therefore, an empty string passed to `permalink` now generates an empty `permalink`. Previously no `permalink` would have been generated. Based on #776.
* Unescape IDs in TOC.Waylan Limberg2019-11-251-0/+34
| | | | | | The slugify function will stript the STX and ETX characters from placeholders for backslash excaped characters. Therefore, we need to unescape any text before passing it to slugify. Fixes #864.
* Drop support for Python 2.7 (#865)Hugo van Kemenade2019-10-2422-49/+6
| | | | | | | * 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.
* Always wrap CodeHilite code in <code> tags (#862)Tim Martin2019-09-301-9/+9
| | | Pygments added the `wrapcode` option in version 2.4. Users need to have 2.4+ installed to see the change. However, as earlier versions accepted arbitrary keywords passed to the HTMLFormatter, no error will be raised if the user has an older version of Pygments installed.
* Refactor em strong to consolidate code and fix issue #792Isaac Muse2019-09-032-0/+45
|
* Optimize HTML_RE from quadratic time to linear (#804)Anders Kaseorg2019-08-143-24/+31
| | | | | | Remove misleading escaped_chars_in_js test Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* Use more specific asserts throughout testsJon Dufresne2019-06-132-26/+26
| | | | | | | | | | | | | | | | In the event that a test fails, a more specific assert will usually provide more useful information about what went wrong. Prefer assertIs(..., True) over assertTrue() to assert the type as well as the truthy value. This is recommended by Python: https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue > Note that this is equivalent to bool(expr) is True and not to expr is > True (use assertIs(expr, True) for the latter). This method should > also be avoided when more specific methods are available (e.g. > assertEqual(a, b) instead of assertTrue(a == b)), because they provide > a better error message in case of failure.
* Use https:// links where availableJon Dufresne2019-06-121-3/+3
|
* Optimize several regexes from quadratic time to linear timeAnders Kaseorg2019-03-061-1/+1
| | | | | | Part of the discussion in #798. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
* Add support for a range to toc_depth.Klaus Mueller2019-02-221-0/+55
| | | | Closes #786.
* Handle overlapping raw HTML matches (#770)Philip Trauner2019-02-071-0/+53
| | | | | Recursively run substitution to handle overlapping matches. Fixes #458.
* Emphasis pattern treats newlines as whitespace (#785)Waylan Limberg2019-02-071-0/+86
| | | | | | All whitespace characters should be treated the same by inline patterns. Previoulsy, emphasis patterns were only accounting for spaces, but not other whitepsace characters such as newlines. Fixes #783.
* Allow hashes to be escaped in headers (#763)Isaac Muse2018-12-221-0/+20
| | | | | Adjust pattern to allow for escaped hashes, but take care to not treat escaped escapes before hashes as escaped hashes. Close #762.
* Use a PEP562 implementation for deprecating attributes (#757)Isaac Muse2018-12-221-2/+2
| | | 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.
* Fix typos in tests namesDmitry Shachnev2018-12-191-3/+3
|
* Collapse all whitespace in reference ids (#743)Isaac Muse2018-10-301-0/+37
| | | Previously only newlines preceded by whitespace were collapsed. Fixes #742.
* Deprecate version and version_info (#740)Isaac Muse2018-10-251-0/+39
| | | | 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.
* Ensure block elements are defined per instancefacelessuser2018-10-091-0/+12
| | | | Block level elements should be defined per instance, not as base class variables.
* foot note adjustments (#728)Isaac Muse2018-10-099-2455/+2496
| | | | | | Add a config to set the footnote separator. Also remove rel/rev as they aren't really compatible with HTML5 and we already have classes set for refs and backrefs. Fixes 723.
* Fix double escaping of block code (#727)Isaac Muse2018-10-071-0/+92
| | | | | Fixes #725
* Add a test for the markdown/serializers.py changeDmitry Shachnev2018-09-251-0/+4
|
* Make ENTITY_RE support hexadecimal entitiesissue712Dmitry Shachnev2018-09-251-0/+44
| | | | Fixes #712.
* Support custom labels in TOC. (#700)Waylan Limberg2018-09-051-9/+25
| | | | | | | | 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.
* Move isBlockLevel to class. (#693)Waylan Limberg2018-07-311-3/+4
| | | | | Allows users and/or extensions to alter the list of block level elements. The old implementation remains with a DeprecationWarning. Fixes #575.
* Deprecate md_globals from extension API. (#697)Waylan Limberg2018-07-311-2/+2
| | | | | | 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.
* Refactor options testsWaylan Limberg2018-07-314-10/+12
|
* smart_emphasis keyword > legacy_em extension.Waylan Limberg2018-07-317-7/+43
| | | | | | | | | The smart_strong extension has been removed and its behavior is now the default (smart em and smart strong are the default). The legacy_em extension restores legacy behavior (no smart em or smart strong). This completes the removal of keywords. All parser behavior is now modified by extensions, not by keywords on the Markdown class.
* Remove lazy_ol keyword. Use sane_lists extension instead.Waylan Limberg2018-07-315-38/+22
| | | | This was adapted from 11408e50 of the md3 branch.
* Removed unnessecary no attributes test. (#694)Waylan Limberg2018-07-313-7/+0
| | | This was missed in #683.
* Fix double escaping of amp in attributes (#670)Isaac Muse2018-07-295-2/+21
| | | | | | | | | | 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-2716-3/+341
| | | | Fixes #435.
* Replace homegrown OrderedDict with purpose-built Registry. (#688)Waylan Limberg2018-07-271-147/+212
| | | | | | | | | | | | | | | | | | | 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-0/+54
|
* Add the possibility to set additional classesWhiteWinterWolf2018-07-242-0/+17
| | | | | | | | | | | | | | | | | Additional CSS classes names can be appended to the admonition name using spaces as separators. The following markdown: !!! note floatright This is a floating note. Generates the following HTML code: <div class="admonition note floatright"> <p class="admonition-title">Note</p> <p>This is a floating note.</p> </div>
* Moved enable_attributes keyword to extension: legacy_attrs.Waylan Limberg2018-07-2412-37/+55
| | | | | | | 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.
* Improve serializer test coverageWaylan Limberg2018-07-241-6/+64
| | | | | | | | | Should be 100% coverage now. The ProcessingInstruction needed to be imported directly from ElementTree as PY27 was using a PIProxy which resulted in a bug. Interestingly, PY3 worked fine. Also removed the encoding code as it was not used. Besides it was only ever accessable from a private function.
* Simplify namespace support in serializer.Waylan Limberg2018-07-241-0/+29
| | | | Fixes #679.
* Implement reset() for Meta extension (#672)Glandos2018-06-191-0/+14
| | | | Fixes #671