Revision: 12807
http://sourceforge.net/p/skim-app/code/12807
Author: hofman
Date: 2022-03-16 14:40:43 +0000 (Wed, 16 Mar 2022)
Log Message:
-----------
Attempt to remove and combine hyphenated words from cleaned string of selection
spanning multiple lines
Modified Paths:
--------------
trunk/PDFSelection_SKExtensions.m
Modified: trunk/PDFSelection_SKExtensions.m
===================================================================
--- trunk/PDFSelection_SKExtensions.m 2022-03-02 10:24:05 UTC (rev 12806)
+++ trunk/PDFSelection_SKExtensions.m 2022-03-16 14:40:43 UTC (rev 12807)
@@ -77,7 +77,21 @@
}
- (NSString *)compactedCleanedString {
- return [[[[[self selectionsByLine] valueForKey:@"string"]
componentsJoinedByString:@" "] stringByRemovingAliens]
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+ NSArray *lines = [self selectionsByLine];
+ if ([lines count] < 2)
+ return [[[self string] stringByRemovingAliens]
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+ NSMutableString *string = [NSMutableString string];
+ for (PDFSelection *line in lines) {
+ NSString *str = [[[line string] stringByRemovingAliens]
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines];
+ if ([str length] == 0) continue;
+ NSInteger l = [string length];
+ if (l > 1 && [string characterAtIndex:l - 1] == '-' &&
[[NSCharacterSet letterCharacterSet] characterIsMember:[string
characterAtIndex:l - 2]])
+ [string deleteCharactersInRange:NSMakeRange(l - 1, 1)];
+ else if (l > 0)
+ [string appendString:@" "];
+ [string appendString:str];
+ }
+ return string;
}
- (NSString *)cleanedString {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit