[44] | 1 | /*
|
---|
| 2 | * CodePress regular expressions for ASP-vbscript syntax highlighting
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | // ASP VBScript
|
---|
| 6 | Language.syntax = [
|
---|
| 7 | // all tags
|
---|
| 8 | { input : /(<[^!%|!%@]*?>)/g, output : '<b>$1</b>' },
|
---|
| 9 | // style tags
|
---|
| 10 | { input : /(<style.*?>)(.*?)(<\/style>)/g, output : '<em>$1</em><em>$2</em><em>$3</em>' },
|
---|
| 11 | // script tags
|
---|
| 12 | { input : /(<script.*?>)(.*?)(<\/script>)/g, output : '<ins>$1</ins><ins>$2</ins><ins>$3</ins>' },
|
---|
| 13 | // strings "" and attributes
|
---|
| 14 | { input : /\"(.*?)(\"|<br>|<\/P>)/g, output : '<s>"$1$2</s>' },
|
---|
| 15 | // ASP Comment
|
---|
| 16 | { input : /\'(.*?)(\'|<br>|<\/P>)/g, output : '<dfn>\'$1$2</dfn>'},
|
---|
| 17 | // <%.*
|
---|
| 18 | { input : /(<%)/g, output : '<strong>$1' },
|
---|
| 19 | // .*%>
|
---|
| 20 | { input : /(%>)/g, output : '$1</strong>' },
|
---|
| 21 | // <%@...%>
|
---|
| 22 | { input : /(<%@)(.+?)(%>)/gi, output : '$1<span>$2</span>$3' },
|
---|
| 23 | //Numbers
|
---|
| 24 | { input : /\b([\d]+)\b/g, output : '<var>$1</var>' },
|
---|
| 25 | // Reserved Words 1 (Blue)
|
---|
| 26 | { input : /\b(And|As|ByRef|ByVal|Call|Case|Class|Const|Dim|Do|Each|Else|ElseIf|Empty|End|Eqv|Exit|False|For|Function)\b/gi, output : '<a>$1</a>' },
|
---|
| 27 | { input : /\b(Get|GoTo|If|Imp|In|Is|Let|Loop|Me|Mod|Enum|New|Next|Not|Nothing|Null|On|Option|Or|Private|Public|ReDim|Rem)\b/gi, output : '<a>$1</a>' },
|
---|
| 28 | { input : /\b(Resume|Select|Set|Stop|Sub|Then|To|True|Until|Wend|While|With|Xor|Execute|Randomize|Erase|ExecuteGlobal|Explicit|step)\b/gi, output : '<a>$1</a>' },
|
---|
| 29 | // Reserved Words 2 (Purple)
|
---|
| 30 | { input : /\b(Abandon|Abs|AbsolutePage|AbsolutePosition|ActiveCommand|ActiveConnection|ActualSize|AddHeader|AddNew|AppendChunk)\b/gi, output : '<u>$1</u>' },
|
---|
| 31 | { input : /\b(AppendToLog|Application|Array|Asc|Atn|Attributes|BeginTrans|BinaryRead|BinaryWrite|BOF|Bookmark|Boolean|Buffer|Byte)\b/gi, output : '<u>$1</u>' },
|
---|
| 32 | { input : /\b(CacheControl|CacheSize|Cancel|CancelBatch|CancelUpdate|CBool|CByte|CCur|CDate|CDbl|Charset|Chr|CInt|Clear)\b/gi, output : '<u>$1</u>' },
|
---|
| 33 | { input : /\b(ClientCertificate|CLng|Clone|Close|CodePage|CommandText|CommandType|CommandTimeout|CommitTrans|CompareBookmarks|ConnectionString|ConnectionTimeout)\b/gi, output : '<u>$1</u>' },
|
---|
| 34 | { input : /\b(Contents|ContentType|Cookies|Cos|CreateObject|CreateParameter|CSng|CStr|CursorLocation|CursorType|DataMember|DataSource|Date|DateAdd|DateDiff)\b/gi, output : '<u>$1</u>' },
|
---|
| 35 | { input : /\b(DatePart|DateSerial|DateValue|Day|DefaultDatabase|DefinedSize|Delete|Description|Double|EditMode|Eof|EOF|err|Error)\b/gi, output : '<u>$1</u>' },
|
---|
| 36 | { input : /\b(Exp|Expires|ExpiresAbsolute|Filter|Find|Fix|Flush|Form|FormatCurrency|FormatDateTime|FormatNumber|FormatPercent)\b/gi, output : '<u>$1</u>' },
|
---|
| 37 | { input : /\b(GetChunk|GetLastError|GetRows|GetString|Global|HelpContext|HelpFile|Hex|Hour|HTMLEncode|IgnoreCase|Index|InStr|InStrRev)\b/gi, output : '<u>$1</u>' },
|
---|
| 38 | { input : /\b(Int|Integer|IsArray|IsClientConnected|IsDate|IsolationLevel|Join|LBound|LCase|LCID|Left|Len|Lock|LockType|Log|Long|LTrim)\b/gi, output : '<u>$1</u>' },
|
---|
| 39 | { input : /\b(MapPath|MarshalOptions|MaxRecords|Mid|Minute|Mode|Month|MonthName|Move|MoveFirst|MoveLast|MoveNext|MovePrevious|Name|NextRecordset)\b/gi, output : '<u>$1</u>' },
|
---|
| 40 | { input : /\b(Now|Number|NumericScale|ObjectContext|Oct|Open|OpenSchema|OriginalValue|PageCount|PageSize|Pattern|PICS|Precision|Prepared|Property)\b/gi, output : '<u>$1</u>' },
|
---|
| 41 | { input : /\b(Provider|QueryString|RecordCount|Redirect|RegExp|Remove|RemoveAll|Replace|Requery|Request|Response|Resync|Right|Rnd)\b/gi, output : '<u>$1</u>' },
|
---|
| 42 | { input : /\b(RollbackTrans|RTrim|Save|ScriptTimeout|Second|Seek|Server|ServerVariables|Session|SessionID|SetAbort|SetComplete|Sgn)\b/gi, output : '<u>$1</u>' },
|
---|
| 43 | { input : /\b(Sin|Size|Sort|Source|Space|Split|Sqr|State|StaticObjects|Status|StayInSync|StrComp|String|StrReverse|Supports|Tan|Time)\b/gi, output : '<u>$1</u>' },
|
---|
| 44 | { input : /\b(Timeout|Timer|TimeSerial|TimeValue|TotalBytes|Transfer|Trim|Type|Type|UBound|UCase|UnderlyingValue|UnLock|Update|UpdateBatch)\b/gi, output : '<u>$1</u>' },
|
---|
| 45 | { input : /\b(URLEncode|Value|Value|Version|Weekday|WeekdayName|Write|Year)\b/gi, output : '<u>$1</u>' },
|
---|
| 46 | // Reserved Words 3 (Turquis)
|
---|
| 47 | { input : /\b(vbBlack|vbRed|vbGreen|vbYellow|vbBlue|vbMagenta|vbCyan|vbWhite|vbBinaryCompare|vbTextCompare)\b/gi, output : '<i>$1</i>' },
|
---|
| 48 | { input : /\b(vbSunday|vbMonday|vbTuesday|vbWednesday|vbThursday|vbFriday|vbSaturday|vbUseSystemDayOfWeek)\b/gi, output : '<i>$1</i>' },
|
---|
| 49 | { input : /\b(vbFirstJan1|vbFirstFourDays|vbFirstFullWeek|vbGeneralDate|vbLongDate|vbShortDate|vbLongTime|vbShortTime)\b/gi, output : '<i>$1</i>' },
|
---|
| 50 | { input : /\b(vbObjectError|vbCr|VbCrLf|vbFormFeed|vbLf|vbNewLine|vbNullChar|vbNullString|vbTab|vbVerticalTab|vbUseDefault|vbTrue)\b/gi, output : '<i>$1</i>' },
|
---|
| 51 | { input : /\b(vbFalse|vbEmpty|vbNull|vbInteger|vbLong|vbSingle|vbDouble|vbCurrency|vbDate|vbString|vbObject|vbError|vbBoolean|vbVariant)\b/gi, output : '<i>$1</i>' },
|
---|
| 52 | { input : /\b(vbDataObject|vbDecimal|vbByte|vbArray)\b/gi, output : '<i>$1</i>' },
|
---|
| 53 | // html comments
|
---|
| 54 | { input : /(<!--.*?-->.)/g, output : '<big>$1</big>' }
|
---|
| 55 | ]
|
---|
| 56 |
|
---|
| 57 | Language.Functions = [
|
---|
| 58 | // Output at index 0, must be the desired tagname surrounding a $1
|
---|
| 59 | // Name is the index from the regex that marks the functionname
|
---|
| 60 | {input : /(function|sub)([ ]*?)(\w+)([ ]*?\()/gi , output : '<ins>$1</ins>', name : '$3'}
|
---|
| 61 | ]
|
---|
| 62 |
|
---|
| 63 | Language.snippets = [
|
---|
| 64 | //Conditional
|
---|
| 65 | { input : 'if', output : 'If $0 Then\n\t\nEnd If' },
|
---|
| 66 | { input : 'ifelse', output : 'If $0 Then\n\t\n\nElse\n\t\nEnd If' },
|
---|
| 67 | { input : 'case', output : 'Select Case $0\n\tCase ?\n\tCase Else\nEnd Select'},
|
---|
| 68 | //Response
|
---|
| 69 | { input : 'rw', output : 'Response.Write( $0 )' },
|
---|
| 70 | { input : 'resc', output : 'Response.Cookies( $0 )' },
|
---|
| 71 | { input : 'resb', output : 'Response.Buffer'},
|
---|
| 72 | { input : 'resflu', output : 'Response.Flush()'},
|
---|
| 73 | { input : 'resend', output : 'Response.End'},
|
---|
| 74 | //Request
|
---|
| 75 | { input : 'reqc', output : 'Request.Cookies( $0 )' },
|
---|
| 76 | { input : 'rq', output : 'Request.Querystring("$0")' },
|
---|
| 77 | { input : 'rf', output : 'Request.Form("$0")' },
|
---|
| 78 | //FSO
|
---|
| 79 | { input : 'fso', output : 'Set fso = Server.CreateObject("Scripting.FileSystemObject")\n$0' },
|
---|
| 80 | { input : 'setfo', output : 'Set fo = fso.getFolder($0)' },
|
---|
| 81 | { input : 'setfi', output : 'Set fi = fso.getFile($0)' },
|
---|
| 82 | { input : 'twr', output : 'Set f = fso.CreateTextFile($0,true)\'overwrite\nf.WriteLine()\nf.Close'},
|
---|
| 83 | { input : 'tre', output : 'Set f = fso.OpenTextFile($0, 1)\nf.ReadAll\nf.Close'},
|
---|
| 84 | //Server
|
---|
| 85 | { input : 'mapp', output : 'Server.Mappath($0)' },
|
---|
| 86 | //Loops
|
---|
| 87 | { input : 'foreach', output : 'For Each $0 in ?\n\t\nNext' },
|
---|
| 88 | { input : 'for', output : 'For $0 to ? step ?\n\t\nNext' },
|
---|
| 89 | { input : 'do', output : 'Do While($0)\n\t\nLoop' },
|
---|
| 90 | { input : 'untilrs', output : 'do until rs.eof\n\t\nrs.movenext\nloop' },
|
---|
| 91 | //ADO
|
---|
| 92 | { input : 'adorec', output : 'Set rs = Server.CreateObject("ADODB.Recordset")' },
|
---|
| 93 | { input : 'adocon', output : 'Set Conn = Server.CreateObject("ADODB.Connection")' },
|
---|
| 94 | { input : 'adostr', output : 'Set oStr = Server.CreateObject("ADODB.Stream")' },
|
---|
| 95 | //Http Request
|
---|
| 96 | { input : 'xmlhttp', output : 'Set xmlHttp = Server.CreateObject("Microsoft.XMLHTTP")\nxmlHttp.open("GET", $0, false)\nxmlHttp.send()\n?=xmlHttp.responseText' },
|
---|
| 97 | { input : 'xmldoc', output : 'Set xmldoc = Server.CreateObject("Microsoft.XMLDOM")\nxmldoc.async=false\nxmldoc.load(request)'},
|
---|
| 98 | //Functions
|
---|
| 99 | { input : 'func', output : 'Function $0()\n\t\n\nEnd Function'},
|
---|
| 100 | { input : 'sub', output : 'Sub $0()\n\t\nEnd Sub'}
|
---|
| 101 |
|
---|
| 102 | ]
|
---|
| 103 |
|
---|
| 104 | Language.complete = [
|
---|
| 105 | //{ input : '\'', output : '\'$0\'' },
|
---|
| 106 | { input : '"', output : '"$0"' },
|
---|
| 107 | { input : '(', output : '\($0\)' },
|
---|
| 108 | { input : '[', output : '\[$0\]' },
|
---|
| 109 | { input : '{', output : '{\n\t$0\n}' }
|
---|
| 110 | ]
|
---|
| 111 |
|
---|
| 112 | Language.shortcuts = [
|
---|
| 113 | { input : '[space]', output : ' ' },
|
---|
| 114 | { input : '[enter]', output : '<br />' } ,
|
---|
| 115 | { input : '[j]', output : 'testing' },
|
---|
| 116 | { input : '[7]', output : '&' }
|
---|
| 117 | ]
|
---|