private Method

ToHtml.convert_string(item)

some of these patterns are taken from SmartyPants…

Source Code

# File rdoc/markup/simple_markup/to_html.rb, line 190
def convert_string(item)
  CGI.escapeHTML(item).


  # convert -- to em-dash, (-- to en-dash)
    gsub(/---?/, '—'). #gsub(/--/, '–').

  # convert ... to elipsis (and make sure .... becomes .<elipsis>)
    gsub(/\.\.\.\./, '.&#8230;').gsub(/\.\.\./, '&#8230;').

  # convert single closing quote
    gsub(%r{([^ \t\r\n\[\{\(])\'}) { "#$1&#8217;" }.
    gsub(%r{\'(?=\W|s\b)}) { "&#8217;" }.

  # convert single opening quote
    gsub(/'/, '&#8216;').

  # convert double closing quote
    gsub(%r{([^ \t\r\n\[\{\(])\'(?=\W)}) { "#$1&#8221;" }.

  # convert double opening quote
    gsub(/'/, '&#8220;').

  # convert copyright
    gsub(/\(c\)/, '&#169;').

  # convert and registered trademark
    gsub(/\(r\)/, '&#174;')

end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.