Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Created April 29, 2011 19:02
Show Gist options
  • Save toritori0318/948810 to your computer and use it in GitHub Desktop.
Save toritori0318/948810 to your computer and use it in GitHub Desktop.
これをperlに置き換えるのを考え中…
ALLOWED_TAGS = %w(redpre pre code notextile)
def escape_html_tags(text)
text.gsub!(%r{<(\/?([!\w]+)[^<>\n]*)(>?)}) {|m| ALLOWED_TAGS.include?($2) ? "<#{$1}#{$3}" : "&lt;#{$1}#{'&gt;' unless $3.blank?}" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment