Fix `org-my-html-svg-contents' error reporting and clean up
This commit is contained in:
parent
59bc902bdb
commit
8857f4c45a
@ -38,7 +38,6 @@
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'ox-html)
|
||||
(require 'nxml-mode)
|
||||
|
||||
|
||||
;;; Define Backend
|
||||
@ -117,13 +116,13 @@ lists of SVG files to include in and/or to exclude from embedding."
|
||||
|
||||
(defun org-my-html-svg-contents (path)
|
||||
"Return the SVG contents of the file named PATH."
|
||||
;; https://emacs.stackexchange.com/a/57433
|
||||
(with-temp-buffer
|
||||
(insert-file-contents path)
|
||||
(with-syntax-table nxml-mode-syntax-table
|
||||
;; Barf if contents contains no valid SVG.
|
||||
(while (and (search-forward "<svg")
|
||||
(nth 8 (syntax-ppss)))))
|
||||
;; Delete text preceding something starting as an SVG root element.
|
||||
;; See https://emacs.stackexchange.com/a/57433 the for original code.
|
||||
(let ((case-fold-search t))
|
||||
(unless (search-forward "<svg" nil 'noerror)
|
||||
(user-error "Can't find an SVG root element in file `%s'." path)))
|
||||
(delete-region (point-min) (match-beginning 0))
|
||||
(buffer-string)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user