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

Can I add a class to a table? #28

Closed
n2o opened this issue Jan 25, 2021 · 4 comments
Closed

Can I add a class to a table? #28

n2o opened this issue Jan 25, 2021 · 4 comments

Comments

@n2o
Copy link

n2o commented Jan 25, 2021

Heyho, is it possible to add a CSS class to a table or something?

I can configure as allowed attributes the following settings:

MARKDOWNIFY_WHITELIST_ATTRS = [
    'href',
    'src',
    'alt',
    'class',
]

In my case, I want to add table table-hover table-striped classes to a table, but I do not know how to do this. And I can only find it in the python code examples, but not from within the markdown itself. Is it possible to add classes?

Your documentation points to this page: https://bleach.readthedocs.io/en/latest/clean.html#allowed-attributes-attributes
But they are using the attrs on the html code itself, not on markdown representations.

Thanks for your help :)

@erwinmatijsen
Copy link
Owner

I think the attribute list extension will do what you want. It is included in the extra extension. Can you give it a shot and let me know how it worked out?

@n2o
Copy link
Author

n2o commented Jan 25, 2021

Hm, jep I came up with this page, but it doesn't work, because the devs of python markdown don't want it.

Python-Markdown/markdown#312

@erwinmatijsen
Copy link
Owner

I see. Well, django-markdownify is a small wrapper around python-markdown and bleach. So if the underlying libs don't have support for it, django-markdownify won't support it either.

Maybe there are some extenstions to python-markdown with better table support? Otherwise there's always the option to just write the html in your Markdown-file.

@n2o
Copy link
Author

n2o commented Jan 25, 2021

Hm, in the issue there are several people talking about alternatives, but they oftentimes don't fulfill the necessary requirements. I will check some of them.

The Editing-Feature is for non-technical people, and I do not think that they are able to write HTML tables without a real editor. I tested it with a small table, but this is not a valuable solution. For me this will be no problem, but there are some more people writing posts on the page.

Thanks for your help. I will keep an eye on the other extensions and leave you a comment, if there is a working solution 👍

@n2o n2o closed this as completed Jan 25, 2021
@n2o n2o changed the title Can I add a class to, e.g., a table? Can I add a class to a table? Jan 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants