 	"ſ": "&#383;"
 
 escape = (input) ->
+	input = unescape input
 	for c of entity_table
 		input = input.replace(c, entity_table[c])
 	input
 
 unescape = (input) ->
 	for c of entity_table
-		input = input.replace(entity_table[c],c)
+		input = input.replace entity_table[c], c
 	input
 
 if exports

				mode = x
			else if x.push
				x.push c
	return cursor

entity_table =
	"™": "&#8482;"
	"€": "&euro;"
	" ": "&nbsp;"
	'"': "&quot;"
	"&": "&amp;"
	"<": "&lt;"
	">": "&gt;"
	"¡": "&iexcl;"

	text = []
	attributes = {}
	emitNode = () ->
		if tagName.length > 0
			node = document.createElement(get(tagName))
			for a of attributes
				node.setAttribute(a, attributes[a])
			cursor.appendChild(node)
			cursor = node
			clear(text, tagName, attrName, attrVal)
			for a of attributes
				delete attributes[a]
			mode = 0
	closeNode = () -> cursor = cursor.parentNode
	emitAttr = () ->
		attributes[get(attrName)] = get(attrVal)
