Fix `org-my-html-svg-contents' error reporting and clean up

Gerard Vermeulen 2023-06-04 22:22:57 +02:00
parent 59bc902bdb
commit 8857f4c45a
1 changed files with 5 additions and 6 deletions

View File

@ -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."
(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 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))