@@ -102,6 +102,20 @@ By default is true."
102
102
" List of hosts where the URL protocol should be http."
103
103
:type '(repeat string))
104
104
105
+ (defcustom browse-at-remote-github-markup-extensions
106
+ '(" .markdown" " .mdown" " .mkdn" " .md"
107
+ " .textile"
108
+ " .rdoc"
109
+ " org"
110
+ " .creole"
111
+ " .mediawiki" " .wiki"
112
+ " .rst"
113
+ " .asciidoc" " .adoc" " .asc"
114
+ " .pod" )
115
+ " List of file extensions where GitHub renders the content as HTML instead of raw.
116
+ See https://github.com/github/markup#markups"
117
+ :type '(repeat string))
118
+
105
119
(defun browse-at-remote--get-url-from-remote (remote-url )
106
120
" Return a plist describing REMOTE-URL."
107
121
; ; If the protocol isn't specified, git treats it as an SSH URL.
@@ -277,11 +291,14 @@ related remote in `browse-at-remote-remote-type-regexps'."
277
291
278
292
(defun browse-at-remote--format-region-url-as-github (repo-url location filename &optional linestart lineend )
279
293
" URL formatted for github."
280
- (cond
281
- ((and linestart lineend)
282
- (format " %s /blob/%s /%s #L%d -L%d " repo-url location filename linestart lineend))
283
- (linestart (format " %s /blob/%s /%s #L%d " repo-url location filename linestart))
284
- (t (format " %s /tree/%s /%s " repo-url location filename))))
294
+ (if linestart
295
+ (let* ((markup-p (-some? (lambda (ext ) (s-ends-with-p ext filename))
296
+ browse-at-remote-github-markup-extensions))
297
+ (fstr (if markup-p " %s/blob/%s/%s?plain=1#L%d" " %s/blob/%s/%s#L%d" )))
298
+ (if lineend
299
+ (format (concat fstr " -L%d" ) repo-url location filename linestart lineend)
300
+ (format fstr repo-url location filename linestart)))
301
+ (format " %s /tree/%s /%s " repo-url location filename)))
285
302
286
303
(defun browse-at-remote--format-commit-url-as-github (repo-url commithash )
287
304
" Commit URL formatted for github"
0 commit comments