Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with pymdownx.superfences #19

Closed
ErliSoares opened this issue Aug 31, 2021 · 12 comments
Closed

Does not work with pymdownx.superfences #19

ErliSoares opened this issue Aug 31, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@ErliSoares
Copy link

First of all thank you very much for the plugin, very useful.

Is there any possibility to tweak it to work with pymdownx.superfences? pymdownx.superfences for me is very important, thank you very much.

I found an issue, but it seems they didn't come up with a solution #17.

@neatc0der
Copy link
Member

neatc0der commented Sep 1, 2021

tl;dr: I'll need a (minimalistic) sample environment from you that reproduces the error reliably.


When an issue is raised twice, that's not a great sign for quality of the project. So, I tried to be thorough and set up a sample environment with some gimmickry to force the error. But, I was unsuccessful. The page looks just fine after doing this:

$ pip install pymdown-extensions==8.1.1

mkdocs.yml

site_name: Test
nav:
  - Home: index.md
  - ...
plugins:
  - markmap:
      base_path: mindmaps
extensions:
  - pymdownx.arithmatex
  - pymdownx.betterem(smart_enable=all)
  - pymdownx.caret
  - pymdownx.critic
  - pymdownx.details
  - pymdownx.emoji:
      emoji_generator: !!python/name:pymdownx.emoji.to_svg
  - pymdownx.highlight(use_pygments=false)
  - pymdownx.inlinehilite
  - pymdownx.magiclink
  - pymdownx.mark
  - pymdownx.smartsymbols
  - pymdownx.superfences
  - pymdownx.tasklist(custom_checkbox=true)
  - pymdownx.tilde
extra_javascript:
  - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-MML-AM_CHTML'

docs/index.md

# Home

```markmap
# Root

## Branch 1

## Branch 2
```

```{.py3 hl_lines="1 3" linenums="2"}
"""Some file."""
import foo.bar
import boo.baz
import foo.bar.baz
```

$$
\frac{n!}{k!(n-k)!} = \binom{n}{k}
$$

{!mindmap.mm.md!}
$ mkdocs build
WARNING -  Config value: 'extensions'. Warning: Unrecognised configuration name: extensions 
INFO    -  Cleaning site directory 
INFO    -  Building documentation to directory: /Users/tobi/Projects/mkdocs-markmap/test/site 
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
  - subdir/index.md 
WARNING -  A relative path to '...' is included in the 'nav' configuration, which is not found in the documentation files 
WARNING -  A relative path to '../' is included in the 'nav' configuration, which is not found in the documentation files 
INFO    -  script downloaded: https://unpkg.com/[email protected]/dist/d3.min.js 
INFO    -  script downloaded: https://unpkg.com/[email protected]/dist/browser/index.min.js 
INFO    -  script downloaded: https://unpkg.com/[email protected]/dist/index.min.js 
INFO    -  Documentation built in 0.85 seconds 

@ErliSoares
Copy link
Author

Example

$ pip install mkdocs-material
$ pip install pymdown-extensions==8.1.1

Clone the repository: https://github.com/ErliSoares/mkdocs-markmap-error

When comments the line works: https://github.com/ErliSoares/mkdocs-markmap-error/blob/9ab445aa2a2c9e1b25022cd18ac83f506107c323/mkdocs.yml#L11

image

With it uncommented the result is the image below
image

@ErliSoares
Copy link
Author

WARNING - Config value: 'extensions'. Warning: Unrecognised configuration name: extensions

In your example change extensions by markdown_extensions

@neatc0der
Copy link
Member

Thanks for the remark to my incorrect configuration as well as your error repo. I'm sorry, but there's no error for me. So, let's dive deeper. Please provide the output to these commands:

  • python --version
  • pip freeze

@ErliSoares
Copy link
Author

Thanks for looking at the possible problem, I reinstalled and another machine from scratch.

python --version
Python 3.9.7

