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

Is there a way to white-list specific HTML tags when sanitize is true? #133

Closed
chevcast opened this issue Mar 7, 2013 · 18 comments
Closed

Comments

@chevcast
Copy link

chevcast commented Mar 7, 2013

I love the sanitize feature and most markdown libraries don't include it or do it very badly. However, there is one feature that Marked does not have that my previous library did, the ability to white-list specific tags or a default set of tags (see node-markdown). Is it possible to have this added to Marked?

This library is the best javascript markdown library I've seen. The main attraction for me is the ability to use it on the server and on the client so I can generate Markdown previews for the user without making ajax calls or having differences between the client library and the server library. If I can just enable specific tags when sanitize is true that would complete the library for me.

@chjj
Copy link
Member

chjj commented Mar 30, 2013

This should actually be fairly simple. I'll mess around with something.

@matthewmueller
Copy link

+1

@martindale
Copy link

+1. This would be fantastic.

@passsy
Copy link

passsy commented Jul 24, 2013

+1 push

@jonathanong
Copy link

+1

1 similar comment
@AdrianoFerrari
Copy link

+1

@chevcast
Copy link
Author

chevcast commented Oct 3, 2013

Seeing as how this isn't in there quite yet I'll try and take a stab at doing it myself sometime this week for you guys. I don't know the code yet so be patient. Hopefully I can figure out how to white-list specific tags and make this the most complete JS markdown library out there :D. I'll link to the fork here when I'm finished.

@Soleone
Copy link

Soleone commented Nov 25, 2013

yes please, 👍 for whitelist of tags i want to enable markdown for and others (e.g. images using ![text](link) I don't want to support)

@adius
Copy link

adius commented Jul 21, 2014

Why exactly was this issue closed? Seems still to be relevant to me!

@chevcast
Copy link
Author

Wondered that myself. sad face

@chevcast
Copy link
Author

Well it's not closed, but it was supposedly simple to implement.

@adius
Copy link

adius commented Jul 21, 2014

Oh right, the referenced issue is closed. Got it =P.
Well, then I'll just give a +1 cause I'd still like to see this feature implemented! =)

@gkoberger
Copy link

Another +1 on this.

@markstos
Copy link

+1

@j127
Copy link

j127 commented Jul 25, 2017

This feature would be very useful.

@markstos
Copy link

A workaround is to not use the sanitize feature of Markdown, but instead pass the resulting HTML through a tool that focuses just on HTML sanitizing, like the insane module. It works out being about the same amount of code and configuration, and yes the insane module supports custom whitelists both tags and attributes.

The Markdown spec does not include any notion of HTML sanitizing. Sanitizing is a separate task that is well served by using a separate module.

@j127
Copy link

j127 commented Jul 25, 2017

@markstos - thanks

@styfle
Copy link
Member

styfle commented Aug 20, 2018

I think @markstos is correct, using a 3rd party sanitizer is the solution here instead of adding a new feature.

I'm closing this in favor of #1232 which is a discussion about external sanitizers and deprecation of the internal sanitizer.

@styfle styfle closed this as completed Aug 20, 2018
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