Backport PR #5917: use shutil.move instead of os.rename

when moving config files

closes #5898
Backport PR #5933: fix qt_loader import hook signature

to match PEP 302

closes #5932
Backport PR #5944: Markdown rendering bug fix.

The wrong signature of `$()` was being used
wrong: http://api.jquery.com/jQuery/#jQuery1
right: http://api.jquery.com/jQuery/#jQuery2

Instead of implictly calling parseHTML, call it explicitly.
...
Backport PR #6003: Set kernel_id before checking websocket

If websocket attempt fails and cross origin attempt is detected, a HTTPError(404) error is raised. However, in the process of closing connections because of this 404 error, an unhandled Attribute exception (kernel_id not an attribute) is raised. Setting the kernel_id first avoids this.