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

How to allow basic html formatting? #1037

Closed
Liero opened this issue Jan 26, 2018 · 2 comments
Closed

How to allow basic html formatting? #1037

Liero opened this issue Jan 26, 2018 · 2 comments

Comments

@Liero
Copy link

Liero commented Jan 26, 2018

Expectation

I would like to allow some basic html formatting tags just like on github or stackoverflow. The rest should be encoded. Is there any way to allow only specific html tags, like <b>, <i> etc...?

Expected Result

E.g.:
<b>sample</b>: sample
<script>alert('a')</script>: <script>alert('a')</script>

What was attempted

Bu default no html tags are encoded, so the script code snipped actually shows alert. When I turn html tags off, the no html formatting is applied.

@Simon-Tang
Copy link

I think the way to do this may be to override the renderer (https://github.com/chjj/marked#renderer) to have your custom handling of HTML elements (see the html method). It looks like html is invoked for tags like <script> but not for tags like <b>.

@UziTech
Copy link
Member

UziTech commented Dec 5, 2018

Yes, the way to do this would be to override the renderer.html function

@UziTech UziTech closed this as completed Dec 5, 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

4 participants