@@ -98,6 +98,20 @@ By default is true."
98
98
" List of domains where the web URL should be http."
99
99
:type '(repeat string))
100
100
101
+ (defcustom browse-at-remote-github-markup-extensions
102
+ '(" .markdown" " .mdown" " .mkdn" " .md"
103
+ " .textile"
104
+ " .rdoc"
105
+ " org"
106
+ " .creole"
107
+ " .mediawiki" " .wiki"
108
+ " .rst"
109
+ " .asciidoc" " .adoc" " .asc"
110
+ " .pod" )
111
+ " List of file extensions where GitHub renders the content as HTML instead of raw.
112
+ See https://github.com/github/markup#markups"
113
+ :type '(repeat string))
114
+
101
115
(defun browse-at-remote--get-url-from-remote (remote-url )
102
116
" Return (DOMAIN . URL) from REMOTE-URL."
103
117
; ; If the protocol isn't specified, git treats it as an SSH URL.
@@ -254,11 +268,14 @@ If HEAD is detached, return nil."
254
268
255
269
(defun browse-at-remote--format-region-url-as-github (repo-url location filename &optional linestart lineend )
256
270
" URL formatted for github."
257
- (cond
258
- ((and linestart lineend)
259
- (format " %s /blob/%s /%s #L%d -L%d " repo-url location filename linestart lineend))
260
- (linestart (format " %s /blob/%s /%s #L%d " repo-url location filename linestart))
261
- (t (format " %s /tree/%s /%s " repo-url location filename))))
271
+ (if linestart
272
+ (let* ((markup-p (-some? (lambda (ext ) (s-ends-with-p ext filename))
273
+ browse-at-remote-github-markup-extensions))
274
+ (fstr (if markup-p " %s/blob/%s/%s?plain=1#L%d" " %s/blob/%s/%s#L%d" )))
275
+ (if lineend
276
+ (format (concat fstr " -L%d" ) repo-url location filename linestart lineend)
277
+ (format fstr repo-url location filename linestart)))
278
+ (format " %s /tree/%s /%s " repo-url location filename)))
262
279
263
280
(defun browse-at-remote--format-commit-url-as-github (repo-url commithash )
264
281
" Commit URL formatted for github"
0 commit comments