Render references to source code lines inline
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=22156) </details> <!--IssueSummary end--> Need the ability to see referenced source code lines directly in an issue comment. Right now if the link to source code is pasted, people still need to: 1. open new tab to read the code 2. know where to get permalink to reference the code (so that it won't shift over time) ### Proposal 1. Automatically transform source code URLs into permalinks (https://gitlab.com/gitlab-org/gitlab/-/issues/537874) 2. Render standalone permalinks as code blocks ### How to test the issue is solved When user pastes link to the source code on a separate line, GitLab should: 1. fetch the permalink for the provided source link (#537874) 2. fetch source code lines for the provided permalink (say 2 above and 5 below by default) 3. render source code, in the comment, with appropriate highlighter and referenced line (3) highlighted 4. render permalink in the comment ### Example Line ``` https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/project_ci_cd_setting.rb#L20 ``` should turn into this permalink while editing the post ``` https://gitlab.com/gitlab-org/gitlab/-/blob/3f1076db0d34c46f0bf4f824a268941bbc943e23/app/models/project_ci_cd_setting.rb#L20 ``` and then rendered as --- ```ruby allow_nil: true ->default_value_for :forward_deployment_enabled, true<------- THIS LINE IS HIGHLIGHTED default_value_for :separated_caches, true chronic_duration_attr :runner_token_expiration_interval_human_readable, :runner_token_expiration_interval def forward_deployment_enabled? ``` https://gitlab.com/gitlab-org/gitlab/-/blob/3f1076db0d34c46f0bf4f824a268941bbc943e23/app/models/project_ci_cd_setting.rb#L20 ### Similar issues #19480 proposes adding menu at line anchor to copy permalink. ### Links / references https://stackoverflow.com/questions/23821235/how-to-link-to-specific-line-number-on-github/45578779#45578779
issue