class SyntaxTree::RegexpLiteral
def format(q)
def format(q) braces = ambiguous?(q) || include?(%r{/}) if braces && include?(/[{}]/) q.group do q.text(beginning) q.format_each(parts) q.text(ending) end elsif braces q.group do q.text("%r{") if beginning == "/" # If we're changing from a forward slash to a %r{, then we can # replace any escaped forward slashes with regular forward slashes. parts.each do |part| if part.is_a?(TStringContent) q.text(part.value.gsub("\\/", "/")) else q.format(part) end end else q.format_each(parts) end q.text("}") q.text(options) end else q.group do q.text("/") q.format_each(parts) q.text("/") q.text(options) end end end