Skip to content

Commit

Permalink
version bump to v2.24.0
Browse files Browse the repository at this point in the history
plus some documentation additions
  • Loading branch information
flavorjones committed Jan 1, 2025
1 parent 2abdafc commit 8599060
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2.24.0 / 2024-12-24

### Added

* Built-in scrubber `:double_breakpoint` which sees `<br><br>` and wraps the surrounding content in `<p>` tags. #279, #284 @josecolella @torihuang

### Improved

* Built-in scrubber `:targetblank` now skips `a` tags whose `href` attribute is an anchor link. Previously, all `a` tags were modified to have `target='_blank'`. #291 @fnando


## 2.23.1 / 2024-10-25

### Added
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Active Record extensions for HTML sanitization are available in the [`loofah-act
* Add the _nofollow_ attribute to all hyperlinks.
* Add the _target=\_blank_ attribute to all hyperlinks.
* Remove _unprintable_ characters from text nodes.
* Modify _double breakpoints_ characters to paragraph nodes.
* Some specialized HTML transformations are also built-in:
* Where `<br><br>` exists inside a `p` tag, close the `p` and open a new one.
* Format markup as plain text, with (or without) sensible whitespace handling around block elements.
* Replace Rails's `strip_tags` and `sanitize` view helper methods.

Expand Down Expand Up @@ -228,15 +229,15 @@ doc.scrub!(:whitewash) # removes unknown/unsafe/namespaced tags and their chi
# and strips all node attributes
```

Loofah also comes with some common transformation tasks:
Loofah also comes with built-in scrubers for some common transformation tasks:

``` ruby
doc.scrub!(:nofollow) # adds rel="nofollow" attribute to links
doc.scrub!(:noopener) # adds rel="noopener" attribute to links
doc.scrub!(:noreferrer) # adds rel="noreferrer" attribute to links
doc.scrub!(:unprintable) # removes unprintable characters from text nodes
doc.scrub!(:targetblank) # adds target="_blank" attribute to links
doc.scrub!(:double_breakpoint) # removes double breakpoints to paragraph nodes
doc.scrub!(:nofollow) # adds rel="nofollow" attribute to links
doc.scrub!(:noopener) # adds rel="noopener" attribute to links
doc.scrub!(:noreferrer) # adds rel="noreferrer" attribute to links
doc.scrub!(:unprintable) # removes unprintable characters from text nodes
doc.scrub!(:targetblank) # adds target="_blank" attribute to links
doc.scrub!(:double_breakpoint) # where `<br><br>` appears in a `p` tag, close the `p` and open a new one
```

See `Loofah::Scrubbers` for more details and example usage.
Expand Down
4 changes: 2 additions & 2 deletions lib/loofah/scrubbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ def scrub(node)
#
# +:double_breakpoint+ replaces double-break tags with closing/opening paragraph tags.
#
# double_breakpoint_markup = "<p>Some text here in a logical paragraph.<br><br>Some more text, apparently a second paragraph.</p>"
# Loofah.html5_fragment(messy_markup).scrub!(:double_breakpoint)
# markup = "<p>Some text here in a logical paragraph.<br><br>Some more text, apparently a second paragraph.</p>"
# Loofah.html5_fragment(markup).scrub!(:double_breakpoint)
# => "<p>Some text here in a logical paragraph.</p><p>Some more text, apparently a second paragraph.</p>"
#
class DoubleBreakpoint < Scrubber
Expand Down
2 changes: 1 addition & 1 deletion lib/loofah/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

module Loofah
# The version of Loofah you are using
VERSION = "2.23.1"
VERSION = "2.24.0"
end

0 comments on commit 8599060

Please sign in to comment.