@@ -36,30 +36,32 @@ module.exports = function tracToHTML(text) {
3636 // Linkify http links in brackets
3737 . replace (
3838 / ( ^ | \s ) (?: \[ h t t p s ? : \/ \/ ( [ ^ ] + ) " ( [ ^ " ] + ) " \] ) | (?: \[ h t t p s ? : \/ \/ ( [ ^ \s \] ] + ) (?: ( [ ^ \] ] + ) ) ? \] ) / g,
39- function ( _match , space , url , text ) {
40- return `${
41- space || ''
42- } <a href=" ${ url } " class="ext-link"><span class="icon"></span>${
43- text || url
39+ function ( _match , space , quotedurl , quotedtext , url , text ) {
40+ return `${ space || '' } <a href=" ${
41+ quotedurl || url
42+ } " class="ext-link"><span class="icon"></span>${
43+ quotedtext || text || url
4444 } </a>`
4545 }
4646 )
4747 // Linkify hash links in brackets
4848 . replace (
4949 / ( ^ | \s ) (?: \[ ( # [ ^ ] + ) " ( [ ^ " ] + ) " \] ) | (?: \[ ( # [ ^ \s \] ] + ) (?: ( [ ^ \] ] + ) ) ? \] ) / g,
50- function ( _match , space , url , text ) {
51- return `${
52- space || ''
53- } <a href=" ${ url } " class="ext-link"><span class="icon"></span>${
54- text || url
50+ function ( _match , space , quotedurl , quotedtext , url , text ) {
51+ return `${ space || '' } <a href=" ${
52+ quotedurl || url
53+ } " class="ext-link"><span class="icon"></span>${
54+ quotedtext || text || url
5555 } </a>`
5656 }
5757 )
5858 // Linkify CamelCase links in brackets
5959 . replace (
6060 / ( ^ | \s ) (?: \[ ( [ A - Z ] [ a - z ] + [ A - Z ] [ ^ ] + ) " ( [ ^ " ] + ) " \] ) | (?: \[ ( [ A - Z ] [ a - z ] + [ A - Z ] [ ^ \s \] ] + ) (?: ( [ ^ \] ] + ) ) ? \] ) / g,
61- function ( _match , space , page , text ) {
62- return `${ space || '' } <a href="/wiki/${ page } ">${ text || page } </a>`
61+ function ( _match , space , quotedpage , quotedtext , page , text ) {
62+ return `${ space || '' } <a href="/wiki/${ quotedpage || page } ">${
63+ quotedtext || text || page
64+ } </a>`
6365 }
6466 )
6567 // Linkify trac links
0 commit comments