Skip to content

Commit eebdd49

Browse files
authored
Deprecate Critic view mode (#2796)
* Deprecate Critic view mode Resolves #2786 * Fix lint
1 parent 4e8a6ee commit eebdd49

File tree

15 files changed

+290
-185
lines changed

15 files changed

+290
-185
lines changed

docs/src/markdown/about/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ icon: lucide/scroll-text
33
---
44
# Changelog
55

6+
## 10.18
7+
8+
- **NEW**: Critic: `view` mode has been deprecated. To avoid warnings or future issues, explicitly set `mode` to
9+
either `accept` or `reject`. In the future, the new default will be `accept` and the `view` mode will be removed
10+
entirely.
11+
612
## 10.17.2
713

814
- **FIX**: Blocks: Blocks extensions will now better handle nesting of indented style Admonitions, Details, and Tabbed

docs/src/markdown/extensions/critic.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ represent edits to a Markdown document. This extension runs before all other ex
1313
Critic allows you to automatically accept edits or reject the edits and render the output accordingly. It also allows
1414
for visually displaying the changes in HTML output ([mileage may vary](#limitations-with-previewing-critic-markup)).
1515

16+
/// warning | Previews Deprecated
17+
The preview mode has been deprecated, and the default `mode` will be set to `accept` in the future. If you rely on
18+
Critic, is advised to explicitly set `mode` to either `accept` or `reject` to be protected against any issues related
19+
to this change in default and removal of the `view` mode in the future.
20+
21+
The `view` mode is being removed simply because support was never that great, and in order to get the quality expected,
22+
the feature would have to be implemented into the core of Python Markdown, something that is impossible for us to do.
23+
///
24+
1625
The Critic extension can be included in Python Markdown by using the following:
1726

1827
```py3

pymdownx/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,5 +193,5 @@ def parse_version(ver: str) -> Version:
193193
return Version(major, minor, micro, release, pre, post, dev)
194194

195195

196-
__version_info__ = Version(10, 17, 2, "final")
196+
__version_info__ = Version(10, 18, 0, "final")
197197
__version__ = __version_info__._get_canonical()

pymdownx/critic.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from markdown.preprocessors import Preprocessor
2828
from markdown.postprocessors import Postprocessor
2929
from markdown.util import STX, ETX
30+
from .util import warn_deprecated
3031
import re
3132

3233
SOH = '\u0001' # start
@@ -294,7 +295,10 @@ def __init__(self, *args, **kwargs):
294295
"""Initialize."""
295296

296297
self.config = {
297-
'mode': ['view', "Critic mode to run in ('view', 'accept', or 'reject') - Default: view "],
298+
'mode': [
299+
'view',
300+
"Critic mode to run in: 'view' (deprecated), 'accept' (future default), or 'reject' - Default: view "
301+
],
298302
'raw_view': [False, "Raw view keeps the output as the raw markup for view mode - Default False"]
299303
}
300304

@@ -308,6 +312,12 @@ def extendMarkdown(self, md):
308312
post = CriticsPostprocessor(self.critic_stash)
309313
critic = CriticViewPreprocessor(self.critic_stash)
310314
critic.config = self.getConfigs()
315+
if critic.config['mode'] == 'view':
316+
warn_deprecated(
317+
"pymdownx.critic has deprecated the 'view' mode and will default the option to 'accept' "
318+
"in the future. It is advised to set the 'mode' option explicitly to either 'accept' or "
319+
"'reject' to avoid issues when this change takes place."
320+
)
311321
md.preprocessors.register(critic, "critic", 31.1)
312322
md.postprocessors.register(post, "critic-post", 25)
313323
md.registerExtensions(["pymdownx._bypassnorm"], {})

tests/extensions/critic/critic (accept).html

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/extensions/critic/critic (accept).txt

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/extensions/critic/critic (reject).html

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/extensions/critic/critic (reject).txt

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/extensions/critic/critic (view).html

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/extensions/critic/critic (view).txt

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)