aboutsummaryrefslogtreecommitdiffstats
path: root/public/prism/prism-parigp.js
blob: 45759b1f32d418d71398726a91e6bab916b68838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph *
Prism.languages.parigp = {
  comment: /\/\*[\s\S]*?\*\/|\\\\.*/,
  string: {
    pattern: /"(?:[^"\\\r\n]|\\.)*"/,
    greedy: true,
  },
  // PARI/GP does not care about white spaces at all
  // so let's process the keywords to build an appropriate regexp
  // (e.g. "b *r *e *a *k", etc.)
  keyword: (function () {
    var keywords = [
      'breakpoint',
      'break',
      'dbg_down',
      'dbg_err',
      'dbg_up',
      'dbg_x',
      'forcomposite',
      'fordiv',
      'forell',
      'forpart',
      'forprime',
      'forstep',
      'forsubgroup',
      'forvec',
      'for',
      'iferr',
      'if',
      'local',
      'my',
      'next',
      'return',
      'until',
      'while',
    ];
    keywords = keywords
      .map(function (keyword) {
        return keyword.split('').join(' *');
      })
      .join('|');
    return RegExp('\\b(?:' + keywords + ')\\b');
  })(),
  function: /\b\w(?:[\w ]*\w)?(?= *\()/,
  number: {
    // The lookbehind and the negative lookahead prevent from breaking the .. operator
    pattern:
      /((?:\. *\. *)?)(?:\b\d(?: *\d)*(?: *(?!\. *\.)\.(?: *\d)*)?|\. *\d(?: *\d)*)(?: *e *(?:[+-] *)?\d(?: *\d)*)?/i,
    lookbehind: true,
  },
  operator:
    /\. *\.|[*\/!](?: *=)?|%(?: *=|(?: *#)?(?: *')*)?|\+(?: *[+=])?|-(?: *[-=>])?|<(?: *>|(?: *<)?(?: *=)?)?|>(?: *>)?(?: *=)?|=(?: *=){0,2}|\\(?: *\/)?(?: *=)?|&(?: *&)?|\| *\||['#~^]/,
  punctuation: /[\[\]{}().,:;|]/,
};