Last active
December 21, 2015 13:09
-
-
Save nikitaeverywhere/6310513 to your computer and use it in GitHub Desktop.
SuperRegular expression for breaking Caché code to lexical parts. It can be improved!
Supports ##class, $Method/$Var, $$MyMethod, $$$Macro, ^Global, ..ClassMethod, %SystemClass, "strings", 016175, {[()]}.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function breaks code for parts with span tags and according styles, but skips &*; html-symbol combinations and tag <br> | |
* | |
* @param string | |
* String to parse. | |
* @returns {string} | |
* Parsed string. | |
*/ | |
this.highlightHTML = function(string) { | |
return string.replace(/(\/\*.*?(?=\*\/)\*\/)|([0-9]+\.?[0-9]+?)|(((<|&|&#)|(\^%?)|\/|\${0,3}|#{0,2}|%|\.|(\.\.))?[A-Za-z0-9]+[;>]?)|[{}\]\[\(\)!_'\\#\?\+\-\*\/=<>,]|("[^"]*")/g, | |
function(part) { | |
return "<span class=\"syntax" + somePart_parsing_function(part) + "\">" + part + "</span>"; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment