Jump to content
Muxe Inc Forums
Sign in to follow this  
dandv

Syntax highlights

Recommended Posts

dandv    0

The XML highlight is wrong because STRINGFLAGS is set to 160, of which 32 means do not highlight strings in apostrophes.

But, according to the XML 1.0 specification at http://www.w3.org/TR/2000/REC-xml-20001006...#sec-common-syn ,

strings can be quoted with both ' and " :

AttValue    ::=    '"' ([^<&"] | Reference)* '"'  
|  "'" ([^<&'] | Reference)* "'"

so the correct STRINGFLAGS value for XML is just 128.

 

The HTML comments currently is

Comment <! >

, which yields very weird results on the following piece of html:

 

-       align=center>Copyright <symbol name=Copyright><!--begin!{{-->x<!--}}end!--> 2004 Medical Systems. All rights reserved. <!--kadov_tag{{<spaces>}}-->  <!--kadov_tag{{</spaces>}}-->P/N 100017344-01</p> </div>
+       align=center>Copyright <symbol name=Copyright><!--begin!{{-->x<!--}}end!--> 2004 Medical Systems. Tous droits rΘservΘs. <!--kadov_tag{{<spaces>}}-->  <!--kadov_tag{{</spaces>}}-->P/N 100017344-01</p> </div>

 

(highlight stops in the middle of a word; if you delete the first "+" or "-" on the line, the 'x' will lose its highlight etc.)

AH, can you check the cause of this before correcting the HTML comment to

Comment <!-- -->

(according to the W3C spec at http://www.w3.org/TR/REC-html40/intro/sgml...t.html#h-3.2.4)

 

Here is a quite powerful syntax highlighter for Perl, my favorite programming language.

;----------------------------------------------------------------------------

; PERL Files

;----------------------------------------------------------------------------

FILES *.PL;*.PM

GeneralFlags 81

StringFlags 131

CommentString #

Comment __END__ a_unique_string_because_there_is_no_end_of_such_comment

MultilineComment 1

Keywords1 cmp,eq,gt,lt,ne

Keywords1 and,not,or,xor

Keywords1 continue,do,else,elsif,for,foreach,goto,if,last,next,return,

Keywords1 unless,until,while

Keywords1 package,sub,

Keywords1 require,use,x

Keywords1 local,my,our

Keywords2 __LINE__, __FILE__

 

Keywords2 abs,atan2,cos,exp,int,log,rand,sin,sqrt,srand

Keywords2 pop, push, shift, splice, unshift

Keywords2 delete, each, exists, keys, values

Keywords2 grep,join,map,reverse,sort

Keywords2 defined,scalar,ref,undef,wantarray

 

Keywords2 seek, sysread, sysseek, syswrite, tell, truncate,

 

Keywords2 binmode, close, eof, fileno, flock, open, rename, select, unlink, utime

 

Keywords2 eval,exit,die, glob,

 

Keywords2 read, readline, print, printf, warn

 

Keywords2 alarm,sleep

Keywords2 pos,quotemeta,split,

Keywords2 chomp,chop,index,lc,length,sprintf,substr,uc

Keywords2 localtime,gmtime,time

Keywords2 pack,unpack,vec,chr,ord,hex,ord

 

Keywords3 $_,@_,$!

 

RegKeywords COLOR LightBlue \$[0-9]+

RegKeywords COLOR Yellow \$([a-zA-Z][_a-zA-Z0-9]*|_[_a-zA-Z0-9]+)

RegKeywords COLOR LightMagenta @([a-zA-Z][_a-zA-Z0-9]*|_[_a-zA-Z0-9]+)

RegKeywords COLOR LightCyan [_a-zA-Z0-9]+ *(?==>)

 

; To play the macro: CTRL+J 1

Macro 1

Print '#! perl -w'^M'use strict;'^M^M

EndMacro

Macro 2

Print 'while (<>) {'^M^M'}'^M#5#5' '

EndMacro

END

 

 

And here is a definition for PHP files:

;================================================================

; PHP files: GENERALFLAGS = case sensitive + C numbers; Comments: #, //

;================================================================

 

FILES *.PHP

GeneralFLAGS 16

STRINGFLAGS 7

CommentString #, //

MultiLineComment 1

Comment /* */

Keywords1 as,else,for,foreach,function,global,if,return,xor,

Keywords1 array,list

Keywords2 array_slice,array_pop

Keywords2 date

Keywords2 define

Keywords2 echo,print,print_r,sprintf,error_log,trigger_error

Keywords2 fclose,file,fopen,fwrite,is_readable,readfile

Keywords2 basename

Keywords2 isset,is_null,mktime

Keywords2 setcookie

Keywords2 implode,explode,bin2hex,crc32,md5,str_pad,strlen,trim,strstr,strpos

Keywords2 preg_match

Keywords2 error_reporting,set_error_handler

 

 

RegKeywords COLOR Yellow \$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*

Share this post


Link to post
Share on other sites

hi again

(hehe, you were quite busy today Dan :P)

 

XML

oh, nice, i will add that

(that happens if someone who doesn't use a language tries to add support for it)

 

HTML

a recent highlight fix also fixes your posted bug :)

and i will correct the comments (this is old, who added the html?)

 

thanks for the other 2 hgl entries

 

Stefan / AH

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×