New highlighter for Ruby's ERB and HTML embedded ERB

Ruby code inside ERB tags (whether in plain or HTML environment) is highlighted
via the ruby.jsf colorer.
This commit is contained in:
cn 2011-10-04 21:26:20 +02:00
parent 4d138ffec2
commit 09bdf55037
5 changed files with 74 additions and 1 deletions

31
erb.jsf Normal file
View File

@ -0,0 +1,31 @@
# JOE syntax highlight file for plain ERB
=Idle
=Keyword bold
=Bad bold red
=Brace magenta
=ERB yellow
:content Idle
* content
"<" maybe_erb_start
:maybe_erb_start Idle
* content noeat
"%" maybe_erb_eq recolor=-2
:maybe_erb_eq ERB
* rtn_ruby noeat call=ruby.ruby(erb)
"=" rtn_ruby call=ruby.ruby(erb)
:rtn_ruby ERB
* content noeat
:erb ERB
* erb
"%" maybe_erb_end
:maybe_erb_end ERB
* erb
">" content

View File

@ -860,3 +860,11 @@
-syntax whitespace -syntax whitespace
--force --force
--spaces --spaces
plain ERB
*.erb
-syntax erb
.html.erb
*.html.erb
-syntax htmlerb

View File

@ -81,11 +81,18 @@
.else .else
"?" xml_pi recolor=-2 "?" xml_pi recolor=-2
.endif .endif
.ifdef erb
"%" maybe_erb_eq
.endif
# this state allows php and perl to recolor the ?> %> or &> properly. # this state allows php and perl to recolor the ?> %> or &> properly.
:rtn_php TagEdge :rtn_php TagEdge
* idle noeat * idle noeat
:maybe_erb_eq TagEdge
* rtn_php noeat call=ruby.ruby(erb)
"=" rtn_php call=ruby.ruby(erb)
:tag_name_first Mystery :tag_name_first Mystery
* tag_idle noeat * tag_idle noeat
"-A-Za-z0-9._:" tag_name recolor=-1 "-A-Za-z0-9._:" tag_name recolor=-1

11
htmlerb.jsf Normal file
View File

@ -0,0 +1,11 @@
# JOE syntax highlight file for HTML embedded ERB
=Idle
=Keyword bold
=Bad bold red
=Brace magenta
=ERB yellow
:begin Idle
* NULL noeat call=html.html(erb)

View File

@ -27,11 +27,13 @@
# Detect pod # Detect pod
:idle Idle :idle Idle
* rest noeat * NULL noeat call=.ruby()
"=" pod_start "=" pod_start
# Rest of line # Rest of line
.subr ruby
:rest Idle :rest Idle
* rest * rest
"#" line_comment recolor=-1 "#" line_comment recolor=-1
@ -59,7 +61,16 @@
:after_term Idle :after_term Idle
* rest noeat * rest noeat
" \t)" after_term " \t)" after_term
.ifdef erb
"/" rest
"%" after_term_erb_end
.else
"/%" rest "/%" rest
.endif
:after_term_erb_end Idle
* rest noeat
">" NULL recolor=-2 return
:pod_start Idle :pod_start Idle
* pod_start * pod_start
@ -430,6 +441,9 @@ done
* match noeat * match noeat
" \t" after_term noeat " \t" after_term noeat
"xrqQw" match "xrqQw" match
.ifdef erb
">" NULL recolor=-2 return
.endif
:match Idle :match Idle
* inmatch save_c recolor=-1 * inmatch save_c recolor=-1
@ -539,6 +553,8 @@ done
* rest noeat * rest noeat
"a-zA-Z0-9_" global_var "a-zA-Z0-9_" global_var
.end
.subr comment_todo .subr comment_todo
# initial state # initial state
:comment_todo_init Comment :comment_todo_init Comment