Skip to content

Commit bf6adff

Browse files
authored
Merge pull request #91 from JuanitoFatas/doc/scrubbers
Improve Scrubber documentations
2 parents c5912e7 + b3c4f7d commit bf6adff

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/rails/html/scrubbers.rb

+18-18
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module Rails
22
module Html
33
# === Rails::Html::PermitScrubber
44
#
5-
# Rails::Html::PermitScrubber allows you to permit only your own tags and/or attributes.
5+
# +Rails::Html::PermitScrubber+ allows you to permit only your own tags and/or attributes.
66
#
7-
# Rails::Html::PermitScrubber can be subclassed to determine:
7+
# +Rails::Html::PermitScrubber+ can be subclassed to determine:
88
# - When a node should be skipped via +skip_node?+.
99
# - When a node is allowed via +allowed_node?+.
1010
# - When an attribute should be scrubbed via +scrub_attribute?+.
@@ -27,22 +27,22 @@ module Html
2727
# If set, attributes excluded will be removed.
2828
# If not, attributes are removed based on Loofahs +HTML5::Scrub.scrub_attributes+.
2929
#
30-
# class CommentScrubber < Html::PermitScrubber
31-
# def initialize
32-
# super
33-
# self.tags = %w(form script comment blockquote)
34-
# end
30+
# class CommentScrubber < Html::PermitScrubber
31+
# def initialize
32+
# super
33+
# self.tags = %w(form script comment blockquote)
34+
# end
3535
#
36-
# def skip_node?(node)
37-
# node.text?
38-
# end
36+
# def skip_node?(node)
37+
# node.text?
38+
# end
3939
#
40-
# def scrub_attribute?(name)
41-
# name == "style"
42-
# end
43-
# end
40+
# def scrub_attribute?(name)
41+
# name == "style"
42+
# end
43+
# end
4444
#
45-
# See the documentation for Nokogiri::XML::Node to understand what's possible
45+
# See the documentation for +Nokogiri::XML::Node+ to understand what's possible
4646
# with nodes: https://nokogiri.org/rdoc/Nokogiri/XML/Node.html
4747
class PermitScrubber < Loofah::Scrubber
4848
attr_reader :tags, :attributes
@@ -160,8 +160,8 @@ def scrub_attribute(node, attr_node)
160160

161161
# === Rails::Html::TargetScrubber
162162
#
163-
# Where Rails::Html::PermitScrubber picks out tags and attributes to permit in
164-
# sanitization, Rails::Html::TargetScrubber targets them for removal.
163+
# Where +Rails::Html::PermitScrubber+ picks out tags and attributes to permit in
164+
# sanitization, +Rails::Html::TargetScrubber+ targets them for removal.
165165
#
166166
# +tags=+
167167
# If set, elements included will be stripped.
@@ -180,7 +180,7 @@ def scrub_attribute?(name)
180180

181181
# === Rails::Html::TextOnlyScrubber
182182
#
183-
# Rails::Html::TextOnlyScrubber allows you to permit text nodes.
183+
# +Rails::Html::TextOnlyScrubber+ allows you to permit text nodes.
184184
#
185185
# Unallowed elements will be stripped, i.e. element is removed but its subtree kept.
186186
class TextOnlyScrubber < Loofah::Scrubber

0 commit comments

Comments
 (0)