aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-06-21 23:08:52 +0000
committerrowanbeentje <rowan@beent.je>2012-06-21 23:08:52 +0000
commitfcf1e1e527e35c824449f40289a799c809c9a1a4 (patch)
tree05e963aab264cfe9ae33f184f7a971b643fbe831 /Source
parent1a139c2094b927e0db747a171183cef0e34bf650 (diff)
downloadsequelpro-fcf1e1e527e35c824449f40289a799c809c9a1a4.tar.gz
sequelpro-fcf1e1e527e35c824449f40289a799c809c9a1a4.tar.bz2
sequelpro-fcf1e1e527e35c824449f40289a799c809c9a1a4.zip
- Fix exceptions with certain kinds of help results, for example for most mathematical operators
- Add support for more help links
Diffstat (limited to 'Source')
-rw-r--r--Source/SPCustomQuery.m37
1 files changed, 6 insertions, 31 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 07dae0ed..0bb182dd 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -3111,37 +3111,12 @@
if(safeCnt > 200)
break;
}
- // detect and generate mysql links for "[HELP keyword]"
- aRange = NSMakeRange(0,0);
- safeCnt = 0;
- while(1){
- // TODO how to catch in HELP 'grant' last see [HELP SHOW GRANTS] ?? it's ridiculous
- aRange = [desc rangeOfRegex:@"\\[HELP ([^ ]*?)\\]" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length+53, [desc length]-53-aRange.location-aRange.length) capture:1 error:&err1];
- if(aRange.location != NSNotFound) {
- aUrl = [[desc substringWithRange:aRange] stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
- [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"<a title='%@ “%@”' href='%@' class='internallink'>%@</a>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]];
- }
- else
- break;
- safeCnt++;
- if(safeCnt > 200)
- break;
- }
- // detect and generate mysql links for capitalzed letters
- // aRange = NSMakeRange(0,0);
- // safeCnt = 0;
- // while(1){
- // aRange = [desc rangeOfRegex:@"(?<!\\w)([A-Z_]{2,}( [A-Z_]{2,})?)" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length, [desc length]-aRange.location-aRange.length) capture:1 error:&err1];
- // if(aRange.location != NSNotFound) {
- // aUrl = [desc substringWithRange:aRange];
- // [desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"<a title='%@ “%@”' href='%@' class='internallink'>%@</a>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for"), aUrl, aUrl, aUrl]];
- // }
- // else
- // break;
- // safeCnt++;
- // if(safeCnt > 200)
- // break;
- // }
+
+ // Detect and generate cross-links. First, handle the old-style [HELP ...] text.
+ [desc replaceOccurrencesOfRegex:@"\\[HELP ([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"<a title='%@ “$1”' href='$1' class='internallink'>[$1]</a>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for")]];
+
+ // Handle "see [...]" and "in [...]"-style 5.x links.
+ [desc replaceOccurrencesOfRegex:@"(See|see|In|in|and)\\s+\\[(?:HELP )?([^\\]]*?)\\]" withString:[NSString stringWithFormat:@"$1 <a title='%@ “$2”' href='$2' class='internallink'>[$2]</a>", NSLocalizedString(@"Show MySQL help for", @"show mysql help for")]];
[theHelp appendFormat:@"<pre class='description'>%@</pre>", desc];
}