-
Notifications
You must be signed in to change notification settings - Fork 355
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
Comments
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. |
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 [email protected]
*THOMAS BOUTELL, *DEV & OPS |
Until this gets implemented, a messy hack would be: text = text.replace(/>/g, '> ');
text = sanitizeHtml(text, {allowedTags:[]}); |
up!! Is this still on? |
@r-custodio As mentioned, I'd take a PR for this. Unfortunately as maintainer I can't necessarily implement every feature. |
@abea this is labeled as |
@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. |
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. |
it's 2023 now. thank you for your solution =) |
@rusakovic Contributions are welcome! |
it's 2024 now. :) |
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. |
Reopening for potential community PRs. |
Is anyone aware of a reliable way to get a list of block-tags? If so, this shouldn't be terribly difficult to implement, right? I'm not sure. |
Somewhat dubious source, but chatGPT says
These tags are generally used to structure the main content of an HTML document. |
It might be easier to exclude inline elements. There are fewer(?) and they're generally easier to identify. The list of phrasing content elements minus inputs, media, |
This is what I got from ChatGPT: Here is a comprehensive list of block-level HTML tags/elements available in the latest implementation(s) of HTML, including both standard and experimental/non-standard elements: Standard Block-Level Elements
Deprecated Block-Level Elements
Non-Standard/Experimental Block-Level Elements
These elements are considered block-level because they typically start on a new line and take up the full width available (unless otherwise styled with CSS). For the most up-to-date list, always refer to the latest HTML specification and browser documentation, as new elements and updates can be introduced. Here is a comprehensive list of inline HTML tags/elements available in the latest implementation(s) of HTML, including both standard and experimental/non-standard elements: Standard Inline Elements
Deprecated Inline Elements
Non-Standard/Experimental Inline Elements
These elements are considered inline because they do not start on a new line and only take up as much width as necessary. For the most accurate and up-to-date list, always refer to the latest HTML specification and browser documentation. In HTML, custom or undefined tags are treated as inline elements by default. This means that if you define a custom tag that is not recognized by the HTML specification, it will behave like an inline element unless you explicitly style it using CSS. For example, if you create a custom tag <my-custom-element>This is a custom element.</my-custom-element> To change its behavior to a block-level element, you need to use CSS: my-custom-element {
display: block;
} This CSS rule will make the custom element behave as a block-level element: <my-custom-element>This is a custom element.</my-custom-element> With the CSS applied, |
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 runtext = sanitizeHtml(text, {allowedTags:[], allowedAttribute: {}});
Is there an option to add whitespace so the output is better:
Some sentence. Some other Sentence
The text was updated successfully, but these errors were encountered: