diff --git a/docs/plugins/blog.md b/docs/plugins/blog.md index 3c36f511c..172e85d45 100644 --- a/docs/plugins/blog.md +++ b/docs/plugins/blog.md @@ -406,35 +406,24 @@ If more than one category is given, they are joined with `/` after slugifying. #### - + -Use this setting to change the function to use for generating URL-compatible -slugs from post titles. [Python Markdown Extensions] comes with a Unicode-aware -[`slugify`][pymdownx.slugs.slugify] function: +Use this setting to change the function for generating URL-compatible slugs +from post titles. By default, the [`slugify`][pymdownx.slugs.slugify] function +from [Python Markdown Extensions] is used as follows: -=== "Unicode" +``` yaml +plugins: + - blog: + post_slugify: !!python/object/apply:pymdownx.slugs.slugify + kwds: + case: lower +``` - ``` yaml - plugins: - - blog: - post_slugify: !!python/object/apply:pymdownx.slugs.slugify - kwds: - case: lower - ``` +The default configuration is Unicode-aware and should produce good slugs for all +languages. Of course, you can also provide a custom slugification function for +more granular control. -=== "Unicode, case-sensitive" - - ``` yaml - plugins: - - blog: - post_slugify: !!python/object/apply:pymdownx.slugs.slugify - ``` - -When your project features non-European languages, it's advisable to use this -configuration. Of course, you can also provide a custom slugification function -for more granular control. - - [toc.slugify]: https://github.com/Python-Markdown/markdown/blob/1337d0891757e192165668d2606db36cf08e65a9/markdown/extensions/toc.py#L26-L33 [pymdownx.slugs.slugify]: https://github.com/facelessuser/pymdown-extensions/blob/01c91ce79c91304c22b4e3d7a9261accc931d707/pymdownx/slugs.py#L59-L65 [Python Markdown Extensions]: https://facelessuser.github.io/pymdown-extensions/extras/slugs/ @@ -856,31 +845,23 @@ The following placeholders are available: #### - + -Use this setting to change the function to use for generating URL-compatible -slugs from categories. [Python Markdown Extensions] comes with a Unicode-aware -[`slugify`][pymdownx.slugs.slugify] function: +Use this setting to change the function for generating URL-compatible slugs +from categories. By default, the [`slugify`][pymdownx.slugs.slugify] function +from [Python Markdown Extensions] is used as follows: -=== "Unicode" +``` yaml +plugins: + - blog: + post_slugify: !!python/object/apply:pymdownx.slugs.slugify + kwds: + case: lower +``` - ``` yaml - plugins: - - blog: - categories_slugify: !!python/object/apply:pymdownx.slugs.slugify - kwds: - case: lower - ``` - -=== "Unicode, case-sensitive" - - ``` yaml - plugins: - - blog: - categories_slugify: !!python/object/apply:pymdownx.slugs.slugify - ``` -When your project features non-European languages, it's advisable to use this -configuration. +The default configuration is Unicode-aware and should produce good slugs for all +languages. Of course, you can also provide a custom slugification function for +more granular control. --- diff --git a/material/plugins/blog/config.py b/material/plugins/blog/config.py index c7a850958..18dbc97d3 100644 --- a/material/plugins/blog/config.py +++ b/material/plugins/blog/config.py @@ -19,9 +19,9 @@ # IN THE SOFTWARE. from functools import partial -from markdown.extensions.toc import slugify from mkdocs.config.config_options import Choice, Deprecated, Optional, Type from mkdocs.config.base import Config +from pymdownx.slugs import slugify # ----------------------------------------------------------------------------- # Classes @@ -41,7 +41,7 @@ class BlogConfig(Config): post_url_date_format = Type(str, default = "yyyy/MM/dd") post_url_format = Type(str, default = "{date}/{slug}") post_url_max_categories = Type(int, default = 1) - post_slugify = Type((type(slugify), partial), default = slugify) + post_slugify = Type(partial, default = slugify(case = "lower")) post_slugify_separator = Type(str, default = "-") post_excerpt = Choice(["optional", "required"], default = "optional") post_excerpt_max_authors = Type(int, default = 1) @@ -62,7 +62,7 @@ class BlogConfig(Config): categories = Type(bool, default = True) categories_name = Type(str, default = "blog.categories") categories_url_format = Type(str, default = "category/{slug}") - categories_slugify = Type((type(slugify), partial), default = slugify) + categories_slugify = Type(partial, default = slugify(case = "lower")) categories_slugify_separator = Type(str, default = "-") categories_allowed = Type(list, default = []) categories_toc = Optional(Type(bool)) diff --git a/src/plugins/blog/config.py b/src/plugins/blog/config.py index c7a850958..18dbc97d3 100644 --- a/src/plugins/blog/config.py +++ b/src/plugins/blog/config.py @@ -19,9 +19,9 @@ # IN THE SOFTWARE. from functools import partial -from markdown.extensions.toc import slugify from mkdocs.config.config_options import Choice, Deprecated, Optional, Type from mkdocs.config.base import Config +from pymdownx.slugs import slugify # ----------------------------------------------------------------------------- # Classes @@ -41,7 +41,7 @@ class BlogConfig(Config): post_url_date_format = Type(str, default = "yyyy/MM/dd") post_url_format = Type(str, default = "{date}/{slug}") post_url_max_categories = Type(int, default = 1) - post_slugify = Type((type(slugify), partial), default = slugify) + post_slugify = Type(partial, default = slugify(case = "lower")) post_slugify_separator = Type(str, default = "-") post_excerpt = Choice(["optional", "required"], default = "optional") post_excerpt_max_authors = Type(int, default = 1) @@ -62,7 +62,7 @@ class BlogConfig(Config): categories = Type(bool, default = True) categories_name = Type(str, default = "blog.categories") categories_url_format = Type(str, default = "category/{slug}") - categories_slugify = Type((type(slugify), partial), default = slugify) + categories_slugify = Type(partial, default = slugify(case = "lower")) categories_slugify_separator = Type(str, default = "-") categories_allowed = Type(list, default = []) categories_toc = Optional(Type(bool))