Syntax highlighting using Mediawiki formatting: Difference between revisions
Content added Content deleted
m (→{{header|Phix}}: oops, not htmlifying string/comment contents properly) |
m (→{{header|Phix}}: elsif) |
||
Line 381: | Line 381: | ||
''-- or(/for javascript compatibility) specify constant pgm = """...""" '' |
''-- or(/for javascript compatibility) specify constant pgm = """...""" '' |
||
'''constant''' qqq = `""`&`"`, ''/* (split to assist with permitting ^^^) */'' |
'''constant''' qqq = `""`&`"`, ''/* (split to assist with permitting ^^^) */'' |
||
keywords = {`and`,`assert`,`bool`,`command_line`,`constant`,`do`,`else`,` |
keywords = {`and`,`assert`,`bool`,`command_line`,`constant`,`do`,`else`,`elsif`,`end`, |
||
`for`,`function`,`get_text`,`if`,`in`,`integer`,`length`,`match`,`not |
`find`,`for`,`function`,`get_text`,`if`,`in`,`integer`,`length`,`match`,`not`, |
||
`puts`,`return`,`sequence`,`string`,`substitute`,`then`,`wait_key`,`while`}, |
`procedure`,`puts`,`return`,`sequence`,`string`,`substitute`,`then`,`wait_key`,`while`}, |
||
htmlify = {"'&<>",{`apos`,`amp`,`lt`,`gt`}} |
htmlify = {"'&<>",{`apos`,`amp`,`lt`,`gt`}} |
||
'''integer''' i = 1, l = '''length'''(pgm), word_start = 0 |
'''integer''' i = 1, l = '''length'''(pgm), word_start = 0 |
||
Line 424: | Line 424: | ||
spacenl(pgm[line_comment..i]) |
spacenl(pgm[line_comment..i]) |
||
out &= `''` |
out &= `''` |
||
elsif ch='/' '''and''' i<l '''and''' pgm[i+1]='*' '''then''' |
'''elsif''' ch='/' '''and''' i<l '''and''' pgm[i+1]='*' '''then''' |
||
'''integer''' block_comment = i |
'''integer''' block_comment = i |
||
i = '''match'''(`*/`,pgm,i+2)+1 |
i = '''match'''(`*/`,pgm,i+2)+1 |
||
Line 431: | Line 431: | ||
spacenl(pgm[block_comment..i]) |
spacenl(pgm[block_comment..i]) |
||
out &= `''` |
out &= `''` |
||
elsif ch='"' '''then''' |
'''elsif''' ch='"' '''then''' |
||
'''if''' i+1<l '''and''' pgm[i..i+2]=qqq '''then''' |
'''if''' i+1<l '''and''' pgm[i..i+2]=qqq '''then''' |
||
i = do_string(i,'''match'''(qqq,pgm,i+3),2,"triple") |
i = do_string(i,'''match'''(qqq,pgm,i+3),2,"triple") |
||
Line 437: | Line 437: | ||
i = do_string(i,'''find'''('"',pgm,i+1),0,"double") |
i = do_string(i,'''find'''('"',pgm,i+1),0,"double") |
||
'''end''' '''if''' |
'''end''' '''if''' |
||
elsif '''find'''(ch,"`'") '''then''' |
'''elsif''' '''find'''(ch,"`'") '''then''' |
||
'''string''' stype = iff(ch='`'?"backtick":"single") |
'''string''' stype = iff(ch='`'?"backtick":"single") |
||
i = do_string(i,'''find'''(ch,pgm,i+1),0,stype) |
i = do_string(i,'''find'''(ch,pgm,i+1),0,stype) |