Method: Websitary::Configuration#highlighter
- Defined in:
- lib/websitary/configuration.rb
#highlighter(rx, color = nil, group = nil, tag = 'span') ⇒ Object
Return a Proc that takes an text as argument and highlight occurences of rx.
- rx
-
Regular expression
- color
-
A string, sets the class to highlight-color (default: “yellow”)
- group
-
A number (default: 0)
- tag
-
The HTML tag to use (default: “span”)
919 920 921 |
# File 'lib/websitary/configuration.rb', line 919 def highlighter(rx, color=nil, group=nil, tag='span') lambda {|text| text.gsub(rx, %{<#{tag} class="highlight-#{color || 'red'}">\\#{group || 0}</#{tag}>})} end |