Class: Filter::Markup
Constant Summary
Constants inherited from Filter
Instance Attribute Summary
Attributes inherited from Filter
Instance Method Summary collapse
-
#filter! ⇒ Object
Filter mini-markup language.
Methods inherited from Filter
Profanity, Profanity!, #filter, inherited, #initialize
Constructor Details
This class inherits a constructor from Filter
Instance Method Details
#filter! ⇒ Object
Filter mini-markup language.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/filters/markup.rb', line 8 def filter! string.gsub! /\*([^*]+)\*/, '<strong>\1</strong>' string.gsub! /\/([^*]+)\//, '<em>\1</em>' string.gsub! /_([^*]+)_/, '<sub>\1</sub>' string.gsub! /-([^*]+)-/, '<sup>\1</sup>' string.gsub! /['"](.*?)['"]:([\w\-\.]+@\S+)/, '<a href="mailto:\2">\1</a>' string.gsub! /['"](.*?)['"]:(\S+)/, '<a href="\2">\1</a>' string.gsub! /@@@\s*\n(.*?)@@@/m, "<pre>\n\\1</pre>" string.gsub! /@@@\s*(\w+)(.*?)@@@/m, '<code class="\1">\2</code>' string.gsub! /h(\d)\.\s*([^\n]+)/, '<h\1>\2</h\1>' string.gsub! /^\s*(={1,5})\s*([^\n]+)/ do |heading| , *contents = heading.split "<h#{bar.length}>#{contents.join(' ')}</h#{bar.length}>" end string end |