File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,23 @@ renderer.heading = function (aText, aLevel) {
94
94
return html ;
95
95
} ;
96
96
97
+ // Autolink @username syntax
98
+ renderer . text = function ( aText ) {
99
+ return aText . replace ( / @ ( [ ^ \s \\ \/ : * ? \' \" < > | # ; @ = & ] + ) / gm, function ( $0 , $1 ) {
100
+ return '<a href="/users/' + $1 + '">' + $0 + '</a>' ;
101
+ } ) ;
102
+ } ;
103
+
104
+ renderer . link = function ( aHref , aTitle , aText ) {
105
+ // Prevent double linking @username
106
+ var autoLinkMatch = / > ( @ [ ^ < ] + ) < \/ a > / mi. exec ( aText ) ;
107
+ if ( autoLinkMatch ) {
108
+ aText = autoLinkMatch [ 1 ] ;
109
+ }
110
+
111
+ return marked . Renderer . prototype . link . call ( renderer , aHref , aTitle , aText ) ;
112
+ } ;
113
+
97
114
// Set the options to use for rendering markdown
98
115
// Keep in sync with ./views/includes/scripts/markdownEditor.html
99
116
marked . setOptions ( {
You can’t perform that action at this time.
0 commit comments