-
Notifications
You must be signed in to change notification settings - Fork 62
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
Styles not working #2
Comments
@erikcw Did you ever get this worked out? |
@ajt No, never did get it working... |
Don't import the default style before setting the custom styles. This causes the settings to be loaded before they are defined and you end up with only the default style. Put this (with no imports from markdown_deux) into your settings.py and it should work: MARKDOWN_DEUX_STYLES = {
"default": {
"extras": {
"code-friendly": None,
},
"safe_mode": "escape",
},
"trusted": {
"extras": {
"code-friendly": None,
},
"safe_mode": False,
}
} |
Hi all. Sorry on the non-response here. I haven't been working on a Django site for a while so I'm a little clueless on Django settings import mechanics. I'd welcome a cleaner way to have this module pick up on It looks like the README.md might be showing usage that will cause this problem:
@mitchelljkotler Does that look like the README is wrong here. |
The README is wrong. The problem is that when you import MARKDOWN_DEUX_DEFAULT_STYLE, markdown_deux's settings.py is run, and since the user's MARKDOWN_DEUX_STYLES isn't defined yet, markdown duex's MARKDOWN_DEUX_STYLES is set to the default. If you do not imoprt MARKDOWN_DEUX_DEFAULT_STYLE and just hard code it, as in my example, all works fine. By the time markdown deux's settings.py is imported, the user's MARKDOWN_DEUX_STYLES is defined and markdown deux's MARKDOWN_DEUX_STYLES picks it up correctly. I can't think of a good way to allow this to work how you have it now. I think a decent compromise might be to always add the default style to the user's MARKDOWN_DEUX_STYLES. So if the user wants to add a trusted style, they can do: MARKDOWN_DEUX_STYLES = {
"trusted": {
"extras": {
"code-friendly": None,
},
"safe_mode": False,
}
} And in markdown_deux.conf.settings.py: MARKDOWN_DEUX_STYLES = getattr(settings, "MARKDOWN_DEUX_STYLES", {})
MARKDOWN_DEUX_STYLES.update({'default': MARKDOWN_DEUX_DEFAULT_STYLE}) This way, the default style is always accessible without the user having to put it in. Just one idea though. |
Sorry to revive such an old thread here, but another potential solution would be to define Then in the README you would instruct the user to import |
First off, thanks to the contributors for this nice project. Having said that, in its innocence, this issue is a very serious one. I am sure many people have wasted time trying to debug both their and this code before they found out that this is a mere bad documentation issue existing for 5 years already. I will create a merge request to apply the correct recommendation by @mitchelljkotler . |
I'm trying to use styles with the markdown templatetag. I've setup settings.MARKDOWN_DEUX_STYLES to match the 3 styles in the README -- but regardless of which I call (trusted or recipe), the "default" style always gets used.
It looks like the get_style function is only looking at the default settings, and not the updated settings.
The text was updated successfully, but these errors were encountered: