Closed marco-silva0000 closed 3 years ago
I've made this fork that supports this, see If its something worth working on and merging https://github.com/marco-silva0000/django-markdownify/commit/eb4904365aeb3ef8dd7fbcc43b2eb0d1d3bb4560
It's a big change, but I do believe it's something worth cleaning up(adding the other settings maybe) and documenting. This implementation also makes it so that the settings are not checked within every filtering, which is a small optimisation
Thanks, sounds like a good idea. I’m not at home right know, but will try to take a look this weekend.
'This weekend' came a bit late...
Anyhow, I took a look at your fork. I like the idea of per view settings, but I think your implementation was a bit too much focused on your use case (which is understandable).
I created a pull request with a different implementation, based on allowing the user to have multiple settings. For example, in your settings file you can have:
MARKDOWNIFY = {
'default': {
'WHITELIST_TAGS': ['a', 'p', ],
....
},
'restricted': {
'WHITELIST_TAGS': ['a', ]
}
}
And then in your template:
{% load markdownify %}
{{ markdowntext|markdownify:"restricted" }}
I want to write some extra tests, because only the 'old style' settings are being tested right now.
It will make some breaking changes, so I added a warning. Let me know what you think.
I might be living on a slow rotating mass that has it's revolution period really slowwwwwwwwwww.
That approach is better, I agree.
Hey,
I'm finding the need to specify different settings on different endpoints, basically I want do have the allowed tags set for the whole app but not on one specific view, where no tags are allowed.
I don't think this is possible with the current code, so I'll make a copy of the filter where I can specify the settings
Do you think this would be worth being added as a new enhancement?