pootle_translationproject: Fix an exception during exception handling

directory is never defined outside the Try block.
Placeables: Make sure text is always escaped

highlight_placeables() was assuming that parse_placeables() will always
detect placeables correctly and was outputting text not part of a
placeable unescaped, but this is not a safe assumption as
parse_placeables() can fail to detect some placeables and we might end
up with unesacaped HTML material.