pip freeze
attrs==20.3.0
Babel==2.9.1
beautifulsoup4==4.10.0
bracex==2.1.1
Brotli==1.0.9
cairocffi==1.2.0
CairoSVG==2.5.2
certifi==2021.5.30
cffi==1.14.6
charset-normalizer==2.0.4
click==8.0.1
colorama==0.4.4
cssselect2==0.4.1
cssutils==2.3.0
defusedxml==0.7.1
fonttools==4.26.2
ghp-import==2.0.1
gitdb==4.0.7
GitPython==3.1.18
html5lib==1.1
htmlmin==0.1.12
idna==3.2
importlib-metadata==4.8.1
Jinja2==3.0.1
jsmin==2.2.2
libsass==0.21.0
Markdown==3.3.4
markdown-captions==2
MarkupSafe==2.0.1
mergedeep==1.3.4
mkdocs==1.2.2
mkdocs-awesome-pages-plugin==2.5.0
mkdocs-drawio-exporter==0.8.0
mkdocs-git-authors-plugin==0.6
mkdocs-git-revision-date-localized-plugin==0.10.0
mkdocs-markmap==2.1.0
mkdocs-material==7.2.6
mkdocs-material-extensions==1.0.3
mkdocs-minify-plugin==0.4.0
mkdocs-section-index==0.3.1
mkdocs-with-pdf==0.9.3
packaging==21.0
Pillow==8.3.2
pycparser==2.20
pydyf==0.1.1
Pygments==2.10.0
pymdown-extensions==8.2
pyparsing==2.4.7
pyphen==0.11.0
python-dateutil==2.8.2
pytz==2021.1
PyYAML==5.4.1
pyyaml_env_tag==0.1
requests==2.26.0
six==1.16.0
smmap==4.0.0
soupsieve==2.2.1
tinycss2==1.1.0
urllib3==1.26.4
watchdog==2.1.5
wcmatch==8.2
weasyprint==53.3
webencodings==0.5.1
zipp==3.5.0
zopfli==0.1.8

mkdocs --version
mkdocs, version 1.2.2 from C:\Users\erli\AppData\Local\Programs\Python\Python39\lib\site-packages\mkdocs (Python 3.9)

@neatc0der
Copy link
Member

neatc0der commented Sep 13, 2021

Ok, so I ran this on my system (macOS 11.5.2):

git clone [email protected]:ErliSoares/mkdocs-markmap-error.git
cd mkdocs-markmap-error
conda create --name markmap-error python=3.9.6
conda activate markmap-error
vim requirements.txt   # I copied your pip freeze output
pip install -r requirements.txt
mkdocs build

There were no errors and the result looks just fine. Conda does not yet provide python 3.9.7, though. Any thoughts?

@sunilkum84
Copy link

sunilkum84 commented Sep 14, 2021

I too had similar issues at least with the latest mkdocs-material mkdocs-material-7.2.6 I am trying to share this experience thinking that it may help to reproduce the issue.
Please ignore if you find this irrelevant.
I had to disable pymdownx.superfences in order to use the mkdcos-markmap.
I then tried to downgrade the mkdocs-material theme to the release mkdocs-material-7.1.4 and the same setup worked for me

@ErliSoares
Copy link
Author

Sorry if I'm talking nonsense, I have no knowledge of python and markdown plugin.

From what I've managed to interplete from the code below, mkdocs-markmap fetches the code element with the language-markmap class in on_post_page, but it looks like pymdownx.superfences drops the class when enabled.

https://github.com/neatc0der/mkdocs-markmap/blob/229b4c522e79f1459953794576dbf45aefa19820/mkdocs_markmap/plugin.py#L94-L100

Without pymdownx.superfences

image

With pymdownx.superfences

image

@neatc0der
Copy link
Member

Thanks for pointing this out to me. In fact, my previous comment was premature. The issue is reproducible for me, my bad.

I'll look into this and get back to you.

@neatc0der neatc0der added the bug Something isn't working label Sep 17, 2021
@neatc0der
Copy link
Member

neatc0der commented Sep 17, 2021

Ok, so for once I'll acknowledge this as a bug, but from my perspective this is a mess produced by pymdownx.superfences:

  1. superfences swallows a class this project relies on: language-markmap. This can be avoided by defining a "custom fence".
  2. The class language-markmap then is not altered by superfences. Unfortunately, it is moved from <code>to <pre> (structure: <pre><code>...</code></pre>), though. Of course, this project was yet unable to support this.

What I did was to support the altered structure in step 2. Also, step 1 is automated in the code. Thus, users will not be required to add custom_fences configuration manually.

Please review #23 and accept if reliable. It works on my machine 😉

@ErliSoares
Copy link
Author

You are amazing, it worked perfectly, a great solution, thank you very much.

@neatc0der
Copy link
Member

v2.1.2 released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants