Ivan Andrus avatar Ivan Andrus committed 5e49d9c

Fixed recognition of pretty_print output
Fixes bitbucket issue #12

Comments (0)

Files changed (1)


   :type 'string
   :group 'sage-view)
-(defvar sage-view-start-string "<html><span class=\"math\">"
+(defvar sage-view-start-string "<html><\\(?:script type=\"math/tex\"\\)>"
   "HTML tags that identify the begining of a math formula in Sage
-(defvar sage-view-final-string "</span></html>"
+(defvar sage-view-final-string "</\\(?:span\\|script\\)></html>"
   "HTML tags that identify the end of a math formula in Sage
 See also `sage-view-output-filter'."
   (goto-char (point-min))
-  (while (search-forward sage-view-start-string (point-max) t)
-    (let* ((beg (point))
-	   (end (- (search-forward sage-view-final-string (point-max) t)
-		   (length sage-view-final-string)))
-	   (text (buffer-substring-no-properties beg end))
-	   (ov (make-overlay (- beg (length sage-view-start-string))
-			     (+ end (length sage-view-final-string))
-			     nil nil nil))
-	   (map (make-sparse-keymap)))
+  (while (re-search-forward sage-view-start-string (point-max) t)
+    (let* ((header-beg (match-beginning 0))
+           (header-end (match-end 0))
+           (footer-beg (when (re-search-forward sage-view-final-string (point-max) t)
+                         (match-beginning 0)))
+           (footer-end (match-end 0))
+           (text (buffer-substring-no-properties header-end footer-beg))
+           (ov (make-overlay header-beg
+                             footer-end
+                             nil nil nil))
+           (map (make-sparse-keymap)))
       (overlay-put ov 'help-echo "mouse-3: Open contextual menu")
       (overlay-put ov 'math text)
+      (overlay-put ov 'display (format "Typesetting %s..." text))
       (define-key map [mouse-3]
-	`(lambda (event) (interactive "e")
-	   (sage-view-context-menu ,ov event)))
+        `(lambda (event) (interactive "e")
+           (sage-view-context-menu ,ov event)))
       (overlay-put ov 'keymap map)
       (sage-view-process-overlay ov))))
       (when sage-view-inline-plots-enabled
 	(sage-view-output-filter-process-inline-plots string))
       (when (and sage-view-inline-output-enabled
-		 (string-match (regexp-quote sage-view-final-string) string))
+		 (string-match sage-view-final-string string))
 	(sage-view-output-filter-process-inline-output string)))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.