mastrboy Posted January 23, 2006 Posted January 23, 2006 (edited) since i did not find what i was looking for i starting coding myself:ToDo:- highlight predefined functions- highlight comments- highlight other AI stuff.- make it compatible with PHPbb and PowerInvision Board (2 different files?)- make it secure for html/sql injections.. Bugs:- Escapes one to many /expandcollapse popupfunction autoit_first_pass($string) { // replace /n with <br> $string = nl2br($string); // Array for entities (under testing!!) # $ai_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#'); # $ai_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}'); // Replace enities (under testing!!) # $string = preg_replace($ai_entities_match, $ai_entities_replace, $string); // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines. $string = str_replace(" ", " ", $string); // Replace 2 spaces with " " so non-tabbed code indents without making huge long lines. $string = str_replace(" ", " ", $string); // now Replace 2 spaces with " " to catch odd #s of spaces. $string = str_replace(" ", " ", $string); // Replace tabs with " " so tabbed code indents sorta right without making huge long lines. $string = str_replace("\t", " ", $string); // now Replace space occurring at the beginning of a line $string = preg_replace("/^ {1}/m", ' ', $string); /****** bbcode replace ******/ // define what to be replaced via the preg_replace function (read php manual) $aibb = array('`\[autoit\](.+?)\[/autoit\]`is'); // define what to be replaced by via the preg_replace function (read php manual) $replaceaibb = array('<span style="display: block; padding: 5px; border: 1px dashed; background-color: #CCCCCC;">\\1</span>'); /****** keyword replace ******/ // Define keywords as array (AutoIT 3) $aikeywords = array("continueloop", "and", "byref", "case", "const", "dim", "do", "else", "elseif", "endfunc", "endif", "endselect", "exit", "exitloop", "for", "func", "global", "if", "local", "next", "not", "or", "redim", "return", "select", "step", "then", "to", "until", "wend", "while"); // Run a loop for each keyword foreach($aikeywords as $k => $keyword) { $aikeywordspattern[$k] = "/\b($keyword)\b/is"; $replaceaikeywords[$k] = '<span style="font-weight: bold; color: #0000FF;">\\1</span>'; } /****** macro replace ******/ // Define macros as array (AutoIT 3) $aimacros = array("@appdatacommondir","@appdatadir","@autoitexe","@autoitversion","@commonfilesdir", "@compiled","@computername","@comspec","@cr","@crlf","@desktopcommondir","@desktopdepth","@desktopdir", "@desktopheight","@desktoprefresh","@desktopwidth","@documentscommondir","@error","@extended", "@favoritescommondir","@favoritesdir","@gui_ctrlhandle","@gui_ctrlid","@gui_winhandle","@homedrive", "@homepath","@homeshare","@hour","@inetgetactive","@inetgetbytesread","@ipaddress1","@ipaddress2", "@ipaddress3","@ipaddress4","@lf","@logondnsdomain","@logondomain","@logonserver","@mday","@min", "@mon","@mydocumentsdir","@numparams","@osbuild","@oslang","@osservicepack","@ostype","@osversion", "@programfilesdir","@programscommondir","@programsdir","@scriptdir","@scriptfullpath","@scriptname", "@sec","@startmenucommondir","@startmenudir","@startupcommondir","@startupdir","@sw_disable", "@sw_enable","@sw_hide","@sw_maximize","@sw_minimize","@sw_restore","@sw_show","@sw_showdefault", "@sw_showmaximized","@sw_showminimized","@sw_showminnoactive","@sw_showna","@sw_shownoactivate", "@sw_shownormal","@systemdir","@tab","@tempdir","@username","@userprofiledir","@wday","@windowsdir", "@workingdir","@yday","@year"); // Run a loop for each macro foreach($aimacros as $m => $macro) { $aimacrospattern[$m] = "/($macro)/is"; $replaceaimacros[$m] = '<span style="font-weight: bold; color: #FF33FF;">\\1</span>'; } // Replace the BBCODECONTENT $string = preg_replace($aibb, $replaceaibb , $string); // Replace keywords with highlighted keywords $string = preg_replace($aikeywordspattern, $replaceaikeywords, $string); // Replace macros with highlighted macros $string = preg_replace($aimacrospattern, $replaceaimacros, $string); return $string; }here is a preview: Edited January 24, 2006 by mastrboy -
BigDaddyO Posted January 23, 2006 Posted January 23, 2006 (edited) if you use SciTE as your script editor it does EVERYTHING for you, it's really sweet. Get it HereMike Edited January 23, 2006 by MikeOsdx
herewasplato Posted January 23, 2006 Posted January 23, 2006 if you use SciTE...I think that mastrboy is looking to display AutoIt code on a webpage using PHP. mastrboy would like the webpage to look as "colorful" as the SciTE4AutoIt3 editor. (but I might be wrong) [size="1"][font="Arial"].[u].[/u][/font][/size]
mastrboy Posted January 23, 2006 Author Posted January 23, 2006 I think that mastrboy is looking to display AutoIt code on a webpage using PHP. mastrboy would like the webpage to look as "colorful" as the SciTE4AutoIt3 editor. (but I might be wrong)You are absolutly right It would be so much readable for others, rather than copying it into SCiTE and then reading the code.But the question remains, does this exist? or is it going to be apart of my new webpage project ? it's already done for the PHP language so if anyone want's to give it a try before i do here is something you can use as sort of a template: http://www.isolated-designs.net/stuff/func..._highlight.phps -
w0uter Posted January 23, 2006 Posted January 23, 2006 it would be uber leet if the [ / code ] tags would have syntax coloring My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
mastrboy Posted January 23, 2006 Author Posted January 23, 2006 (edited) i could not find anything after hours of googling so i started myself here is first progress, currently it only highlights keywords, but more to come ops: i will not implement highlighting of predefined and user-defined function, it's just to much work. function autoit($string) { // replaces \n with <br> $string = nl2br($string); /****** bbcode replace ******/ // define what to be replaced via the preg_replace function (read php manual) $aibb = array('`\[autoit\](.+?)\[/autoit\]`is'); // define what to be replaced by via the preg_replace function (read php manual) $replaceaibb = array('<span style="padding: 5px; border: 1px dashed; background-color: #CCCCCC;">\\1</span>'); /****** keyword replace ******/ // Define keywords as array (AutoIT 3) $aikeywords = array("continueloop", "and", "byref", "case", "const", "dim", "do", "else", "elseif", "endfunc", "endif", "endselect", "exit", "exitloop", "for", "func", "global", "if", "local", "next", "not", "or", "redim", "return", "select", "step", "then", "to", "until", "wend", "while"); // Run a loop for each keyword foreach($aikeywords as $k => $keyword) { $aikeywordspattern[$k] = "/\b($keyword)\b/is"; $replaceaikeywords[$k] = '<span style="font-weight: bold; color: #0000FF;">\\1</span>'; } // Replace the BBCODECONTENT $string = preg_replace($aibb, $replaceaibb , $string); $string = preg_replace($aikeywordspattern, $replaceaikeywords, $string); return $string; } btw; im going to use SCiTE's coloring... Edited January 23, 2006 by mastrboy -
w0uter Posted January 23, 2006 Posted January 23, 2006 maby you could adapt au3.keywords.properties from scite for your use. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
Valik Posted January 24, 2006 Posted January 24, 2006 SciTE can export as HTML and the document will retain all it's syntax highlighting.
mastrboy Posted January 24, 2006 Author Posted January 24, 2006 (edited) - Edited May 2, 2017 by mastrboy -
mastrboy Posted January 24, 2006 Author Posted January 24, 2006 (edited) - Edited May 2, 2017 by mastrboy -
Valik Posted January 24, 2006 Posted January 24, 2006 but it would look like shit in a database and increase the size.And if you want to edit the post after it's posted you'l get pure html instead of just autoit code surrounded by bbcode tags Nobody said store it. What I had in mind was using php to run SciTE in the background on the server and have it export a file as HTML. Then in you read the exported HTML file and display it. You can either write a Lua script in SciTE which on startup will do what you want or you might even be able to get away with using SciTE's command line. And since SciTE runs on Windows or Linux, there's a good chance your server can spawn it if you're able to get it on the machine.Basically all I'm suggesting is using PHP to drive SciTE to do the syntax highlighting instead of re-writing a syntax highlighter from scratch.
Developers Jos Posted January 24, 2006 Developers Posted January 24, 2006 anyone know what font SCiTE is using?It depends what you have defined for $(font.monospace) in SciTEUser.properties.The Font.base is used when not using MONOSPACE font else whatever you defened for $(font.monospace)# Give symbolic names to the set of fonts used in the standard styles.if PLAT_WIN font.base=font:Verdana,size:10,$(font.override) font.small=font:Verdana,size:9,$(font.override) font.comment=font:Tahoma,size:10,$(font.override) font.code.comment.box=$(font.comment),$(font.override) font.code.comment.line=$(font.comment),$(font.override) font.code.comment.doc=$(font.comment),$(font.override) font.text=font:Verdana,size:10,$(font.override) font.text.comment=font:Verdana,size:10,$(font.override) font.embedded.base=font:Verdana,size:10,$(font.override) font.embedded.comment=font:Comic Sans MS,size:10,$(font.override) font.vbs=font:Lucida Sans Unicode,size:10,$(font.override) font.monospace=font:Courier New,size:10 font.override=$(font.monospace)html.properties contain the syntax highlight info for PHP:# PHP# Defaultstyle.hypertext.118=fore:#000033,back:#FFF8F8,eolfilled# Double quoted Stringstyle.hypertext.119=fore:#007F00,back:#FFF8F8# Single quoted stringstyle.hypertext.120=fore:#009F00,back:#FFF8F8# Keywordstyle.hypertext.121=fore:#7F007F,italics,back:#FFF8F8# Numberstyle.hypertext.122=fore:#CC9900,back:#FFF8F8# Variablestyle.hypertext.123=fore:#00007F,italics,back:#FFF8F8# Commentstyle.hypertext.124=fore:#999999,$(font.comment),back:#FFF8F8# One line commentstyle.hypertext.125=fore:#666666,italics,$(font.comment),back:#FFF8F8# PHP variable in double quoted stringstyle.hypertext.126=fore:#007F00,italics,back:#FFF8F8# PHP operatorstyle.hypertext.127=fore:#000000,back:#FFF8F8 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mastrboy Posted January 24, 2006 Author Posted January 24, 2006 (edited) - Edited May 2, 2017 by mastrboy -
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now