facelessuser / pymdown-extensions

Extensions for Python Markdown
https://facelessuser.github.io/pymdown-extensions/
Other
949 stars 253 forks source link

Admonition doesn't allow adding custom types in mkdocs.yml #2419

Closed nidem closed 1 month ago

nidem commented 1 month ago

Description

I used the same syntax in https://github.com/facelessuser/pymdown-extensions/blob/main/mkdocs.yml#L175-L220 to add additional types to both admonition and details, but returns the error Invalid Markdown Extensions configuration.

Minimal Reproduction

  1. Setup an existing project with the required plugins
  2. Add lines https://github.com/facelessuser/pymdown-extensions/blob/main/mkdocs.yml#L175-L22 to mkdocs.yml
  3. Error

Version(s) & System Info

facelessuser commented 1 month ago

@nidem you are going to need to provide details of exactly what you are doing. You are making a claim that using those configurations do not work, but it does work as my documentation is built with it and it uses both details and admonitions with custom types: https://facelessuser.github.io/pymdown-extensions/extensions/blocks/.

Screenshot 2024-07-22 at 8 28 54 PM

Please provide a minimal, reproducible example. The steps you listed are not enough because my project is already doing that and works fine. Most likely this is a user error, but since you aren't providing me a failing example, I can only guess what you might have done wrong.

facelessuser commented 1 month ago

To be clear, please provide me a minimal, failing example, contained in zip, that way I can see exactly what you are doing.

nidem commented 1 month ago

File is here: test-adding-types.tgz Also, here is the output of pip freeze. Babel==2.15.0 certifi==2024.7.4 charset-normalizer==3.3.2 click==8.1.7 colorama==0.4.6 ghp-import==2.1.0 idna==3.7 Jinja2==3.1.4 Markdown==3.6 MarkupSafe==2.1.5 mergedeep==1.3.4 mkdocs==1.6.0 mkdocs-get-deps==0.2.0 mkdocs-material==9.5.29 mkdocs-material-extensions==1.3.1 packaging==24.1 paginate==0.5.6 pathspec==0.12.1 platformdirs==4.2.2 Pygments==2.18.0 pymdown-extensions==10.8.1 python-dateutil==2.9.0.post0 PyYAML==6.0.1 pyyaml_env_tag==0.1 regex==2024.5.15 requests==2.32.3 six==1.16.0 urllib3==2.2.2 watchdog==4.0.1

nidem commented 1 month ago

I left index.md empty since it didn't matter because mkdocs would never run

$ mkdocs serve
ERROR   -  Config value 'markdown_extensions': Invalid Markdown Extensions configuration

Aborted with a configuration error!
facelessuser commented 1 month ago

Your indentation was wrong in your config. Here is the fixed config:

site_name: test

nav:
  - Home: index.md

# works
#markdown_extensions:
#  - pymdownx.blocks.admonition
#  - pymdownx.blocks.details

# errors
markdown_extensions:
  - pymdownx.blocks.admonition:
      types:
        - new
        - settings
        - note
        - abstract
        - info
        - tip
        - success
        - question
        - warning
        - failure
        - danger
        - bug
        - example
        - quote
  - pymdownx.blocks.details:
      types:
      - name: details-new
        class: new
      - name: details-settings
        class: settings
      - name: details-note
        class: note
      - name: details-abstract
        class: abstract
      - name: details-info
        class: info
      - name: details-tip
        class: tip
      - name: details-success
        class: success
      - name: details-question
        class: question
      - name: details-warning
        class: warning
      - name: details-failure
        class: failure
      - name: details-danger
        class: danger
      - name: details-bug
        class: bug
      - name: details-example
        class: example
      - name: details-quote
        class: quote
nidem commented 1 month ago

I swear I did that too. My bad. Sorry for you taking up your time. Much appreciated! Tip/sponsorship incoming.

facelessuser commented 1 month ago

No worries, YAML can be a little confusing. You aren't the first to fall into this trap :).

facelessuser commented 1 month ago

Oh and thanks for the tip!