Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IPython Syntax Highlighting for `ne` (the Nice Editor) and JOE (Joe's Own Editor).
# IPython Highlighting for ne and JOE.
=Idle
=Comment white
=Docstring green
=DocstringLabel magenta
=DocEscape bold yellow
=StringLiteral green
=Constant magenta
=Escape bold yellow
=Keyword bold
=Bad bold red
=Brace
=PrivateMember yellow
=Decorator red
=Declaration bold blue
=IpTag bold magenta
=IpString magenta
:maybe_ip Idle
* idle noeat
" \t" maybe_ip
"!%" ip_tag noeat
:ip_tag IpTag
* ip_string noeat
"!%" ip_tag
:ip_string IpString
* ip_string
"\n" maybe_ip
:idle Idle
* idle
"#" comment recolor=-1
"0-9" first_digit recolor=-1
"'\"" string_quot_1 recolor=-1 save_c
"a-za-z_" ident noeat
"{}" brace recolor=-1
"@" decorator recolor=-1
"=\n" maybe_ip
:brace Brace
* idle noeat
# annotations
:decorator Decorator
* decorator
" (\t\r\n" idle noeat
:comment Comment
* comment
"BFHNTX" comment noeat call=comment_todo.comment_todo()
"\n" idle noeat
:first_digit Constant
* idle noeat
"xX" hex
"." float
"eE" epart
"0-9" first_number
:hex Constant
* idle noeat
"0-9A-Fa-f" hex
:first_number Constant
* idle noeat
"0-9" first_number
"." float
:maybe_float Constant
* idle recolor=-2 noeat
"0-9" float recolor=-2
:float Constant
* idle noeat
"eE" epart
"0-9" float
:epart Constant
* idle noeat
"0-9+\-" enum
:enum Constant
* idle noeat
"0-9" enum
:ident Idle
* ident1 noeat buffer
"_" priv_member recolor=-1
:ident1 Idle
* idle noeat strings
"and" kw
"as" kw
"assert" kw
"break" kw
"class" declkw
"continue" kw
"def" declkw
"del" kw
"elif" kw
"else" kw
"except" kw
"exec" kw
"finally" kw
"for" kw
"from" kw
"global" kw
"if" kw
"import" kw
"in" kw
"is" kw
"lambda" kw
"not" kw
"nonlocal" kw
"or" kw
"pass" kw
"print" kw
"raise" kw
"return" kw
"try" kw
"while" kw
"with" kw
"yield" kw
"False" lit
"None" lit
"True" lit
done
"'\"" idle noeat istrings
"u" string_pre
"b" string_pre
"r" string_raw_pre
"br" string_raw_pre
"rb" string_raw_pre
done
"a-zA-Z0-9_" ident1
:kw Keyword
* idle noeat
:lit Keyword
* idle noeat
:declkw Keyword
* idle noeat recolor=-1
"a-zA-Z" declkw
" \t" declname_1
:declname_1 Declaration
* declname
"_" priv_member recolor=-1
:declname Declaration
* idle noeat recolor=-1
"a-zA-Z0-9_" declname
:priv_member PrivateMember
* idle noeat
"a-zA-Z0-9_" priv_member
# Handle string prefixes up to the string itself.
:string_pre StringLiteral
* idle noeat
"'\"" string_quot_1 save_c
:string_raw_pre StringLiteral
* idle noeat
"'\"" string_quot_raw_1 save_c
# Differentiate between docstrings and regular strings, carrying with it raw state
:string_quot_1 StringLiteral
* idle call=.string() noeat
& string_quot_2
:string_quot_2 StringLiteral
* idle noeat
& idle call=.string(docstring) recolor=-3
:string_quot_raw_1 StringLiteral
* idle call=.string(raw)
& string_quot_raw_2
:string_quot_raw_2 StringLiteral
* idle noeat
& idle call=.string(docstring raw) recolor=-3
.subr string
.ifdef docstring # Long strings
:string Docstring
* string
"BFHNTX" string noeat call=.comment_todo_docstr()
.ifdef raw
.else
"\\" string_esc mark
.endif
& doc_end_1
:doc_end_1 Docstring
* string noeat
& doc_end_2
:doc_end_2 Docstring
* string noeat
& string return
.else # Short strings
:string StringLiteral
* string
"\n" string return
.ifdef raw
.else
"\\" string_esc mark
.endif
& string return
.endif
:string_esc StringLiteral
* string_esc_done
"x" string_hex2
"u" string_hex4
"U" string_hex8
"0-7" string_octal2
"\n" string_esc_done
# Recolor whole escape sequence based on whether this is a docstring.
:string_esc_done Constant
* string_esc_really_done noeat markend recolormark
.ifdef docstring
:string_esc_really_done DocEscape
* string noeat
.else
:string_esc_really_done Escape
* string noeat
.endif
:string_hex1 Escape
* string_esc_done noeat
"0-9a-fA-F" string_esc_done
:string_hex2 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex1
:string_hex3 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex2
:string_hex4 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex3
:string_hex5 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex4
:string_hex6 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex5
:string_hex7 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex6
:string_hex8 Escape
* string_esc_done noeat
"0-9a-fA-F" string_hex7
:string_octal1 Escape
* string_esc_done noeat
"0-7" string_esc_done
:string_octal2 Escape
* string_esc_done noeat
"0-7" string_octal1
.end
.subr comment_todo_docstr
# initial state
:comment_todo_init Docstring
* comment_todo_guess buffer
# highlight common TODO labels
:comment_todo_guess Docstring
* comment_todo_unknown noeat strings
"BUG" comment_todo
"FIXME" comment_todo
"HACK" comment_todo
"NOTE" comment_todo
"TODO" comment_todo
done
"A-Z" comment_todo_guess
:comment_todo_unknown Docstring
* NULL noeat return
:comment_todo DocstringLabel
* NULL noeat return
.end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.