Highlight diff content rendered/extracted only once
Meta issue to describe parts that need to be addressed to be able to highlight diff content only once as raw diff and in the UI. We're showing highlighted diff content in the following parts:
- MR#new
- MR#show (discussion tab to show DiffNote contexts)
- MR#diff
- Commit#show
- Compare#show
- EmailsOnPush
### Definitions
**highlighted diff content**
It's the HTML content that the rouge gem is generating per line of a diff. `Gitlab::Diff::Highlight#highlight`
**UI highlighted diff content**
it's the HTML content result of wrapping the __highlighted_diff_content__ with some HTML to be shown in the UI.
### Questions to think about it
- How can we store highlighted diff content?
- Do we want to preemptively store it? Just an example if we render the diff when rendering the MR form, that diff will be the same after creation if not pushes happened in the meantime so we can reuse a lot.
- Can a discussion access to an existing highlighted diff content to show that content as context? Or that context can be associated to the discussion itself on diff note creation?
- Do we want to cache the whole HTML that the browsers are getting __UI highlighted diff content__?
- __UI highlighted diff content__ is modified only when adding notes or when diffing with other options (ignore_white_space), can we merge comments and notes without flushing the cache?
- Discussion context can be part of the __UI highlighted diff content__ which is something that we already generate in a previous step (when the user created the note through the UI). Can we add the notes to that context (from a cached context or cached whole highlighted diff content)? or we copy the context to the note when creating the not? (the context should be already persisted in some place because we show it when creating the note at if its generated through the UI) I'm not sure if DiffNote can be created through the API
issue