ensure closing tags are appended when using custom word boundaries