File tree Expand file tree Collapse file tree 1 file changed +17
-8
lines changed
Expand file tree Collapse file tree 1 file changed +17
-8
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,25 @@ var R = require('ramda');
1010var pkg = require ( '../package.json' ) ;
1111
1212
13+ //. esc :: String -> String
14+ var esc = R . pipe ( R . replace ( / & / g, '&' ) ,
15+ R . replace ( / < / g, '<' ) ,
16+ R . replace ( / " / g, '"' ) ) ;
17+
18+
1319//. formatSignature :: Options -> String -> Number -> String -> String
1420var formatSignature = R . curry ( function ( options , filename , line , signature ) {
15- return R . join ( '' , [
16- options . heading ,
17- ' [`' ,
18- signature ,
19- '`](' ,
20- options . url . replace ( '{filename}' , filename ) . replace ( '{line}' , line ) ,
21- ')\n' ,
22- ] ) ;
21+ var tagName = 'h' + String ( options . heading . length ) ;
22+ var href = options . url
23+ . replace ( '{filename}' , filename )
24+ . replace ( '{line}' , line ) ;
25+ return (
26+ '<' + esc ( tagName ) + ' name="' + esc ( signature . split ( ' :: ' ) [ 0 ] ) + '">' +
27+ '<code>' +
28+ '<a href="' + esc ( href ) + '">' + esc ( signature ) + '</a>' +
29+ '</code>' +
30+ '</' + esc ( tagName ) + '>\n'
31+ ) ;
2332} ) ;
2433
2534
You can’t perform that action at this time.
0 commit comments