Add '?plain=1' to Permalinks on GitLab/GitHub for md files (#18241)

Peter Tripp created

Improve our Permalinks to markdown files.
GitHub/GitLab supports the same URL syntax.

Change summary

crates/git_hosting_providers/src/providers/github.rs | 3 +++
crates/git_hosting_providers/src/providers/gitlab.rs | 3 +++
2 files changed, 6 insertions(+)

Detailed changes

crates/git_hosting_providers/src/providers/github.rs 🔗

@@ -145,6 +145,9 @@ impl GitHostingProvider for Github {
             .base_url()
             .join(&format!("{owner}/{repo}/blob/{sha}/{path}"))
             .unwrap();
+        if path.ends_with(".md") {
+            permalink.set_query(Some("plain=1"));
+        }
         permalink.set_fragment(
             selection
                 .map(|selection| self.line_fragment(&selection))

crates/git_hosting_providers/src/providers/gitlab.rs 🔗

@@ -65,6 +65,9 @@ impl GitHostingProvider for Gitlab {
             .base_url()
             .join(&format!("{owner}/{repo}/-/blob/{sha}/{path}"))
             .unwrap();
+        if path.ends_with(".md") {
+            permalink.set_query(Some("plain=1"));
+        }
         permalink.set_fragment(
             selection
                 .map(|selection| self.line_fragment(&selection))