module SyntaxTree::Quotes

def self.normalize(content, enclosing)

enclose +content+ with +enclosing+.
Escape and unescape single and double quotes as needed to be able to
def self.normalize(content, enclosing)
  return content if enclosing != "\"" && enclosing != "'"
  content.gsub(/\\([\s\S])|(['"])/) do
    _match, escaped, quote = Regexp.last_match.to_a
    if quote == enclosing
      "\\#{quote}"
    elsif quote
      quote
    else
      "\\#{escaped}"
    end
  end
end