diff --git a/src/theme/syntaxes/README.md b/src/theme/syntaxes/README.md index a03b1aa8..2031f263 100644 --- a/src/theme/syntaxes/README.md +++ b/src/theme/syntaxes/README.md @@ -1,5 +1,12 @@ +Console.sublime-syntax was written for mdBook. + +Handlebars.sublime-syntax is from PLACEHOLDER + +TOML.sublime-syntax is from https://github.com/jasonwilliams/sublime_toml_highlighting/blob/0f14b7caf3c775a5d18551a9563a9debdb10c9a9/TOML.sublime-syntax + # Note This folder is not copied over to the book directory when using `mdbook init`, nor is it indexed at runtime. All of the files in this folder are scraped by build.rs. -To make build.rs run again without running `cargo clean`, touch the run `touch build.rs`. \ No newline at end of file +To make build.rs run again without running `cargo clean`, touch the run `touch build.rs`. + diff --git a/src/theme/syntaxes/TOML.sublime-syntax b/src/theme/syntaxes/TOML.sublime-syntax new file mode 100644 index 00000000..ea8e6328 --- /dev/null +++ b/src/theme/syntaxes/TOML.sublime-syntax @@ -0,0 +1,405 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: TOML + +file_extensions: + - toml + - tml + - Cargo.lock + - Gopkg.lock + - Pipfile + +scope: source.toml + +variables: + ws: '[ \t]*' + wsnl: '([ \t\n])*' + + # Used to detect the possible start of a key. + peek_key_start: '(?=[A-Za-z0-9_''"-])' + dot_peek_key: '{{ws}}(\.){{ws}}{{peek_key_start}}' + + # integer = [ "-" / "+" ] int + # int = DIGIT / digit1-9 1*( DIGIT / "_" DIGIT ) + integer: '([\+\-]?) (?: [0-9] | [1-9] (?: [0-9] | _ [0-9] )+ )' + + HEXDIG: '[0-9A-Fa-f]' + hex_int: '0x{{HEXDIG}}(?:{{HEXDIG}}|_{{HEXDIG}})*' + oct_int: '0o[0-7](?:[0-7]|_[0-7])*' + bin_int: '0b[0-1](?:[0-1]|_[0-1])*' + + # zero-prefixable-int = DIGIT *( DIGIT / underscore DIGIT ) + zero_prefixable_int: '[0-9] (?: [0-9] | _ [0-9] )*' + # frac = decimal-point zero-prefixable-int + frac: '\. {{zero_prefixable_int}}' + # exp = "e" float-exp-part + # float-exp-part = [ minus / plus ] zero-prefixable-int + exp: '[eE] [\+\-]? {{zero_prefixable_int}}' + + # date-time = offset-date-time / local-date-time / local-date / local-time + date_time: '{{offset_date_time}} | {{local_date_time}} | {{local_date}} | {{local_time}}' + # date-fullyear = 4DIGIT + date_fullyear: '[0-9]{4}' + # date-month = 2DIGIT ; 01-12 + date_month: '[0-1][0-9]' + # date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on month/year + date_mday: '[0-3][0-9]' + # time-hour = 2DIGIT ; 00-23 + time_hour: '[0-2][0-9]' + # time-minute = 2DIGIT ; 00-59 + time_minute: '[0-5][0-9]' + # time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second rules + time_second: '[0-6][0-9]' + # time-secfrac = "." 1*DIGIT + time_secfrac: '\.[0-9]+' + # time-numoffset = ( "+" / "-" ) time-hour ":" time-minute + time_numoffset: '[+-] {{time_hour}} : {{time_minute}}' + # time-offset = "Z" / time-numoffset + time_offset: '(?: [zZ] | {{time_numoffset}} )' + # partial-time = time-hour ":" time-minute ":" time-second [time-secfrac] + partial_time: '{{time_hour}} : {{time_minute}} : {{time_second}} (?: {{time_secfrac}} )?' + # full-date = date-fullyear "-" date-month "-" date-mday + full_date: '{{date_fullyear}} - {{date_month}} - {{date_mday}}' + # full-time = partial-time time-offset + full_time: '{{partial_time}} {{time_offset}}' + # offset-date-time = full-date T|%20 full-time + offset_date_time: '{{full_date}} [tT ] {{full_time}}' + # local-date-time = full-date T|%20 partial-time + local_date_time: '{{full_date}} [tT ] {{partial_time}}' + # local-date = full-date + local_date: '{{full_date}}' + # local-time = partial-time + local_time: '{{partial_time}}' + +contexts: + main: + - match: '^{{ws}}' + # Ignore leading whitespace for all expressions. + - include: comments + - include: tables + - include: keyval + - include: illegal + + illegal: + - match: (.*) + # Invalid things -> everything unmatched + captures: + 1: invalid.illegal.toml + + comments: + - match: '{{ws}}((#).*)' + captures: + 1: comment.line.number-sign.toml + 2: punctuation.definition.comment.toml + + data-types: + - include: inline-table + - include: array + - include: string + - include: date-time + - include: float + - include: integer + - include: boolean + - match: '{{ws}}$' + # Don't show an incomplete line as invalid to avoid frequent red + # highlighting while typing. + pop: true + - match: '\w+|.' + scope: invalid.illegal.value.toml + pop: true + + boolean: + - match: (true|false) + captures: + 1: constant.language.toml + pop: true + + integer: + - match: |- + (?x) + (?