Skip to content

extensions in 'extra' ignore their configs if only 'extra' is requested #1019

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

Closed
afontenot opened this issue Sep 9, 2020 · 1 comment · Fixed by #1023
Closed

extensions in 'extra' ignore their configs if only 'extra' is requested #1019

afontenot opened this issue Sep 9, 2020 · 1 comment · Fixed by #1023
Labels
docs Related to the project documentation. extension Related to one or more of the included extensions.

Comments

@afontenot
Copy link

I want all the extensions in extra, so instead of requesting all of them individually I just do something like

html = markdown.markdown(text, extensions=['extra'])

But I need to specify some options (for the 'footnotes' extension), so I include those in the options dict. These options get ignored when just specifying 'extra', I have to explicitly add 'footnotes' to the extensions list for them to be used.

A simple test case:

from markdown import Markdown

text1 = "[^1]\n\n[^1]: test1"
text2 = "[^1]\n\n[^1]: test2"

opts = {'footnotes': {'UNIQUE_IDS': True}}
md = Markdown(extensions=['extra'], extension_configs=opts)

print(md.convert(text1))
md.reset()
print(md.convert(text2))

python-markdown will re-use the footnote numbering, even though I set UNIQUE_IDS.

@waylan waylan added docs Related to the project documentation. extension Related to one or more of the included extensions. labels Sep 9, 2020
@waylan
Copy link
Member

waylan commented Sep 9, 2020

I thought this was documented but I'm not finding it. The extra extension is just a wrapper which enables each of the individual extensions. However, extra only has access to config options for the extra key. Therefore, for extra to have access to the configs to pass them on to the individual extensions, you need to nest the individual extensions within the extra config. Like this:

opts = {'extra': {'footnotes': {'UNIQUE_IDS': True}}}
md = Markdown(extensions=['extra'], extension_configs=opts)

We need to add this to the documentation. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Related to the project documentation. extension Related to one or more of the included extensions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants