@@ -130,12 +130,26 @@ def truncate(text, options = {}, &block)
130
130
end
131
131
end
132
132
133
- # Highlights one or more +phrases+ everywhere in +text+ by inserting it into
134
- # a <tt>:highlighter</tt> string. The highlighter can be specialized by passing <tt>:highlighter</tt>
135
- # as a single-quoted string with <tt>\1</tt> where the phrase is to be inserted (defaults to
136
- # <tt>"<mark>\1</mark>"</tt>) or passing a block that receives each matched term. By default +text+
137
- # is sanitized to prevent possible XSS attacks. If the input is trustworthy, passing false
138
- # for <tt>:sanitize</tt> will turn sanitizing off.
133
+ # Highlights occurrences of +phrases+ in +text+ by formatting them with a
134
+ # highlighter string. +phrases+ can be one or more strings or regular
135
+ # expressions. The result will be marked HTML safe. By default, +text+ is
136
+ # sanitized before highlighting to prevent possible XSS attacks.
137
+ #
138
+ # If a block is specified, it will be used instead of the highlighter
139
+ # string. Each occurrence of a phrase will be passed to the block, and its
140
+ # return value will be inserted into the final result.
141
+ #
142
+ # ==== Options
143
+ #
144
+ # [+:highlighter+]
145
+ # The highlighter string. Uses <tt>\1</tt> as the placeholder for a
146
+ # phrase, similar to +String#sub+. Defaults to <tt>"<mark>\1</mark>"</tt>.
147
+ # This option is ignored if a block is specified.
148
+ #
149
+ # [+:sanitize+]
150
+ # Whether to sanitize +text+ before highlighting. Defaults to true.
151
+ #
152
+ # ==== Examples
139
153
#
140
154
# highlight('You searched for: rails', 'rails')
141
155
# # => "You searched for: <mark>rails</mark>"
0 commit comments