pawamoy / markdown-exec

Utilities to execute code blocks in Markdown files.
https://pawamoy.github.io/markdown-exec
ISC License
111 stars 8 forks source link

bug: can not run the example #35

Closed elrandira closed 9 months ago

elrandira commented 9 months ago

Description of the bug

I can not manage to get the example working

image

To Reproduce

```python exec="on"
print("Hello Markdown!")

- add in mkdocs.yml

plugins:

Full traceback

INFO - Building documentation... INFO - Cleaning site directory INFO - Documentation built in 0.06 seconds INFO - [17:25:07] Watching paths for changes: 'docs', 'mkdocs.yml' INFO - [17:25:07] Serving on http://127.0.0.1:8000/ INFO - [17:25:07] Browser connected: http://127.0.0.1:8000/

Expected behavior

python code is interpreted and page show "hello world"

Environment information

(markdown) C:\workplace\test>pip list Package Version


click 8.1.7 colorama 0.4.6 ghp-import 2.1.0 importlib-metadata 7.0.1 Jinja2 3.1.3 Markdown 3.3.7 markdown-exec 1.7.0 MarkupSafe 2.1.4 mergedeep 1.3.4 mkdocs 1.3.1 packaging 23.2 pip 23.2.1 pymdown-extensions 10.4 python-dateutil 2.8.2 PyYAML 6.0.1 pyyaml_env_tag 0.1 setuptools 65.5.0 six 1.16.0 watchdog 3.0.0 zipp 3.17.0

(markdown) C:\workplace\test>python --version Python 3.11.6

I tried with latest of mkdocs & markdown-exec without better result

What am I doing wrong?

pawamoy commented 9 months ago

I think the docs are unclear, sorry: you have to enable the pymdownx.superfences Markdown extension too.

elrandira commented 9 months ago

thank you, I had to add the following in the mkdocs.yml and it worked.

markdown_extensions:
- pymdownx.superfences:
    custom_fences:
    - name: python
      class: python
      validator: !!python/name:markdown_exec.validator
      format: !!python/name:markdown_exec.formatter
pawamoy commented 9 months ago

You can just enable the extension without specific fences, the plugin will take care of adding them.

plugins:
- search
- markdown-exec

markdown_extensions:
- pymdownx.superfences