EE: Optimise rendering of Markdown documents that belong to different projects
This is the EE version of https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18157
This is the EE version of https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/18157