Update syntax highlighting (#426)

* Update highlighted data types

* Update keywords

* Add highlight.js bundled file

* Fix types

Co-authored-by: Alexandru Matei <alexandrumatei3693@gmail.com>
This commit is contained in:
alex-matthe 2021-12-07 14:18:58 +02:00 committed by GitHub
parent e4677959f8
commit e8f381592d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 333 additions and 325 deletions

View file

@ -22,17 +22,21 @@ export default function(hljs) {
const NUMBER_SUFFIX = '([u](8|16|32|64))\?';
const KEYWORDS = [
"abi",
"as",
"asm",
"const",
"contract",
"deref",
"enum",
"fn",
"if",
"impl",
"let",
"library",
"match",
"mut",
"else",
"predicate",
"ref",
"return",
@ -54,20 +58,16 @@ export default function(hljs) {
];
const TYPES = [
"u8",
"u16",
"u32",
"u64",
"bool", "char", "u8", "u16", "u32", "u64", "b256", "str", "Self"
];
return {
name: 'Sway',
aliases: [ 'sw' ],
keywords: {
$pattern: hljs.IDENT_RE + '!?',
type: TYPES,
keyword: KEYWORDS,
literal: LITERALS,
built_in: BUILTINS
built_in: TYPES
},
illegal: '</',
contains: [
@ -126,7 +126,7 @@ export default function(hljs) {
},
{
begin: [
/let/, /\s+/,
/(let|const)/, /\s+/,
/(?:mut\s+)?/,
hljs.UNDERSCORE_IDENT_RE
],
@ -149,7 +149,7 @@ export default function(hljs) {
},
{
begin: [
/(?:trait|enum|struct|impl|for|library)/,
/(?:trait|enum|struct|impl|for|library|abi)/,
/\s+/,
hljs.UNDERSCORE_IDENT_RE
],