Revision: 23890
          http://sourceforge.net/p/bibdesk/svn/23890
Author:   hofman
Date:     2019-06-22 15:13:22 +0000 (Sat, 22 Jun 2019)
Log Message:
-----------
add mathjax code as tex to arxiv titles and abstract

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

Modified: trunk/bibdesk/BDSKArxivParser.m
===================================================================
--- trunk/bibdesk/BDSKArxivParser.m     2019-06-22 14:26:40 UTC (rev 23889)
+++ trunk/bibdesk/BDSKArxivParser.m     2019-06-22 15:13:22 UTC (rev 23890)
@@ -233,11 +233,7 @@
         // search for title
         node = [arxivMetaNode singleNodeForXPathExpression:titleNodePath];
         if (node) {
-            if ((string = [node stringValuePreservingBreaks])) {
-                if ([string hasPrefix:@"Title:"])
-                    string = [string substringFromIndex:6];
-                while ([string hasPrefix:@" "])
-                    string = [string substringFromIndex:1];
+            if ((string = [[node stringValuePreservingMathJax] 
stringByRemovingSurroundingWhitespace])) {
                 [pubFields setValue:string forKey:BDSKTitleString];
             }
         }
@@ -283,9 +279,7 @@
         // search for abstract
         node = [arxivMetaNode singleNodeForXPathExpression:abstractNodePath];
         if (node) {
-            if ((string = [node stringValuePreservingBreaks])) {
-                if (isAbstract && [string hasPrefix:@"Abstract: "])
-                    string = [string substringFromIndex:10];
+            if ((string = [[node stringValuePreservingMathJax] 
stringByRemovingSurroundingWhitespaceAndNewlines])) {
                 if (isSearch && [string hasSuffix:@"\u25B3 Less"])
                     string = [[string substringToIndex:[string length] - 6] 
stringByRemovingSurroundingWhitespaceAndNewlines];
                 [pubFields setValue:string forKey:BDSKAbstractString];

Modified: trunk/bibdesk/DOMNode_BDSKExtensions.h
===================================================================
--- trunk/bibdesk/DOMNode_BDSKExtensions.h      2019-06-22 14:26:40 UTC (rev 
23889)
+++ trunk/bibdesk/DOMNode_BDSKExtensions.h      2019-06-22 15:13:22 UTC (rev 
23890)
@@ -47,7 +47,7 @@
 - (DOMNode *)singleNodeForXPathExpression:(DOMXPathExpression 
*)xpathExpression;
 
 - (NSString *)stringValue;
-- (NSString *)stringValuePreservingBreaks;
+- (NSString *)stringValuePreservingMathJax;
 - (NSString *)stringValueOfAttribute:(NSString *)attrName;
 
 @end

Modified: trunk/bibdesk/DOMNode_BDSKExtensions.m
===================================================================
--- trunk/bibdesk/DOMNode_BDSKExtensions.m      2019-06-22 14:26:40 UTC (rev 
23889)
+++ trunk/bibdesk/DOMNode_BDSKExtensions.m      2019-06-22 15:13:22 UTC (rev 
23890)
@@ -86,7 +86,7 @@
     return [[self textContent] 
stringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]
 ?: @"";
 }
 
-- (NSString *)stringValuePreservingBreaks {
+- (NSString *)stringValuePreservingMathJax {
     DOMNodeList *children = [self childNodes];
     NSUInteger i, iMax = [children length];
     
@@ -98,13 +98,17 @@
     for (i = 0; i < iMax; i++) {
         DOMNode *node = [children item:i];
         short type = [node nodeType];
-        if (type != DOM_ELEMENT_NODE && type != DOM_TEXT_NODE) continue;
+        if (type != DOM_TEXT_NODE && (type != DOM_ELEMENT_NODE || [[node 
nodeName] isCaseInsensitiveEqual:@"span"])) continue;
         if (type == DOM_ELEMENT_NODE && [[node nodeName] 
isCaseInsensitiveEqual:@"br"]) {
             [string appendString:@"\n"];
-        } else if (type == DOM_TEXT_NODE || [[node nodeName] 
isCaseInsensitiveEqual:@"script"] == NO) {
-            NSString *s = [node stringValuePreservingBreaks];
-            if ([s length])
-                [string appendString:s];
+        } else {
+            NSString *s = [node stringValuePreservingMathJax];
+            if ([s length]) {
+                if (type == DOM_ELEMENT_NODE && [[node nodeName] 
isCaseInsensitiveEqual:@"script"])
+                    [string appendFormat:@"$%@$", s];
+                else
+                    [string appendString:s];
+            }
         }
     }
     return string;

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