Add built-in traits to hirust.js

0af749604bdb5b1a31c32b83b9dab6228d46495a
Alexis Sellier committed ago 1 parent 723787f4
js/hirust.js +3 -1
8 8
// All elements which match this will be syntax highlighted.
9 9
var selector = hirust || '.language-rust';
10 10
11 11
var keywords = ('fn pub if else for while break match struct enum type let impl use mod self '
12 12
               +'continue return true false loop in unsafe where crate super').split(' '),
13 -
    special  = ('Ok Err Result').split(' ');
13 +
    special  = ('Ok Err Result').split(' '),
14 +
    traits   = ('Eq PartialEq Ord PartialOrd Copy Clone Debug Default Sync Send Sized').split(' ');
14 15
15 16
// Syntax definition.
16 17
//
17 18
// The key becomes the class name of the <span> around the matched block of code.
18 19
var syntax = [
21 22
  ['attr'   , /(#\[[^\]]+\])/g],
22 23
  ['number' , /\b([0-9]+(?:\.[0-9]+)?)\b/g],
23 24
  ['ref'    , /(&mut\b|\bmut\b|&)\b/g],
24 25
  ['op'     , /(::|\.\.)/g],
25 26
  ['macro'  , /\b(println!|eprintln!|panic!|assert!|assert_eq!)/g],
27 +
  ['trait'  , new(RegExp)('\\b(' + traits.join('|') + ')\\b', 'g')],
26 28
  ['keyword', new(RegExp)('\\b(' + keywords.join('|') + ')\\b', 'g')],
27 29
  ['special', new(RegExp)('\\b(' + special.join('|') + ')\\b', 'g')]
28 30
];
29 31
var nodes, table = {};
30 32