Improve markup detection, fixes #4695
Merge pull request #4698 from Razer6/improve_markup_detection

Improve markup detection, fixes #4695