class BookChef

Constants

LIB_PATH

Public Class Methods

decode_special_chars(s) click to toggle source
# File lib/bookchef.rb, line 28
def decode_special_chars(s)
  s.gsub(/#([a-zA-Z0-9#]*?);/, '&\1;')
end
protect_special_chars(s) click to toggle source

Converts XML special characrters into temporary identifiable entities for later backwards conversion by BookChef compilers.

# File lib/bookchef.rb, line 18
def protect_special_chars(s)
  # erb tags
  s.gsub!(/<%(.*?)%>/, '#lt;%\1%#gt;')
  # all xml entities
  s.gsub!(/&([a-zA-Z0-9#]*?);/, '#\1;')
  # standalone ampersand chars
  s.gsub!('&', '#amp;')
  return s
end
replace_https_with_http(s) click to toggle source
# File lib/bookchef.rb, line 32
def replace_https_with_http(s)
  s.gsub('href="https://', 'href="http://')
end