Support linking from handbook content to a specific line of code in the web IDE
Problem to solve
A user can lose their context when opening a handbook page in the web IDE and it can be hard to pinpoint the content they intended to edit. This is particularly difficult on lengthy handbook pages with long areas of body text.
Proposal
Building off the work in #6027 (closed) and #6370 (closed), we should build a way to deep-link into the web IDE and place the user's cursor at an exact line of code. This way, when a user selects some content on the handbook page, they can be linked to the exact line of code that needs to be edited.
For example, linking to https://gitlab.com/-/ide/project/username/project-name/edit/master/-/FILE.md::42
would take the user to line 42.
Other options might be to link to specific markdown tags like headings matching a certain string. Or, as a stretch, allow a link to contain information about the entire selection. Something like https://gitlab.com/-/ide/project/username/project-name/edit/master/-/README.md&42:6-47:15
to pre-select a range of text on lines 42-47.
Open questions
- Can we reliably link to the correct source file with a reasonable level of accuracy (say, 80% of the time) given the dynamic structure of some of the handbook content?
- If we end up trying to match strings (instead of keeping some reference to the LOC) then how do we handle very short, frequently occurring strings?
Implementation details
- Use the beginning of the selection to place the user's cursor in the Web IDE
- If the selection spans multiple paragraphs, multiple sections, or even multiple files, use the source for the line at the beginning of the selection