use $().text() instead of .safeHtml for sourceSnudown

Issue #1836.
Also slightly refactored.