I need to display some superscript and subscript characters in my webpage title. I have a helper method that recognizes the pattern for a subscript or superscript, and converts it to &sub2 or ² 

However, when it shows up in the rendered page's file, it shows up in the source code as:

```
&amp;sub2;

```

Which is not right. I have it set up to be:

```
<% provide(:title, raw(format_title(@hash[:page_title]))) %>

```

But the raw is not working. Any help is appreciated.

Method:

```
def format_title(name)
label = name
if label.match /(_[\d]+_)+|(~[\d]+~)+/
  label = label.gsub(/(_([\d]+)_)+/, '&sub\2;')
  label = label.gsub(/(~([\d]+)~)+/, '&sup\2;')
  label.html_safe
else
  name
end

```

end

I have even tried:

```
str.gsub(/&amp;/, '&')

```

but it gives back:

```
&amp;amp;sub2;

```