| @@ -1,4 +1,4 @@ |
| 1 | | −/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+crystal+rust+scss+sql+typescript */ |
| 1 | +/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+c+cpp+coffeescript+ruby+d+elixir+erlang+go+java+json+kotlin+lua+nginx+nim+perl+php+python+crystal+rust+scss+sql+typescript */ |
| 2 | 2 | var _self = (typeof window !== 'undefined') |
| 3 | 3 | ? window // if in browser |
| 4 | 4 | : ( |
| @@ -976,6 +976,70 @@ delete Prism.languages.coffeescript['template-string']; · 971 unmodified lines |
| 976 | 976 | } |
| 977 | 977 | ]; |
| 978 | 978 | }(Prism)); |
| 979 | +Prism.languages.d = Prism.languages.extend('clike', { |
| 980 | + 'string': [ |
| 981 | + // r"", x"" |
| 982 | + /\b[rx]"(\\.|[^\\"])*"[cwd]?/, |
| 983 | + // q"[]", q"()", q"<>", q"{}" |
| 984 | + /\bq"(?:\[[\s\S]*?\]|\([\s\S]*?\)|<[\s\S]*?>|\{[\s\S]*?\})"/, |
| 985 | + // q"IDENT |
| 986 | + // ... |
| 987 | + // IDENT" |
| 988 | + /\bq"([_a-zA-Z][_a-zA-Z\d]*)(?:\r?\n|\r)[\s\S]*?(?:\r?\n|\r)\1"/, |
| 989 | + // q"//", q"||", etc. |
| 990 | + /\bq"(.)[\s\S]*?\1"/, |
| 991 | + // Characters |
| 992 | + /'(?:\\'|\\?[^']+)'/, |
| 993 | + |
| 994 | + /(["`])(\\.|(?!\1)[^\\])*\1[cwd]?/ |
| 995 | + ], |
| 996 | + |
| 997 | + 'number': [ |
| 998 | + // The lookbehind and the negative look-ahead try to prevent bad highlighting of the .. operator |
| 999 | + // Hexadecimal numbers must be handled separately to avoid problems with exponent "e" |
| 1000 | + /\b0x\.?[a-f\d_]+(?:(?!\.\.)\.[a-f\d_]*)?(?:p[+-]?[a-f\d_]+)?[ulfi]*/i, |
| 1001 | + { |
| 1002 | + pattern: /((?:\.\.)?)(?:\b0b\.?|\b|\.)\d[\d_]*(?:(?!\.\.)\.[\d_]*)?(?:e[+-]?\d[\d_]*)?[ulfi]*/i, |
| 1003 | + lookbehind: true |
| 1004 | + } |
| 1005 | + ], |
| 1006 | + |
| 1007 | + // In order: $, keywords and special tokens, globally defined symbols |
| 1008 | + 'keyword': /\$|\b(?:abstract|alias|align|asm|assert|auto|body|bool|break|byte|case|cast|catch|cdouble|cent|cfloat|char|class|const|continue|creal|dchar|debug|default|delegate|delete|deprecated|do|double|else|enum|export|extern|false|final|finally|float|for|foreach|foreach_reverse|function|goto|idouble|if|ifloat|immutable|import|inout|int|interface|invariant|ireal|lazy|long|macro|mixin|module|new|nothrow|null|out|override|package|pragma|private|protected|public|pure|real|ref|return|scope|shared|short|static|struct|super|switch|synchronized|template|this|throw|true|try|typedef|typeid|typeof|ubyte|ucent|uint|ulong|union|unittest|ushort|version|void|volatile|wchar|while|with|__(?:(?:FILE|MODULE|LINE|FUNCTION|PRETTY_FUNCTION|DATE|EOF|TIME|TIMESTAMP|VENDOR|VERSION)__|gshared|traits|vector|parameters)|string|wstring|dstring|size_t|ptrdiff_t)\b/, |
| 1009 | + 'operator': /\|[|=]?|&[&=]?|\+[+=]?|-[-=]?|\.?\.\.|=[>=]?|!(?:i[ns]\b|<>?=?|>=?|=)?|\bi[ns]\b|(?:<[<>]?|>>?>?|\^\^|[*\/%^~])=?/ |
| 1010 | +}); |
| 1011 | + |
| 1012 | + |
| 1013 | +Prism.languages.d.comment = [ |
| 1014 | + // Shebang |
| 1015 | + /^\s*#!.+/, |
| 1016 | + // /+ +/ |
| 1017 | + { |
| 1018 | + // Allow one level of nesting |
| 1019 | + pattern: /(^|[^\\])\/\+(?:\/\+[\s\S]*?\+\/|[\s\S])*?\+\//, |
| 1020 | + lookbehind: true |
| 1021 | + } |
| 1022 | +].concat(Prism.languages.d.comment); |
| 1023 | + |
| 1024 | +Prism.languages.insertBefore('d', 'comment', { |
| 1025 | + 'token-string': { |
| 1026 | + // Allow one level of nesting |
| 1027 | + pattern: /\bq\{(?:|\{[^}]*\}|[^}])*\}/, |
| 1028 | + alias: 'string' |
| 1029 | + } |
| 1030 | +}); |
| 1031 | + |
| 1032 | +Prism.languages.insertBefore('d', 'keyword', { |
| 1033 | + 'property': /\B@\w*/ |
| 1034 | +}); |
| 1035 | + |
| 1036 | +Prism.languages.insertBefore('d', 'function', { |
| 1037 | + 'register': { |
| 1038 | + // Iasm registers |
| 1039 | + pattern: /\b(?:[ABCD][LHX]|E[ABCD]X|E?(?:BP|SP|DI|SI)|[ECSDGF]S|CR[0234]|DR[012367]|TR[3-7]|X?MM[0-7]|R[ABCD]X|[BS]PL|R[BS]P|[DS]IL|R[DS]I|R(?:[89]|1[0-5])[BWD]?|XMM(?:[89]|1[0-5])|YMM(?:1[0-5]|\d))\b|\bST(?:\([0-7]\)|\b)/, |
| 1040 | + alias: 'variable' |
| 1041 | + } |
| 1042 | +}); |
| 979 | 1043 | Prism.languages.elixir = { |
| 980 | 1044 | // Negative look-ahead is needed for string interpolation |
| 981 | 1045 | // Negative look-behind is needed to avoid highlighting markdown headers in |