How to use the marked.apply function in marked

To help you get started, we’ve selected a few marked examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sinfo / eventdeck / client / js / helpers / marked.js View on Github external
var customMarked = function () {
  return marked.apply(marked, arguments)
    // emails
    .replace(/([a-zA-Z0-9.!#$%&amp;'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)/g, '<a href="mailto:$1">$1</a>')
    // twitter
    .replace(/(\W)@(\w+)(?!(?:\w|\.\w))/g, '$1<a href="https://twitter.com/$2">@$2</a>')
    // mentions
    .replace(/(\W)@(\w+\.\w+)(?=\W)/g, function () {
      return arguments[1] + '<a href="/members/' + arguments[2].toLowerCase() + '">@' + arguments[2] + '</a>'
    })
}