Live markdown preview for comments
We'd like to have a live markdown preview for everywhere you can type markdown, but most especially, comments! This would be a really cool feature and make GitLab a lot nicer to use.
Unfortunately, doing so is very hard:
- If we do this using the existing markdown preview endpoint, we will have serious performance problems. Our markdown pipeline is very customised, and part of that is the huge variety of references we support. Markdown references can hit the database (issues, labels, etc.) and the filesystem (commits, commit ranges, perhaps blobs in future). Both of these are prohibitive to hitting this endpoint anywhere near as frequently as it would need to be hit to provide a smooth user experience. This endpoint is hardly hit at all at the moment, because it's a manual action.
- If we do this on the frontend, we save ourselves the backend performance problems, but we give ourselves a huge correctness problem. We have to reimplement the entire markdown pipeline in JS, and manually figure out which references are valid. We could use the autocomplete endpoints for some of these, but not all of them (commits are one example, cross-project references are another), so even finding those references will still have to hit the backend in some cases. The bigger problem is that we have to implement any new markdown feature twice: once in Ruby, once in JS. That's going to drastically slow down our ability to make changes in this area.
None of this is to say that it is impossible!