aboutsummaryrefslogtreecommitdiff
path: root/node_modules/supertest/node_modules/superagent/docs/highlight.js
blob: b37eefbd5f289e29c3441f00ed25bc0a94f1803c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$(function(){
  $('code').each(function(){
    $(this).html(highlight($(this).text()));
  });
});

function highlight(js) {
  return js
    .replace(/</g, '&lt;')
    .replace(/>/g, '&gt;')
    .replace(/('.*?')/gm, '<span class="string">$1</span>')
    .replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>')
    .replace(/(\d+)/gm, '<span class="number">$1</span>')
    .replace(/\bnew *(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>')
    .replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>')
}