From 2b59cf9e90194eb74ac4145c5199643c4dde4a64 Mon Sep 17 00:00:00 2001 From: cn Date: Wed, 19 Oct 2011 20:34:20 +0200 Subject: [PATCH] Brand new Haml highlighter The main features of Haml can be correctly parsed according to http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html. There exist some limitations inherently comming from the limitations of state machine based highlighters (without side effects)... this parsers sucks with multiline comments, strings etc since the indent based grouping can't be evaluated. --- ftyperc | 11 +++++- haml.jsf | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ruby.jsf | 8 ++++ 3 files changed, 133 insertions(+), 1 deletion(-) create mode 100644 haml.jsf diff --git a/ftyperc b/ftyperc index 9d85be2..700b472 100644 --- a/ftyperc +++ b/ftyperc @@ -866,6 +866,15 @@ *.erb -syntax erb - .html.erb + ERB within HTML *.html.erb -syntax htmlerb + + Haml +*.haml +-syntax haml +-istep 2 +-indentc 32 +-autoindent +-smarthome +-smartbacks diff --git a/haml.jsf b/haml.jsf new file mode 100644 index 0000000..96ee0c1 --- /dev/null +++ b/haml.jsf @@ -0,0 +1,115 @@ +# JOE syntax highlight file for Haml + +=Idle +=Comment green +=Constant cyan +=Escape bold cyan +=Bad bold red +=Brace magenta + +=Tag fg_310 +=Class yellow +=Id green +=Doctype bold magenta +=Filter blue + +:line_start Idle + * idle noeat + # eat indent + " " line_start + "\\" escape_first recolor=-1 + "!" doctype1 + "%" tag recolor=-1 + # implicit
+ ".#" after_tag noeat + "/" html_comment recolor=-1 + ":" filter recolor=-1 + +:escape_first Constant + * idle + +:idle Constant + * idle + "\n" line_start + "=~-" ruby_call noeat + "&!" maybe_esc_ruby_call + "#" maybe_subst + "\\" maybe_subst_escape + +:doctype1 Idle + * idle recolor=-2 + "=" esc_ruby_call recolor=-2 + "!" doctype2 + +:doctype2 Idle + * idle recolor=-3 + "!" doctype3 recolor=-3 + +:doctype3 Doctype + * doctype3 + "\n" line_start + +:tag Tag + * idle noeat + "a-zA-Z0-9_-" tag + ".#{(/" after_tag noeat + +:after_tag Idle + * idle noeat + "." class recolor=-1 + "#" id recolor=-1 + "{" attrA + "(" attrB + "/" tag_close recolor=-1 + +:class Class + * after_tag noeat + "a-zA-Z0-9_-" class + +:id Id + * after_tag noeat + "a-zA-Z0-9_-" id + +:attrA Idle + * attrA + "}" after_tag + +:attrB Idle + * attrB + ")" after_tag + +:tag_close Tag + * idle noeat + +:html_comment Comment + * html_comment + "\n" line_start + +:ruby_call Idle + * line_start call=ruby.ruby(haml) + +:maybe_esc_ruby_call Constant + * idle + "=" esc_ruby_call recolor=-2 + +:esc_ruby_call Idle + * line_start call=ruby.ruby(haml) + "=" esc_ruby_call2 + +:esc_ruby_call2 Idle + * line_start call=ruby.ruby(haml) + +:maybe_subst Constant + * idle + "{" subst recolor=-2 + +:subst Escape + * subst + "}" idle + +:maybe_subst_escape Constant + * idle + +:filter Filter + * idle + "a-zA-Z0-9_" filter diff --git a/ruby.jsf b/ruby.jsf index 2b671e0..4b78454 100644 --- a/ruby.jsf +++ b/ruby.jsf @@ -40,7 +40,11 @@ :rest Idle * rest "#" line_comment recolor=-1 +.ifdef haml + "\n" NULL return +.else "\n" idle +.endif "{}" brace recolor=-1 "0" first_digit recolor=-1 "1-9" decimal recolor=-1 @@ -183,7 +187,11 @@ done .endif # might be TODO label "BFHNTX" line_comment noeat call=.comment_todo() +.ifdef haml + "\n" NULL return +.else "\n" idle +.endif :line_comment_maybe_erb_end Comment ">" NULL recolor=-2 return