Skip to content

Commit

Permalink
Deprecate extrarawhtml in favor of md_in_html in Python Markdown 3.2 (#…
Browse files Browse the repository at this point in the history
…773)

* Deprecate extrarawhtml in favor of md_in_html in Python Markdown 3.2

* Attempt to fix document test conflict
  • Loading branch information
facelessuser authored Dec 28, 2019
1 parent ae04e5a commit f17ba7b
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pyspelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ matrix:
sources:
- pymdownx/**/*.py
- tests/**/*.py
- tools/**/*.py|!tools/tags/*
- tools/**/*.py|!tools/tags/**
aspell:
lang: en
hunspell:
Expand Down
5 changes: 5 additions & 0 deletions docs/src/markdown/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.3.0

- **NEW**: `pymdownx.extrarawhtml` is now deprecated in favor of Python Markdown's `md_in_html` extension found in the
3.2 release.

## 6.2.1

- **FIX**: Fix issue in PathConverter where Windows path conversion from relative to absolute doesn't always work in all
Expand Down
7 changes: 7 additions & 0 deletions docs/src/markdown/extensions/extrarawhtml.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Overview

!!! warning "Deprecated 6.3"
ExtraRawHTML has been deprecated in 6.3.

As of Python Markdown release 3.2, raw HTML handling has been broken out into a separate extensions called
`md_in_html`. This change makes the existence of `extrarawhtml` redundant. It is advised that all users use
`md_in_html` moving forward. `extrarawhtml` will be removed in a future version.

Python Markdown provides an `extra` extension that has features similar to PHP Markdown Extra. For reasons covered in
[`pymdownx.extra`](./extra.md), PyMdown Extensions implements its own `extra` extension. In order to accomplish this,
Python Markdown's raw HTML parsing functionality, which is used to parse nested Markdown inside HTML blocks, had to be
Expand Down
2 changes: 1 addition & 1 deletion pymdownx/__meta__.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,5 @@ def parse_version(ver, pre=False):
return Version(major, minor, micro, release, pre, post, dev)


__version_info__ = Version(6, 2, 1, "final")
__version_info__ = Version(6, 3, 0, ".dev")
__version__ = __version_info__._get_canonical()
3 changes: 2 additions & 1 deletion pymdownx/extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"""
from __future__ import unicode_literals
from markdown import Extension
from . import util

extra_extensions = [
'pymdownx.betterem',
Expand All @@ -38,7 +39,7 @@
'markdown.extensions.def_list',
'markdown.extensions.tables',
'markdown.extensions.abbr',
'pymdownx.extrarawhtml'
'markdown.extensions.md_in_html' if util.MD32 else 'pymdownx.extrarawhtml'
]

extra_extension_configs = {}
Expand Down
12 changes: 10 additions & 2 deletions pymdownx/extrarawhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
"""
from __future__ import unicode_literals
from markdown import Extension
from markdown.extensions import extra
import re
from . import util
if util.MD32: # pragma: no cover
from markdown.extensions import md_in_html as module
else:
from markdown.extensions import extra as module


class ExtraRawHtmExtension(Extension):
Expand All @@ -23,11 +27,15 @@ class ExtraRawHtmExtension(Extension):
def extendMarkdown(self, md):
"""Register extension instances."""

util.PymdownxDeprecationWarning(
"'extrarawhtml' extension is deprected, 'markdown.extensions.md_in_html' should be used instead"
)

md.registerExtension(self)
# Turn on processing of markdown text within raw html
md.preprocessors['html_block'].markdown_in_raw = True
md.parser.blockprocessors.register(
extra.MarkdownInHtmlProcessor(md.parser), 'markdown_block', 105
module.MarkdownInHtmlProcessor(md.parser), 'markdown_block', 105
)
md.parser.blockprocessors.tag_counter = -1
md.parser.blockprocessors.contain_span_tags = re.compile(
Expand Down
2 changes: 2 additions & 0 deletions pymdownx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"""
from __future__ import unicode_literals
from markdown.inlinepatterns import InlineProcessor, util
from markdown.__meta__ import __version_info__
from collections import namedtuple
import sys
import copy
import re

MD32 = __version_info__ >= (3, 2)
PY3 = sys.version_info >= (3, 0)
PY34 = sys.version_info >= (3, 4)

Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mkdocs-material>=2.8.0
mkdocs-material==4.4.3
git+https://github.com/facelessuser/pymdown-lexers.git
pyspelling
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ commands=
[testenv:documents]
deps=
-rrequirements/docs.txt
-rrequirements/project.txt
-rrequirements/extra.txt
commands=
{envpython} -m pip install .
Expand Down

0 comments on commit f17ba7b

Please sign in to comment.