dbpedialite.rb
# Escape ampersands, brackets and quotes to their HTML/XML entities.
Escape ampersands, brackets and quotes to their HTML/XML entities.
Escape ampersands brackets and quotes to their HTML / XML entities .
def h(string)
      mapping = {
        "&" => "&amp;",
        "<" => "&lt;",
        ">" => "&gt;",
        "'" => "&#x27;",
        '"' => "&quot;"
      }
      pattern = /#{Regexp.union(*mapping.keys)}/n
      string.to_s.gsub(pattern){|c| mapping[c] }
    end
def h ( string ) mapping = { "&" => "&amp;" , "<" => "&lt;" , ">" => "&gt;" , "'" => "&#x27;" , '"' => "&quot;" } pattern = / #{ Regexp . union ( * mapping . keys ) } /n string . to_s . gsub ( pattern ) { | c | mapping [ c ] } end
Escape ampersands, brackets and quotes to their HTML/XML entities.
Escape ampersands brackets and quotes to their HTML / XML entities .
string
<not_specific>