Menu

[7d5c33]: / syntax / css.jsf  Maximize  Restore  History

Download this file

170 lines (134 with data), 2.9 kB

# JOE syntax highlight file for CSS
# by Eric Lin

# Define colors

=Idle
=Comment
=Constant
=Number		+Constant
=Escape
=Keyword
=Bad

=Class		+Type
=Id		+String +DefinedIdent
=Tag
=HTML		# TODO: Get back to this when going over html, xml, php, ant, etc

# from html.jsf to support <?php?>
=TagEdge

:begin Idle
	*		begin		noeat call=.css()

#
# For <style> in html
#

.subr css

:reset HTML
	*		reset
	"<"		maybe_done	recolor=-1
	"/"		slash
	# prevent duplicate code
	"#.a-zA-Z"	selector	noeat
	"@"		command		recolor=-1

:maybe_done TagEdge
	*		reset_html	noeat
	"/"		reset		noeat return recolor=-2
.ifdef php
	"?%"		rtn_php		call=php.php()
.endif

# fix needed to produce similar output without php
:reset_html HTML
	*		reset		noeat recolor=-2

# this state allows php and perl to recolor the ?> %> or &> properly.
:rtn_php TagEdge
	*		reset		noeat

:slash Idle
	*		reset		noeat
	"*"		comment		recolor=-2

:comment Comment comment
	*		comment
	"*"		maybe_end_comment

:maybe_end_comment Comment comment
	*		comment
	"/"		reset
	"*"		maybe_end_comment

:command Idle
	*		command
	";"		reset
	"{"		command_block

:command_block Idle
	*		command_block
	"}"		reset

# CSS selectors
:selector Idle
	*		selector
	"#"		id_sel		recolor=-1
	"."		class_sel	recolor=-1
	"a-zA-Z"	tag_sel		recolor=-1
	":"		pseudo_class_sel	recolor=-1
	"{"		style_block	recolor=-1

:id_sel Id
	*		selector	noeat
	"a-zA-Z0-9_-"	id_sel

:class_sel Class
	*		selector	noeat
	"a-zA-Z0-9_-"	class_sel

:tag_sel Tag
	*		selector	noeat
	"a-zA-Z0-9_-"	tag_sel
	"["		tag_sel_attr	recolor=-1

:tag_sel_attr Idle
	*		tag_sel_attr
	"]"		selector

:pseudo_class_sel Idle
	*		selector	noeat
	"a-zA-Z0-9_-"	pseudo_class_sel

# everything inside "{ ... }", containing many "key: value;" pairs
:style_block Idle
	*		style_block
	"}"		reset
	"/"		maybe_style_comment
	"a-zA-Z-"	style_word	recolor=-1

:maybe_style_comment Idle
	*		style_block	recolor=-1
	"*"		style_comment	recolor=-2

:style_comment Comment comment
	*		style_comment
	"*"		maybe_end_style_comment
  
:maybe_end_style_comment Comment comment
	*		comment
	"/"		style_block
	"*"		maybe_end_style_comment

# property-key
:style_word Keyword
	*		style_word
	":"		style_value	recolor=-1

# property-value
:style_value Idle
	*		style_value
	";"		style_block
	# treat } without previous ; like ;}
	"}"		style_block	noeat
	"#"		color		recolor=-1
	"0-9"		decimal		recolor=-1
	"."		maybe_float
	"a-zA-Z_"	ident

:color Constant
	*		style_value	noeat
	"0-9a-fA-F"	color

:decimal Number
	*		style_value	noeat
	"0-9"		decimal
	"."		float
	"a-zA-Z%"	decimal_unit

:maybe_float Number
	*		style_value	noeat recolor=-2
	"0-9"		float		recolor=-2

:float Number
	*		style_value	noeat
	"0-9"		float
	"a-zA-Z%"	decimal_unit

:decimal_unit Number
	*		style_value	noeat
	"a-zA-Z"	decimal_unit

:ident Idle
	*		style_value	noeat
	"a-ZA-Z0-9_-"	ident

.end
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.