It would really help to see the code that you are actually running...
The problem is that something is escaping the HTML. Your code has a function that escaptes HTML. That was the most obvious answer.
Now that I know you aren't actually using that function and you were just showing me test code and not the actual code you were running, I investigated further.
The issue is line 4. By then, the HTML has already been escaped. What you need to do then is to unescape the HTML.
The problem is that something is escaping the HTML. Your code has a function that escaptes HTML. That was the most obvious answer.
Now that I know you aren't actually using that function and you were just showing me test code and not the actual code you were running, I investigated further.
The issue is line 4. By then, the HTML has already been escaped. What you need to do then is to unescape the HTML.
Comment