Skip to content

Commit

Permalink
changes to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gkumar9891 committed Feb 5, 2024
1 parent b268d15 commit 31def35
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions CHANGELOG.md
Expand Up @@ -2,12 +2,10 @@

## UNRELEASED

- Clarified the use of SVGs with a new test and changes to documentation.

## UNRELEASED

- Introduced the `allowedEmptyAttributes` option, enabling explicit specification of empty string values for select attributes, with the default attribute set to `alt`.

- Clarified the use of SVGs with a new test and changes to documentation.

## 2.11.0 (2023-06-21)

- Fix to allow `false` in `allowedClasses` attributes. Thanks to [Kevin Jiang](https://github.com/KevinSJ) for this fix!
Expand Down
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -265,9 +265,11 @@ allowedAttributes: {

With `multiple: true`, several allowed values may appear in the same attribute, separated by spaces. Otherwise the attribute must exactly match one and only one of the allowed values.

#### "What if I want to prevent attributes and tags from being truly lowercase?"
#### "What if I want to maintain the original case for SVG elements and attributes?"

if you got any tag like `linearGradient` and you want to prevent that tag from being lowercased so you have to pass `lowerCaseTags: false` in `parser` option and same for if you want to prevent any attribute like `viewBox` in svg tag from being lowercased so you have to pass `lowerCaseAttributeNames: false` in parser option.
If you're incorporating SVG elements like `linearGradient` into your content and notice that they're not rendering as expected due to case sensitivity issues, it's essential to prevent `sanitize-html` from converting element and attribute names to lowercase. This situation often arises when SVGs fail to display correctly because their case-sensitive tags, such as `linearGradient` and attributes like `viewBox`, are inadvertently lowercased.

To address this, ensure you set `lowerCaseTags: false` and `lowerCaseAttributeNames: false` in the parser options of your sanitize-html configuration. This adjustment stops the library from altering the case of your tags and attributes, preserving the integrity of your SVG content.

```js
allowedTags: [ 'svg', 'g', 'defs', 'linearGradient', 'stop', 'circle' ],
Expand Down

0 comments on commit 31def35

Please sign in to comment.