diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d4e9b97 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,27 @@ +[submodule "sublime_syntaxes/Packages"] + path = sublime_syntaxes/Packages + url = https://github.com/sublimehq/Packages.git +[submodule "sublime_syntaxes/sublimeassembly"] + path = sublime_syntaxes/sublimeassembly + url = https://github.com/Nessphoro/sublimeassembly.git +[submodule "sublime_syntaxes/LESS-sublime"] + path = sublime_syntaxes/LESS-sublime + url = https://github.com/danro/LESS-sublime.git +[submodule "sublime_syntaxes/TypeScript-Sublime-Plugin"] + path = sublime_syntaxes/TypeScript-Sublime-Plugin + url = https://github.com/Microsoft/TypeScript-Sublime-Plugin.git +[submodule "sublime_syntaxes/Handlebars"] + path = sublime_syntaxes/Handlebars + url = https://github.com/daaain/Handlebars.git +[submodule "sublime_syntaxes/Julia-sublime"] + path = sublime_syntaxes/Julia-sublime + url = https://github.com/JuliaEditorSupport/Julia-sublime.git +[submodule "sublime_syntaxes/Elm.tmLanguage"] + path = sublime_syntaxes/Elm.tmLanguage + url = https://github.com/elm-community/Elm.tmLanguage.git +[submodule "sublime_syntaxes/sublime_toml_highlighting"] + path = sublime_syntaxes/sublime_toml_highlighting + url = https://github.com/Jayflux/sublime_toml_highlighting.git +[submodule "sublime_syntaxes/SublimeTextLinkerSyntax"] + path = sublime_syntaxes/SublimeTextLinkerSyntax + url = https://github.com/jbw3/SublimeTextLinkerSyntax.git diff --git a/README.md b/README.md index 1f45bf8..b57ab61 100644 --- a/README.md +++ b/README.md @@ -148,9 +148,6 @@ built-in: - solarized-dark - solarized-light -A gallery containing lots of themes at https://tmtheme-editor.herokuapp.com/#!/editor/theme/Agola%20Dark. -More themes can be easily added to gutenberg, just make a PR with the wanted theme. - ### Internal links You can have internal links in your markdown that will be replaced with the full URL when rendering. To do so, use the normal markdown link syntax, start the link with `./` and point to the `.md` file you want @@ -207,3 +204,47 @@ In case of shortcodes with a body, the body will be passed as the `body` variabl ## Example sites - [vincent.is](https://vincent.is): https://gitlab.com/Keats/vincent.is + + +## Adding syntax highlighting languages and themes +### Adding a syntax +Syntax highlighting depends on submodules so ensure you load them first: +```bash +$ git submodule update --init +``` +Gutenberg only works with syntaxes in the `.sublime-syntax` format. If your syntax +is in `.tmLanguage` format, open it in Sublime Text and convert it to `sublime-syntax` by clicking on +Tools > Developer > New Syntax from ... and put it at the root of `sublime_syntaxes`. + +You can also add a submodule to the repository of the wanted syntax: + +```bash +$ cd sublime_syntaxes +$ git submodule add https://github.com/elm-community/Elm.tmLanguage.git +``` + +Note that you can also only copy manually the updated syntax definition file but this means +Gutenberg won't be able to automatically update it. + +You can check for any updates to the current packages by running: + +```bash +$ git submodule update --remote --merge +``` + +And finally from the root of the repository run the following command: + +```bash +$ cargo run --example generate_sublime synpack sublime_syntaxes sublime_syntaxes/newlines.packdump sublime_syntaxes/nonewlines.packdump +``` + +### Adding a theme +A gallery containing lots of themes at https://tmtheme-editor.herokuapp.com/#!/editor/theme/Agola%20Dark. +More themes can be easily added to gutenberg, just make a PR with the wanted theme added in the `sublime_themes` directory +and run the following command from the repository root: + +```bash +$ cargo run --example generate_sublime themepack sublime_themes sublime_themes/all.themedump +``` + +You should see the list of themes being added. diff --git a/examples/generate_themes.rs b/examples/generate_sublime.rs similarity index 58% rename from examples/generate_themes.rs rename to examples/generate_sublime.rs index bd19cae..3f73ae9 100644 --- a/examples/generate_themes.rs +++ b/examples/generate_sublime.rs @@ -9,19 +9,18 @@ use syntect::dumps::*; use std::env; fn usage_and_exit() -> ! { - println!("USAGE: gendata synpack source-dir newlines.packdump nonewlines.packdump\n - gendata themepack source-dir themepack.themedump"); + println!("USAGE: cargo run --example generate_sublime synpack source-dir newlines.packdump nonewlines.packdump\n + cargo run --example generate_sublime themepack source-dir themepack.themedump"); ::std::process::exit(2); } +// Not an example of Gutenberg but is used to generate the theme and syntax dump +// used for syntax highlighting. +// Check README for more details fn main() { - - let mut a = env::args().skip(1); - match (a.next(), a.next(), a.next(), a.next()) { - (Some(ref cmd), - Some(ref package_dir), - Some(ref packpath_newlines), - Some(ref packpath_nonewlines)) if cmd == "synpack" => { + let mut args = env::args().skip(1); + match (args.next(), args.next(), args.next(), args.next()) { + (Some(ref cmd), Some(ref package_dir), Some(ref packpath_newlines), Some(ref packpath_nonewlines)) if cmd == "synpack" => { let mut ps = SyntaxSet::new(); ps.load_plain_text_syntax(); ps.load_syntaxes(package_dir, true).unwrap(); @@ -32,8 +31,11 @@ fn main() { ps.load_syntaxes(package_dir, false).unwrap(); dump_to_file(&ps, packpath_nonewlines).unwrap(); - } - (Some(ref s), Some(ref theme_dir), Some(ref packpath), None) if s == "themepack" => { + for s in ps.syntaxes() { + println!("Add {} -> {:?}", s.name, s.file_extensions); + } + }, + (Some(ref cmd), Some(ref theme_dir), Some(ref packpath), None) if cmd == "themepack" => { let ts = ThemeSet::load_from_folder(theme_dir).unwrap(); for path in ts.themes.keys() { println!("{:?}", path); diff --git a/src/markdown.rs b/src/markdown.rs index b02940d..ce137af 100644 --- a/src/markdown.rs +++ b/src/markdown.rs @@ -18,7 +18,7 @@ use errors::{Result, ResultExt}; // We need to put those in a struct to impl Send and sync pub struct Setup { - syntax_set: SyntaxSet, + pub syntax_set: SyntaxSet, pub theme_set: ThemeSet, } @@ -28,7 +28,11 @@ unsafe impl Sync for Setup {} lazy_static!{ static ref SHORTCODE_RE: Regex = Regex::new(r#"\{(?:%|\{)\s+([[:alnum:]]+?)\(([[:alnum:]]+?="?.+?"?)\)\s+(?:%|\})\}"#).unwrap(); pub static ref SETUP: Setup = Setup { - syntax_set: SyntaxSet::load_defaults_newlines(), + syntax_set: { + let mut ps: SyntaxSet = from_binary(include_bytes!("../sublime_syntaxes/newlines.packdump")); + ps.link_syntaxes(); + ps + }, theme_set: from_binary(include_bytes!("../sublime_themes/all.themedump")) }; } diff --git a/src/site.rs b/src/site.rs index 09371a4..d82127e 100644 --- a/src/site.rs +++ b/src/site.rs @@ -70,6 +70,7 @@ pub struct Site { static_path: PathBuf, pub tags: HashMap>, pub categories: HashMap>, + pub permalinks: HashMap, } impl Site { @@ -96,6 +97,7 @@ impl Site { static_path: path.join("static"), tags: HashMap::new(), categories: HashMap::new(), + permalinks: HashMap::new(), }; Ok(site) @@ -146,6 +148,7 @@ impl Site { page.render_markdown(&permalinks, &self.tera, &self.config)?; } + self.permalinks = permalinks; self.populate_sections(); self.populate_tags_and_categories(); @@ -166,6 +169,14 @@ impl Site { Ok(()) } + /// Called in serve, add a page again updating permalinks and its content + fn add_page_and_render(&mut self, path: &Path) -> Result<()> { + self.add_page(path)?; + let mut page = self.pages.get_mut(path).unwrap(); + self.permalinks.insert(page.relative_path.clone(), page.permalink.clone()); + page.render_markdown(&self.permalinks, &self.tera, &self.config) + } + /// Find out the direct subsections of each subsection if there are some /// as well as the pages for each section fn populate_sections(&mut self) { @@ -272,15 +283,17 @@ impl Site { self.add_section(path)?; } else { // probably just an update so just re-parse that page - self.add_page(path)?; + self.add_page_and_render(path)?; } } else { // new file? - self.add_page(path)?; + self.add_page_and_render(path)?; } } else { - // File doesn't exist -> a deletion so we remove it from + // File doesn't exist -> a deletion so we remove it from everything + let relative_path = self.pages[path].relative_path.clone(); self.pages.remove(path); + self.permalinks.remove(&relative_path); } self.populate_sections(); self.populate_tags_and_categories(); diff --git a/sublime_syntaxes/Assembly x86.sublime-syntax b/sublime_syntaxes/Assembly x86.sublime-syntax new file mode 100644 index 0000000..98a74a6 --- /dev/null +++ b/sublime_syntaxes/Assembly x86.sublime-syntax @@ -0,0 +1,68 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Assembly x86 (NASM) +file_extensions: + - asm + - inc + - nasm +scope: source.assembly +contexts: + main: + - match: \b(?i)(v)?(aaa|aad|aam|aas|adc|add|addpd|addps|addsd|addss|addsubpd|addsubps|aesdec|aesdeclast|aesenc|aesenclast|aesimc|aeskeygenassist|and|andpd|andps|andnpd|andnps|arpl|blendpd|bmi|blendps|blendvpd|blendvps|bound|bsf|bsr|bswap|bt|btc|btr|bts|cbw|cwde|cdqe|clc|cld|cflush|clts|cmc|cmov(n?e|ge?|ae?|le?|be?|n?o|n?z)|cmp|cmppd|cmpps|cmps|cnpsb|cmpsw|cmpsd|cmpsq|cmpss|cmpxchg|cmpxchg8b|cmpxchg16b|comisd|comiss|cpuid|crc32|cvtdq2pd|cvtdq2ps|cvtpd2dq|cvtpd2pi|cvtpd2ps|cvtpi2pd|cvtpi2ps|cvtps2dq|cvtps2pd|cvtps2pi|cvtsd2si|cvtsd2ss|cvts2sd|cvtsi2ss|cvtss2sd|cvtss2si|cvttpd2dq|cvtpd2pi|cvttps2dq|cvttps2pi|cvttps2dq|cvttps2pi|cvttsd2si|cvttss2si|cwd|cdq|cqo|daa|das|dec|div|divpd|divps|divsd|divss|dppd|dpps|emms|enter|extractps|f2xm1|fabs|fadd|faddp|fiadd|fbld|fbstp|fchs|fclex|fnclex|fcmov(n?e|ge?|ae?|le?|be?|n?o|n?z)|fcom|fcmop|fcompp|fcomi|fcomip|fucomi|fucomip|fcos|fdecstp|fdiv|fdivp|fidiv|fdivr|fdivrp|fidivr|ffree|ficom|ficomp|fild|fincstp|finit|fnint|fist|fistp|fisttp|fld|fld1|fldl2t|fldl2e|fldpi|fldlg2|fldln2|fldz|fldcw|fldenv|fmul|fmulp|fimul|fnop|fpatan|fprem|fprem1|fptan|frndint|frstor|fsave|fnsave|fscale|fsin|fsincos|fsqrt|fst|fstp|fstcw|fnstcw|fstenv|fnstenv|fsts(w?)|fnstsw|fsub|fsubp|fisub|fsubr|fsubrp|fisubr|ftst|fucom|fucomp|fucompp|fxam|fxch|fxrstor|fxsave|fxtract|fyl2x|fyl2xp1|haddpd|haddps|husbpd|hsubps|idiv|imul|in|inc|ins|insb|insw|insd|insertps|int|into|invd|invlpg|invpcid|iret|iretd|iretq|lahf|lar|lddqu|ldmxcsr|lds|les|lfs|lgs|lss|lea|leave|lfence|lgdt|lidt|llgdt|lmsw|lock|lods|lodsb|lodsw|lodsd|lodsq|lsl|ltr|maskmovdqu|maskmovq|maxpd|maxps|maxsd|maxss|mfence|minpd|minps|minsd|minss|monitor|mov|movapd|movaps|movbe|movd|movq|movddup|movdqa|movdqu|movq2q|movhlps|movhpd|movhps|movlhps|movlpd|movlps|movmskpd|movmskps|movntdqa|movntdq|movnti|movntpd|movntps|movntq|movq|movq2dq|movs|movsb|movsw|movsd|movsq|movsd|movshdup|movsldup|movss|movsx|movsxd|movupd|movups|movzx|mpsadbw|mul|mulpd|mulps|mulsd|mulss|mwait|neg|not|or|orpd|orps|out|outs|outsb|outsw|outsd|pabsb|pabsw|pabsd|packsswb|packssdw|packusdw|packuswb|paddb|paddw|paddd|paddq|paddsb|paddsw|paddusb|paddusw|palignr|pand|pandn|pause|pavgb|pavgw|pblendvb|pblendw|pclmulqdq|pcmpeqb|pcmpeqw|pcmpeqd|pcmpeqq|pcmpestri|pcmpestrm|pcmptb|pcmptgw|pcmpgtd|pcmpgtq|pcmpistri|pcmpisrm|pdep|pext|pextrb|pextrd|pextrq|pextrw|phaddw|phaddd|phaddsw|phinposuw|phsubw|phsubd|phsubsw|pinsrb|pinsrd|pinsrq|pinsrw|pmaddubsw|pmadddwd|pmaxsb|pmaxsd|pmaxsw|pmaxsw|pmaxub|pmaxud|pmaxuw|pminsb|pminsd|pminsw|pminub|pminud|pminuw|pmovmskb|pmovsx|pmovzx|pmuldq|pmulhrsw|pmulhuw|pmulhw|pmulld|pmullw|pmuludw|pop|popa|popad|popcnt|popf|popfd|popfq|por|prefetch|psadbw|pshufb|pshufd|pshufhw|pshuflw|pshufw|psignb|psignw|psignd|pslldq|psllw|pslld|psllq|psraw|psrad|psrldq|psrlw|psrld|psrlq|psubb|psubw|psubd|psubq|psubsb|psubsw|psubusb|psubusw|test|ptest|punpckhbw|punpckhwd|punpckhdq|punpckhddq|punpcklbw|punpcklwd|punpckldq|punpckldqd|push|pusha|pushad|pushf|pushfd|pxor|prcl|rcr|rol|ror|rcpps|rcpss|rdfsbase|rdgsbase|rdmsr|rdpmc|rdrand|rdtsc|rdtscp|rep|repe|repz|repne|repnz|roundpd|roundps|roundsd|roundss|rsm|rsqrps|rsqrtss|sahf|sal|sar|shl|shr|sbb|scas|scasb|scasw|scasd|set(n?e|ge?|ae?|le?|be?|n?o|n?z)|sfence|sgdt|shld|shrd|shufpd|shufps|sidt|sldt|smsw|sqrtpd|sqrtps|sqrtsd|sqrtss|stc|std|stmxcsr|stos|stosb|stosw|stosd|stosq|str|sub|subpd|subps|subsd|subss|swapgs|syscall|sysenter|sysexit|sysret|teset|ucomisd|ucomiss|ud2|unpckhpd|unpckhps|unpcklpd|unpcklps|vbroadcast|vcvtph2ps|vcvtp2sph|verr|verw|vextractf128|vinsertf128|vmaskmov|vpermilpd|vpermilps|vperm2f128|vtestpd|vzeroall|vzeroupper|wait|fwait|wbinvd|wrfsbase|wrgsbase|wrmsr|xadd|xchg|xgetbv|xlat|xlatb|xor|xorpd|xorps|xrstor|xsave|xsaveopt|xsetbv|lzcnt|extrq|insertq|movntsd|movntss|vfmaddpd|vfmaddps|vfmaddsd|vfmaddss|vfmaddsubbpd|vfmaddsubps|vfmsubaddpd|vfmsubaddps|vfmsubpd|vfmsubps|vfmsubsd|vfnmaddpd|vfnmaddps|vfnmaddsd|vfnmaddss|vfnmsubpd|vfnmusbps|vfnmusbsd|vfnmusbss|vbroadcastss|vbroadcastsd|vbroadcastf128|vmaskmovps|vmaskmovpd|cvt|xor|cli|sti|hlt|nop|lock|wait|enter|leave|ret|loop(n?e|n?z)?|call|j(mp|n?e|n?ge?|n?ae?|le?|be?|n?o|n?z|n?c|n?p|n?b))\b + scope: keyword.control.assembly + - match: '\b(?i)(RBP|EBP|BP|CS|DS|ES|FS|GS|SS|RAX|EAX|RBX|EBX|RCX|ECX|RDX|EDX|RIP|EIP|IP|RSP|ESP|SP|RSI|ESI|SI|RDI|EDI|DI|RFLAGS|EFLAGS|FLAGS|R(8|9|10|11|12|13|14|15)(d|w|b)?|(Y|X)MM([0-9]|10|11|12|13|14|15)|(A|B|C|D)(X|H|L)|CR[0-4]|DR[0-7]|TR6|TR7|EFER)\b' + scope: variable.parameter.register.assembly + - match: '\b[0-9]+\b' + scope: constant.character.decimal.assembly + - match: '\b(0x)(?i)[A-F0-9]+\b' + scope: constant.character.hexadecimal.assembly + - match: '\b(?i)[A-F0-9]+h\b' + scope: constant.character.hexadecimal.assembly + - match: \b(?i)(0|1)+b\b + scope: constant.character.binary.assembly + - match: ("|').*?("|') + scope: string.assembly + - match: '^\[' + push: + - meta_scope: support.function.directive.assembly + - match: '\]' + pop: true + - match: "(^struc) ([_a-zA-Z][_a-zA-Z0-9]*)" + scope: support.function.directive.assembly + captures: + 2: entity.name.function.assembly + - match: ^endstruc + scope: support.function.directive.assembly + - match: "^%macro ([_a-zA-Z][_a-zA-Z0-9]*) ([0-9]+)" + scope: support.function.directive.assembly + captures: + 1: entity.name.function.assembly + 2: constant.character.assembly + - match: ^%endmacro + scope: support.function.directive.assembly + - match: ^%comment + push: + - meta_scope: comment.assembly + - match: ^%endcomment + pop: true + - match: '\s*(?i)(%define|%ifndef|%xdefine|%idefine|%undef|%assign|%defstr|%strcat|%strlen|%substr|%00|%0|%rotate|%rep|%endrep|%include|\$\$|\$|%unmacro|%if|%elif|%else|%endif|%(el)?ifdef|%(el)?ifmacro|%(el)?ifctx|%(el)?ifidn|%(el)?ifidni|%(el)?ifid|%(el)?ifnum|%(el)?ifstr|%(el)?iftoken|%(el)?ifempty|%(el)?ifenv|%pathsearch|%depend|%use|%push|%pop|%repl|%arg|%stacksize|%local|%error|%warning|%fatal|%line|%!|%comment|%endcomment|__NASM_VERSION_ID__|__NASM_VER__|__FILE__|__LINE__|__BITS__|__OUTPUT_FORMAT__|__DATE__|__TIME__|__DATE_NUM__|_TIME__NUM__|__UTC_DATE__|__UTC_TIME__|__UTC_DATE_NUM__|__UTC_TIME_NUM__|__POSIX_TIME__|__PASS__|ISTRUC|AT|IEND|BITS 16|BITS 32|BITS 64|USE16|USE32|__SECT__|ABSOLUTE|EXTERN|GLOBAL|COMMON|CPU|FLOAT)\b ?([_a-zA-Z][_a-zA-Z0-9]*)?' + captures: + 1: support.function.directive.assembly + 13: entity.name.function.assembly + - match: \b(?i)(d(b|w|d|q|t|o|y)|res(b|w|d|q|t|o)|equ|times|align|alignb|sectalign|section|ptr|byte|word|dword|qword|incbin|)\b + scope: support.function.directive.assembly + - match: (\s)*;.*$ + scope: comment.assembly + - match: '(,|\[|\]|\+|\-|\*)' + scope: source.assembly + - match: '^\s*%%(.-[;])+?:$' + scope: entity.name.function.assembly + - match: '^\s*%\$(.-[;])+?:$' + scope: entity.name.function.assembly + - match: '^\.?(.-[;])+?:$' + scope: entity.name.function.assembly + - match: '^\.?(.-[;])+?\b' + scope: entity.name.function.assembly + - match: .+? + scope: entity.name.function.assembly diff --git a/sublime_syntaxes/Elm.sublime-syntax b/sublime_syntaxes/Elm.sublime-syntax new file mode 100644 index 0000000..9e9eb66 --- /dev/null +++ b/sublime_syntaxes/Elm.sublime-syntax @@ -0,0 +1,200 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Elm +file_extensions: + - elm +scope: source.elm +contexts: + main: + - match: "(`)[a-zA-Z_']*?(`)" + scope: keyword.operator.function.infix.elm + captures: + 1: punctuation.definition.entity.elm + 2: punctuation.definition.entity.elm + - match: \(\) + scope: constant.language.unit.elm + - match: ^\b((effect|port)\s+)?(module)\s+ + captures: + 1: keyword.other.elm + 3: keyword.other.elm + push: + - meta_scope: meta.declaration.module.elm + - match: $|; + captures: + 1: keyword.other.elm + pop: true + - include: module_name + - match: '(where)\s*\{' + captures: + 1: keyword.other.elm + push: + - match: '\}' + pop: true + - include: type_signature + - match: (exposing) + scope: keyword.other.elm + - include: module_exports + - match: (where) + scope: keyword.other.elm + - match: "[a-z]+" + scope: invalid + - match: ^\b(import)\s+((open)\s+)? + captures: + 1: keyword.other.elm + 3: invalid + push: + - meta_scope: meta.import.elm + - match: ($|;) + pop: true + - match: (as|exposing) + scope: keyword.import.elm + - include: module_name + - include: module_exports + - match: '(\[)(glsl)(\|)' + captures: + 1: keyword.other.elm + 2: support.function.prelude.elm + 3: keyword.other.elm + push: + - meta_scope: entity.glsl.elm + - match: '(\|\])' + captures: + 1: keyword.other.elm + pop: true + - include: scope:source.glsl + - match: \b(type alias|type|case|of|let|in|as)\s+ + scope: keyword.other.elm + - match: \b(if|then|else)\s+ + scope: keyword.control.elm + - match: '\b([0-9]+\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+[eE][+-]?[0-9]+)\b' + comment: Floats are always decimal + scope: constant.numeric.float.elm + - match: '\b([0-9]+)\b' + scope: constant.numeric.elm + - match: '"""' + captures: + 0: punctuation.definition.string.begin.elm + push: + - meta_scope: string.quoted.double.elm + - match: '"""' + captures: + 0: punctuation.definition.string.end.elm + pop: true + - match: '\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\''\&])' + scope: constant.character.escape.elm + - match: '\^[A-Z@\[\]\\\^_]' + scope: constant.character.escape.control.elm + - match: '"' + captures: + 0: punctuation.definition.string.begin.elm + push: + - meta_scope: string.quoted.double.elm + - match: '"' + captures: + 0: punctuation.definition.string.end.elm + pop: true + - match: '\\(NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE|DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS|US|SP|DEL|[abfnrtv\\\"''\&])' + scope: constant.character.escape.elm + - match: '\^[A-Z@\[\]\\\^_]' + scope: constant.character.escape.control.elm + - match: |- + (?x) + (') + (?: + [\ -\[\]-~] # Basic Char + | (\\(?:NUL|SOH|STX|ETX|EOT|ENQ|ACK|BEL|BS|HT|LF|VT|FF|CR|SO|SI|DLE + |DC1|DC2|DC3|DC4|NAK|SYN|ETB|CAN|EM|SUB|ESC|FS|GS|RS + |US|SP|DEL|[abfnrtv\\\"'\&])) # Escapes + | (\^[A-Z@\[\]\\\^_]) # Control Chars + ) + (') + scope: string.quoted.single.elm + captures: + 1: punctuation.definition.string.begin.elm + 2: constant.character.escape.elm + 3: punctuation.definition.string.end.elm + - match: '^(port\s+)?([a-z_][a-zA-Z0-9_'']*|\([|!%$+\-.,=]+\))\s*((:)([:]+)?)' + captures: + 1: keyword.other.port.elm + 2: entity.name.function.elm + 4: keyword.other.colon.elm + 5: invalid + push: + - meta_scope: meta.function.type-declaration.elm + - match: $\n? + pop: true + - include: type_signature + - match: \bport\s+ + scope: keyword.other.port.elm + - match: '\b[A-Z]\w*\b' + scope: constant.other.elm + - include: comments + - match: '^[a-z][A-Za-z0-9_'']*\s+' + scope: entity.name.function.elm + - include: infix_op + - match: '[|!%$?~+:\-.=&\\*^]+' + scope: keyword.operator.elm + - match: '([\[\]\{\},])' + scope: constant.language.delimiter.elm + captures: + 1: support.function.delimiter.elm + - match: '([\(\)])' + scope: keyword.other.parenthesis.elm + block_comment: + - match: '\{-(?!#)' + captures: + 0: punctuation.definition.comment.elm + push: + - meta_scope: comment.block.elm + - include: block_comment + - match: '-\}' + captures: + 0: punctuation.definition.comment.elm + pop: true + comments: + - match: (--).*$\n? + scope: comment.line.double-dash.elm + captures: + 1: punctuation.definition.comment.elm + - include: block_comment + infix_op: + - match: '(\([|!%$+:\-.=]+\)|\(,+\))' + scope: entity.name.function.infix.elm + module_exports: + - match: \( + push: + - meta_scope: meta.declaration.exports.elm + - match: \) + pop: true + - match: '\b[a-z][a-zA-Z_''0-9]*' + scope: entity.name.function.elm + - match: '\b[A-Z][A-Za-z_''0-9]*' + scope: storage.type.elm + - match: "," + scope: punctuation.separator.comma.elm + - include: infix_op + - match: \(.*?\) + comment: So named because I don't know what to call this. + scope: meta.other.unknown.elm + module_name: + - match: "[A-Z][A-Za-z._']*" + scope: support.other.module.elm + type_signature: + - match: '\(\s*([A-Z][A-Za-z]*)\s+([a-z][A-Za-z_'']*)\)\s*(=>)' + scope: meta.class-constraint.elm + captures: + 1: entity.other.inherited-class.elm + 2: variable.other.generic-type.elm + 3: keyword.other.big-arrow.elm + - match: "->" + scope: keyword.other.arrow.elm + - match: "=>" + scope: keyword.other.big-arrow.elm + - match: '\b[a-z][a-zA-Z0-9_'']*\b' + scope: variable.other.generic-type.elm + - match: '\b[A-Z][a-zA-Z0-9_'']*\b' + scope: storage.type.elm + - match: \(\) + scope: support.constant.unit.elm + - include: comments diff --git a/sublime_syntaxes/Elm.tmLanguage b/sublime_syntaxes/Elm.tmLanguage new file mode 160000 index 0000000..195e71c --- /dev/null +++ b/sublime_syntaxes/Elm.tmLanguage @@ -0,0 +1 @@ +Subproject commit 195e71c6a70beadea428f684a073aec425a65a81 diff --git a/sublime_syntaxes/Handlebars b/sublime_syntaxes/Handlebars new file mode 160000 index 0000000..63c28f7 --- /dev/null +++ b/sublime_syntaxes/Handlebars @@ -0,0 +1 @@ +Subproject commit 63c28f7aa9360681451779164f40d80f2e70a9cc diff --git a/sublime_syntaxes/Handlebars.sublime-syntax b/sublime_syntaxes/Handlebars.sublime-syntax new file mode 100644 index 0000000..b89574e --- /dev/null +++ b/sublime_syntaxes/Handlebars.sublime-syntax @@ -0,0 +1,473 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Handlebars +file_extensions: + - handlebars + - handlebars.html + - hbr + - hbrs + - hbs + - hdbs + - hjs + - mu + - mustache + - rac + - stache + - template + - tmpl +scope: text.html.handlebars +contexts: + main: + - include: yfm + - include: extends + - include: block_comments + - include: comments + - include: block_helper + - include: end_block + - include: else_token + - include: partial_and_var + - include: inline_script + - include: html_tags + - include: scope:text.html.basic + block_comments: + - match: '\{\{!--' + push: + - meta_scope: comment.block.handlebars + - match: '--\}\}' + pop: true + - match: '@\w*' + scope: keyword.annotation.handlebars + - include: comments + - match: