Revision: 23897
          http://sourceforge.net/p/bibdesk/svn/23897
Author:   hofman
Date:     2019-06-26 15:17:32 +0000 (Wed, 26 Jun 2019)
Log Message:
-----------
trim surrounding whitespace in category method

Modified Paths:
--------------
    trunk/bibdesk/BDSKArxivParser.m
    trunk/bibdesk/DOMNode_BDSKExtensions.m

Modified: trunk/bibdesk/BDSKArxivParser.m
===================================================================
--- trunk/bibdesk/BDSKArxivParser.m     2019-06-26 06:30:26 UTC (rev 23896)
+++ trunk/bibdesk/BDSKArxivParser.m     2019-06-26 15:17:32 UTC (rev 23897)
@@ -105,10 +105,11 @@
     DOMXPathExpression *abstractNodePath = nil;
     
     if (isAbstract) {
-        arxivIDNodePath = [[self domDocument] 
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell 
arxivid']/span[@class='arxivid']/a[contains(text(),'arXiv:')]" resolver:nil];
+        arxivLinkNodePath = [[self domDocument] 
createExpression:@"./div[@class='metatable']/table" resolver:nil];
         
-        pdfURLNodePath = [[self domDocument] 
createExpression:@"../../../div[@class='extra-services']/div[@class='full-text']/ul/li/a[contains(text(),'PDF')]"
 resolver:nil];
-        doiNodePath = [[self domDocument] 
createExpression:@"./div[@class='metatable']/table//td[@class='tablecell 
doi']/a" resolver:nil];
+        arxivIDNodePath = [[self domDocument] 
createExpression:@".//td[@class='tablecell 
arxivid']/span[@class='arxivid']/a[contains(text(),'arXiv:')]" resolver:nil];
+        pdfURLNodePath = [[self domDocument] 
createExpression:@"../../../../../div[@class='extra-services']/div[@class='full-text']/ul/li/a[contains(text(),'PDF')]"
 resolver:nil];
+        doiNodePath = [[self domDocument] 
createExpression:@".//td[@class='tablecell doi']/a" resolver:nil];
         
         titleNodePath = [[self domDocument] 
createExpression:@"./h1[contains(concat(' ',normalize-space(@class),' '),' 
title ')]" resolver:nil];
         authorsNodePath = [[self domDocument] 
createExpression:@"./div[@class='authors']/a" resolver:nil];
@@ -116,8 +117,8 @@
         abstractNodePath = [[self domDocument] 
createExpression:@"./blockquote[contains(concat(' ',normalize-space(@class),' 
'),' abstract ')]" resolver:nil];
     } else if (isSearch) {
         arxivLinkNodePath = [[self domDocument] 
createExpression:@"./div[@class='is-marginless']/p[contains(concat(' 
',normalize-space(@class),' '),' list-title ')]" resolver:nil];
+        
         arxivIDNodePath = [[self domDocument] 
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
-        
         pdfURLNodePath = [[self domDocument] 
createExpression:@"./span/a[contains(text(),'pdf')]" resolver:nil];
         doiNodePath = [[self domDocument] 
createExpression:@"../div/div/span[contains(text(),'doi')]/following-sibling::span/a"
 resolver:nil];
         
@@ -127,8 +128,8 @@
         abstractNodePath = [[self domDocument] 
createExpression:@"./p[contains(concat(' ',normalize-space(@class),' '),' 
abstract ')]/span[contains(concat(' ',normalize-space(@class),' '),' 
abstract-full ')]" resolver:nil];
     } else if (isList) {
         arxivLinkNodePath = [[self domDocument] 
createExpression:@"./span[@class='list-identifier']" resolver:nil];
+        
         arxivIDNodePath = [[self domDocument] 
createExpression:@"./a[contains(text(),'arXiv:')]" resolver:nil];
-        
         pdfURLNodePath = [[self domDocument] 
createExpression:@"./a[contains(text(),'pdf')]" resolver:nil];
         doiNodePath = [[self domDocument] 
createExpression:@"./div[@class='list-doi']/span/following-sibling::text()" 
resolver:nil];
         
@@ -233,7 +234,7 @@
         // search for title
         node = [arxivMetaNode singleNodeForXPathExpression:titleNodePath];
         if (node) {
-            if ((string = [[node stringValuePreservingMathJax] 
stringByRemovingSurroundingWhitespace])) {
+            if ((string = [node stringValuePreservingMathJax])) {
                 [pubFields setValue:string forKey:BDSKTitleString];
             }
         }
@@ -279,7 +280,7 @@
         // search for abstract
         node = [arxivMetaNode singleNodeForXPathExpression:abstractNodePath];
         if (node) {
-            if ((string = [[node stringValuePreservingMathJax] 
stringByRemovingSurroundingWhitespaceAndNewlines])) {
+            if ((string = [node stringValuePreservingMathJax])) {
                 if (isSearch && [string hasSuffix:@"\u25B3 Less"])
                     string = [[string substringToIndex:[string length] - 6] 
stringByRemovingSurroundingWhitespaceAndNewlines];
                 [pubFields setValue:string forKey:BDSKAbstractString];

Modified: trunk/bibdesk/DOMNode_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/DOMNode_BDSKExtensions.m      2019-06-26 06:30:26 UTC (rev 
23896)
+++ trunk/bibdesk/DOMNode_BDSKExtensions.m      2019-06-26 15:17:32 UTC (rev 
23897)
@@ -86,7 +86,7 @@
     return [[self textContent] 
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]
 ?: @"";
 }
 
-- (NSString *)stringValuePreservingMathJax {
+- (NSString *)stringValuePreservingMathJaxNoTrim {
     DOMNodeList *children = [self childNodes];
     NSUInteger i, iMax = [children length];
     
@@ -102,7 +102,7 @@
         if (type == DOM_ELEMENT_NODE && [[node nodeName] 
isCaseInsensitiveEqual:@"br"]) {
             [string appendString:@"\n"];
         } else {
-            NSString *s = [node stringValuePreservingMathJax];
+            NSString *s = [node stringValuePreservingMathJaxNoTrim];
             if ([s length]) {
                 if (type == DOM_ELEMENT_NODE && [[node nodeName] 
isCaseInsensitiveEqual:@"script"])
                     [string appendFormat:@"$%@$", s];
@@ -114,6 +114,10 @@
     return string;
 }
 
+- (NSString *)stringValuePreservingMathJax {
+    return [[self stringValuePreservingMathJaxNoTrim] 
stringByRemovingSurroundingWhitespace];
+}
+
 - (NSString *)stringValueOfAttribute:(NSString *)attrName {
     if ([self nodeType] != DOM_ELEMENT_NODE)
         return nil;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to