const httpBracketLink = /\[([^[]+)\]\(([^)]+)\)/gim ; const httpRawLink = /((?<!href=")https?:\/\/[^\s]+)/gim ; const rules = { httpBracketLink : { regex : httpBracketLink , replacer : function ( match , $1 , $2 ) { return `<a href="${ $2 }">${ $1 }</a>` ; } } , httpRawLink : { regex : httpRawLink , replacer : function ( match , $1 ) { return `<a href="${ $1 }">${ $1 }</a>` ; } } } ; export function render ( md ) { Object . keys ( rules ) . forEach ( ( key ) => { md = md . replace ( rules [ key ] . regex , rules [ key ] . replacer ) ; } ) ; return md . trim ( ) ; }