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

Not working with python-markdown 3 and above #4

Open
Galarzaa90 opened this issue Sep 24, 2018 · 8 comments
Open

Not working with python-markdown 3 and above #4

Galarzaa90 opened this issue Sep 24, 2018 · 8 comments

Comments

@Galarzaa90
Copy link
Contributor

This does not seem to be working anymore, at least not on mkdocs, I don't have another way to test.

ERROR   -  Config value: 'markdown_extensions'. Error: Failed loading extension "figureAltCaption".

I forked it and checked it, and noticed that there were some imports that weren't valid anymore and removed them, but even then, it kept failing, but now with a different error.

This are the changes I made

ERROR   -  Config value: 'markdown_extensions'. Error: configs

I have no experience with markdown extensions, so I really don't know how to test.

@jdittrich
Copy link
Owner

Thanks for reporting the issue. I tried with the command line version of python markdown and it seems to work well for me: cat somemarkdown.md | python3 -m markdown -x figureAltCaption

My version is 2.6.9 which is what is shown when I execute python3 -m markdown --version

Or do you use the very recent 3.0 version of the markdown extensions? (I have not tried with that one yet)

@Galarzaa90
Copy link
Contributor Author

I think that's definitely the problem, they introduced many breaking changes in 3.0 :(

I tried manually downgraded to Markdown 2.6.*, but then it breaks the requirements because of pymdown-extensions 5.0`.
I'm pretty sure doing those downgrades will make it work again, I will test later.

Have you considered adding this to pypi? It would be a great addition there. It would require implementing a versioning system tho.

@jdittrich
Copy link
Owner

I think that's definitely the problem, they introduced many breaking changes in 3.0

OK, that seems probable. I will set up an environment and test with 3.0.

Have you considered adding this to pypi?
Good idea. I created #5 (Add to pypi)

@ronligt
Copy link
Contributor

ronligt commented Dec 8, 2018

How can I help? We really need this functionality!

After testing with markdown 3.0.1 in python 3.7.1 I get the following Traceback:

>>> import figureAltCaption
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "miniconda3/envs/mkdocs-new/lib/python3.7/site-packages/figureAltCaption.py", line 33, in <module>
    from markdown.inlinepatterns import IMAGE_LINK_RE, IMAGE_REFERENCE_RE, NOBRACKET, BRK
ImportError: cannot import name 'NOBRACKET' from 'markdown.inlinepatterns' (miniconda3/envs/mkdocs-new/lib/python3.7/site-packages/markdown/inlinepatterns.py)
>>> 

Seems that at least NOBRACKET is gone from inlinepatterns. From the code in figureAltCaption I gather that this is actually not used (also BRK is not used). Could we just remove that from the import-line?

@jdittrich jdittrich changed the title Not working on recent versions Not working with python-markdown 3 and above Dec 8, 2018
@ronligt
Copy link
Contributor

ronligt commented Dec 8, 2018

I think it works fine with the mods (also changed the makeExtension-part)!

Newbie-mode: how can I submit the changes with a pull request?

@jdittrich
Copy link
Owner

I think this is the documentation page which explains pull requesting. It assumes that you have forked the repo.

@jdumas
Copy link

jdumas commented Jun 2, 2019

Hi. I wanted to let you know that I've updated this plugin to work with Python Markdown 3, using Inline Patterns instead of Block Processors. See the code here. I have only implemented the support for image links, not image references (which I why I don't directly create a PR), but this should make it easier to adapt for the latter I hope.

@fw2048
Copy link

fw2048 commented Mar 29, 2020

We processed hundreds of article with the extension on Python 3.6 and it was running perfectly. Only recently we move our code (with an old version of the extension) onto Python 3.8 and that fails on this traceback - ImportError: cannot import name 'NOBRACKET' from 'markdown.inlinepatterns'. Since then we updated on your latest commit 2c867c0 and it seems to work fine. Appreciated thanks your efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants