| 1 |
# 9.0 Migration Notes {: #\9.0} |
| 2 |
|
| 3 |
## Overview |
| 4 |
|
| 5 |
There are many new features that come with 9.0, and a little housecleaning as well. This guide will touch on migration |
| 6 |
concerns related to removals, deprecations, and/or breaking changes. |
| 7 |
|
| 8 |
In general, there should be no breaking changes in 9.0 unless you were still using old, already deprecated features. |
| 9 |
|
| 10 |
## Gone \& Deprecated |
| 11 |
|
| 12 |
Removed deprecated features: |
| 13 |
|
| 14 |
- Highlight's `legacy_no_wrap_code` option was removed. This used to allow people to output code blocks in Pygments' |
| 15 |
original way, which simply inserted code in a `#!html <pre>` block. This was added all the way back in 6.3 and was |
| 16 |
only added to help transition people to the new output which is HTML5 compatible and wraps code in |
| 17 |
`#!html <pre><code>` blocks. If you have styling or logic that depending on this old, deprecated option, you will |
| 18 |
have to update said styles and/or script logic to account for the new output. |
| 19 |
|
| 20 |
- Highlight's `highlight_code` option has formally been removed. This option as been a NOOP for a long time and was |
| 21 |
just left around in order to not break people's usage of Highlight. It has now been removed. If it was still hanging |
| 22 |
around in your config, it should simply be removed. Nothing functionally will change. |
| 23 |
|
| 24 |
- SuperFences, in 7.0, changed up the format of the custom fences. When custom fences were added, a full vision of how |
| 25 |
they would/should be used had not fully cemented, so unfortunately they have been revised occasionally, 7.0 being |
| 26 |
the most recent time. To help transition people, a fallback was left in with a warning. This fallback code has now |
| 27 |
been removed. Information regarding how to upgrade the format is available in the |
| 28 |
[7.0 release guide](./7.0.md#superfences-configurable-classes-and-ids). |
| 29 |
|
| 30 |
As far as deprecated functions and features are concerned: |
| 31 |
|
| 32 |
- Arithmatex has deprecated all of its SuperFences custom fence functions and instead has replaced it with two |
| 33 |
configurable methods. MkDocs users may have some concerns that these will not work in the YAML configuration, but |
| 34 |
fear not as things work just fine. Check out [Arithmatex Custom Fences](#arithmatex) for more info. |
| 35 |
|
| 36 |
- PyMdown Extensions provided a number of slugify functions which, like with Arithmatex, have been consolidated into a |
| 37 |
single configurable function. With this consolidation, two new options have been added that allow applying Python's |
| 38 |
default case folding on slugs and allow configuring Unicode normalization. Personally, we feel NFC is the way to go, |
| 39 |
but if others disagree, this is now configurable. Check out |
| 40 |
[One Slugify to Rule Them All](#one-slugify-to-rule-them-all). Much like the new Arithmatex formatters, these slugs, |
| 41 |
even though they are configurable, will work with MkDocs just fine. |
| 42 |
|
| 43 |
## Arithmatex |
| 44 |
|
| 45 |
Arithmatex now as two new custom fences that can be used for InlineHilite and SuperFences: `arithmatex_inline_format` |
| 46 |
and `arithmatex_fenced_format` respectively. They can do everything the old methods can do and are configurable. The old |
| 47 |
formatters are still available, but have been deprecated. |
| 48 |
|
| 49 |
`arithmatex_inline_format` is meant for InlineHilite and replaces all other inline formatters. The table below shows how |
| 50 |
to migrate: |
| 51 |
|
| 52 |
Name | Migration |
| 53 |
------------------------------- | --------- |
| 54 |
`inline_mathjax_preview_format` | `#!py arithmatex_inline_format(mode="mathjax", preview=True)` |
| 55 |
`inline_mathjax_format` | `#!py arithmatex_inline_format(mode="mathjax")` |
| 56 |
`inline_generic_format` | `#!py arithmatex_inline_format(mode="generic")` |
| 57 |
|
| 58 |
`arithmatex_fenced_format` is meant for SuperFences and replaces all related fenced style formatters. |
| 59 |
|
| 60 |
Name | Migration |
| 61 |
------------------------------ | --------- |
| 62 |
`fence_mathjax_preview_format` | `#!py arithmatex_fenced_format(mode="mathjax", preview=True)` |
| 63 |
`_inline_mathjax_format` | `#!py arithmatex_fenced_format(mode="mathjax")` |
| 64 |
`inline_generic_format` | `#!py arithmatex_fenced_format(mode="generic")` |
| 65 |
|
| 66 |
These new, custom fences also add some new features, like being able to change the wrapper element. If you happen to |
| 67 |
use MkDocs with Arithmatex, and happen to use `mkdocs-minify-plugin`, you may notice that some math blocks don't render |
| 68 |
proper. This is because the plugin butchers white space in the wrapper `#!html <div>` element. Now you can wrap your |
| 69 |
math in a `#!html <pre>` and move on :smile:. This is configurable as an Arithmatex option called `block_tag` and |
| 70 |
`inline_tag`. The custom fences and formatters also have a `tag` option where this can be configured. |
| 71 |
|
| 72 |
/// note | MkDocs Users |
| 73 |
Fear not, this works for MkDocs as well! Using the following syntax can allow you to specify the function with |
| 74 |
keyword arguments: |
| 75 |
|
| 76 |
```yaml |
| 77 |
markdown_extensions: |
| 78 |
- pymdownx.superfences: |
| 79 |
custom_fences: |
| 80 |
- name: math |
| 81 |
class: arithmatex |
| 82 |
format: !!python/object/apply:pymdownx.arithmatex.arithmatex_fenced_format {kwds: {mode: generic, tag: pre}} |
| 83 |
``` |
| 84 |
|
| 85 |
While the above is a personal preference as it keeps the arguments on the same line as the function, you can also |
| 86 |
specify them in this way which some may find cleaner: |
| 87 |
|
| 88 |
```yaml |
| 89 |
markdown_extensions: |
| 90 |
- pymdownx.superfences: |
| 91 |
custom_fences: |
| 92 |
- name: math |
| 93 |
class: arithmatex |
| 94 |
format: !!python/object/apply:pymdownx.arithmatex.arithmatex_fenced_format |
| 95 |
kwds: |
| 96 |
mode: generic |
| 97 |
tag: pre |
| 98 |
``` |
| 99 |
/// |
| 100 |
|
| 101 |
## One Slugify to Rule Them All |
| 102 |
|
| 103 |
Previously, the `slug` module provided numerous slugify functions, they have all been reduced to one configurable |
| 104 |
function. Migration is shown below: |
| 105 |
|
| 106 |
Name | Migration |
| 107 |
------------------------ | --------- |
| 108 |
`uslugify` | `#!py slugify(case="lower", percent_encode=True)` |
| 109 |
`uslugify_encoded` | `#!py slugify(case="lower", )` |
| 110 |
`uslugify_cased` | `#!py slugify(percent_encode=True)` |
| 111 |
`uslugify_cased_encoded` | `#!py slugify()` |
| 112 |
`gfm` | `#!py slugify(case="lower-ascii", percent_encode=True)` |
| 113 |
`gfm_encoded` | `#!py slugify(case="lower-ascii")` |
| 114 |
|
| 115 |
Additionally, you can now set `case="fold"` to use Python's default case folding and set `normalize` to different |
| 116 |
Unicode normalization modes (`NFC` is default). |
| 117 |
|
| 118 |
/// note | MkDocs Users |
| 119 |
Fear not, this works for MkDocs as well! Using the following syntax can allow you to specify the function with |
| 120 |
keyword arguments: |
| 121 |
|
| 122 |
```yaml |
| 123 |
markdown_extensions: |
| 124 |
- markdown.extensions.toc: |
| 125 |
slugify: !!python/object/apply:pymdownx.slugs.slugify {kwds: {case: lower}} |
| 126 |
``` |
| 127 |
|
| 128 |
While the above is a personal preference as it keeps the arguments on the same line as the function, you can also |
| 129 |
specify them in this way which some may find cleaner: |
| 130 |
|
| 131 |
```yaml |
| 132 |
markdown_extensions: |
| 133 |
- markdown.extensions.toc: |
| 134 |
slugify: !!python/object/apply:pymdownx.slugs.slugify |
| 135 |
kwds: |
| 136 |
case: lower |
| 137 |
``` |
| 138 |
/// |