Skip to content

Commit

Permalink
Add some missing keywords for mdBook syntax highlighting (FuelLabs#2903)
Browse files Browse the repository at this point in the history
Add some missing keywords to the `sway.js` file. This was triggered by
@Braqzen noticing some inconsistent highlighting in the generated MD
books.

Doesn't address custom types not being highlighted but that can be for a
future PR.
  • Loading branch information
JoshuaBatty authored Sep 30, 2022
1 parent 49b9e7e commit 58f2021
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/theme/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ anyNumberOfTimes:g};for(const e in A)"object"==typeof A[e]&&n(A[e])
grmr_sway:e=>{const t={className:"title.function.invoke",relevance:0,
begin:b(/\b/,/(?!let\b)/,e.IDENT_RE,u(/\s*\(/))},n="([u](8|16|32|64))?";return{
name:"Sway",aliases:["sw"],keywords:{$pattern:e.IDENT_RE+"!?",
keyword:["abi","as","asm","const","contract","deref","enum","fn","if","impl","let","library","match","mut","else","predicate","ref","return","script","Self","self","storage","str","struct","trait","use","where","while"],
literal:["true","false"],
keyword:["abi","as","asm","break","const","continue","contract","dep","deref","else","enum","fn","for","if","impl","let","library","match","mut","predicate","pub","ref","return","script","Self","self","storage","str","struct","trait","use","where","while"],
literal:["true","false","Some","None","Ok","Err"],
built_in:["bool","char","u8","u16","u32","u64","b256","str","Self"]},
illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{
contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{
Expand Down
11 changes: 10 additions & 1 deletion scripts/highlightjs/sway.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@ export default function(hljs) {
"abi",
"as",
"asm",
"break",
"const",
"continue",
"contract",
"dep",
"deref",
"else",
"enum",
"fn",
"for",
"if",
"impl",
"let",
"library",
"match",
"mut",
"else",
"predicate",
"pub",
"ref",
"return",
"script",
Expand All @@ -54,6 +59,10 @@ export default function(hljs) {
const LITERALS = [
"true",
"false",
"Some",
"None",
"Ok",
"Err",
];
const BUILTINS = [

Expand Down

0 comments on commit 58f2021

Please sign in to comment.