fixing a lot of (\s) vs (\s|[()]) bugs

This commit is contained in:
Andrew Danger Lyon 2013-03-21 16:35:34 -07:00
parent 8c54bdecd6
commit 5137e9bda2

View file

@ -263,7 +263,7 @@ var highlight_lisp = function() {
// "special" (let/lambda) // "special" (let/lambda)
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
{ {
regex: new RegExp('.'+list_to_regex(special)+'(\\s)', 'gm'), regex: new RegExp('.'+list_to_regex(special)+'(\\s|[()])', 'gm'),
replace: function(fullmatch, fnname, whitespace) { replace: function(fullmatch, fnname, whitespace) {
if(fullmatch[0] == '(') if(fullmatch[0] == '(')
{ {
@ -282,7 +282,7 @@ var highlight_lisp = function() {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// known functions // known functions
{ {
regex: new RegExp('.'+list_to_regex(funcs)+'(\\s)', 'gm'), regex: new RegExp('.'+list_to_regex(funcs)+'(\\s|[()])', 'gm'),
replace: function(fullmatch, fnname, whitespace) { replace: function(fullmatch, fnname, whitespace) {
if(fullmatch[0] == '(') if(fullmatch[0] == '(')
{ {
@ -311,15 +311,16 @@ var highlight_lisp = function() {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// lambda keywords // lambda keywords
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
{regex: new RegExp('(\\s)'+list_to_regex(lambda)+'(\\s)', 'gm'), replace: '$1<span class="lambda-list">$2</span>$3'}, {regex: new RegExp('(\\s|[()])'+list_to_regex(lambda)+'(\\s|[()])', 'gm'), replace: '$1<span class="lambda-list">$2</span>$3'},
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// symbols/keywords/variables // symbols/keywords/variables
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// known keywords // generic symbols
{regex: /(\s|[()])('\w[\w_-]*)(\s|[()])/g, replace: '$1<span class="symbol">$2</span>$3'}, {regex: /(\s|[()])('\w[\w_-]*)(\s|[()])/g, replace: '$1<span class="symbol">$2</span>$3'},
// known keywords
{ {
regex: new RegExp('(\\s)'+list_to_regex(keywords)+'(\\s)', 'g'), regex: new RegExp('(\\s|[()])'+list_to_regex(keywords)+'(\\s|[()])', 'g'),
replace: function(fullmatch, whitespace, keyword, whitespace2) { replace: function(fullmatch, whitespace, keyword, whitespace2) {
return whitespace + '<span class="keyword known">'+ keyword +'</span>'+ whitespace2; return whitespace + '<span class="keyword known">'+ keyword +'</span>'+ whitespace2;
} }
@ -366,7 +367,7 @@ var highlight_lisp = function() {
{regex: /(\s|[()])t(\s|[()])/g, replace: '$1<span class="nil">t</span>$2'}, {regex: /(\s|[()])t(\s|[()])/g, replace: '$1<span class="nil">t</span>$2'},
// generic "maybe a function" forms. best second to last // generic "maybe a function" forms. best second to last
{regex: /\((\w[\w_:-]*)(\s)/g, replace: '(<span class="function">$1</span>$2'}, {regex: /\((\w[\w_:-]*)(\s|[()])/g, replace: '(<span class="function">$1</span>$2'},
// ()'s (should most probably be last, unless there's a good reason) // ()'s (should most probably be last, unless there's a good reason)
{regex: /([()])/g, replace: '<span class="list">$1</span>'} {regex: /([()])/g, replace: '<span class="list">$1</span>'}