Added regular expression parsing so that [[ATTACHMENT| prefix and ]] suffix don't have to occupy a whole line
Remove some now-unnecessary code and fix some formatting.