Prevent markdown being parsed inside a <pre> tag

This allows for #Rem and #End (and others) to be displayed correctly
added check for close pre tag at the end of a line

Also added trim to allow for blank spaces before or after the tag
corrected case of first Trim call in LineToHtml