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

Add a space where two tags met #49

Open
danschumann opened this issue Apr 2, 2015 · 13 comments
Open

Add a space where two tags met #49

danschumann opened this issue Apr 2, 2015 · 13 comments

Comments

@danschumann
Copy link

I'm wondering if there is a way to create a space wherever tags were.

Picture this:

<div>Some sentence.</div><div>Some other Sentence</div>

It converts to Some sentence.Some other Sentence when I run

text = sanitizeHtml(text, {allowedTags:[], allowedAttribute: {}});

Is there an option to add whitespace so the output is better: Some sentence. Some other Sentence

@dgrad
Copy link

dgrad commented Nov 27, 2015

I think to do this properly you'll need a list of block tags (or a list of inline tags). You want to add a space wherever a block tag ends (actually it should probably be a newline character and let the browser convert it to space), but not where an inline tag ends (e.g. <div>foo</div><div>bar</div> should convert to foo bar, but <span>foo</span><span>bar</span> should convert to foobar).

@boutell
Copy link
Member

boutell commented Dec 1, 2015

I agree, and there should be an option to override that list.

I'd take a pull request for this one.

On Fri, Nov 27, 2015 at 12:42 PM, Daniel Grad notifications@github.com
wrote:

I think to do this properly you'll need a list of block tags (or a list of
inline tags). You want to add a space wherever a block tag ends (actually
it should probably be a newline character and let the browser convert it to
space), but not where an inline tag ends (e.g.

foo
bar
should convert to foo bar, but foobar should convert to foobar).


Reply to this email directly or view it on GitHub
#49 (comment)
.

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

@SystemDisc
Copy link

Until this gets implemented, a messy hack would be:

text = text.replace(/>/g, '> ');
text = sanitizeHtml(text, {allowedTags:[]});

@rafacustodio
Copy link

up!!

Is this still on?

@boutell
Copy link
Member

boutell commented Nov 6, 2017

@r-custodio As mentioned, I'd take a PR for this. Unfortunately as maintainer I can't necessarily implement every feature.

@greghub
Copy link

greghub commented Nov 18, 2020

@abea this is labeled as seeking contributions but closed. Is it still something you'd accept a PR for?

@abea
Copy link
Contributor

abea commented Nov 18, 2020

@greghub Sure. It had been sitting idle for years, so there didn't seem much reason to keep it open. I'll reopen it if you want to work on it for 2.x and let the stalebot close it if nothing happens.

@abea abea reopened this Nov 18, 2020
@stale
Copy link

stale bot commented Jan 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 17, 2021
@stale stale bot closed this as completed Jan 31, 2021
@rusakovic
Copy link

Until this gets implemented, a messy hack would be:

text = text.replace(/>/g, '> ');
text = sanitizeHtml(text, {allowedTags:[]});

it's 2023 now. thank you for your solution =)

@boutell
Copy link
Member

boutell commented Sep 5, 2023

@rusakovic Contributions are welcome!

@adorum
Copy link

adorum commented Mar 26, 2024

it's 2024 now. :)

@boutell
Copy link
Member

boutell commented Mar 26, 2024

Yes, it's 2024 now, and as always, community contributions are welcome. 😄 This isn't a feature that matters for our use cases, although I appreciate it would be nice for developers reading the resulting markup.

@boutell
Copy link
Member

boutell commented Mar 26, 2024

Reopening for potential community PRs.

@boutell boutell reopened this Mar 26, 2024
@stale stale bot removed the stale label Mar 26, 2024
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

9 participants