In your reverse code you have an error:
On line 118:
if(!$self->{reverse_for_edit}) {
it is either the opposite (correct line: "if($self->{reverse_for_edit}) {")
or the documentation is misleading when it says:
reverse_for_edit
When set to a positive value, the "reverse" method will parse
"&", ">" and "<" to their HTML entity equivalent. This option
is useful when reversing HTML to BBCode for editing in a
browser, in a normal "textarea". When set to zero, the
"reverse" method should just ignore these characters. Defaults
to 1.
Best regards