Skip to content

Commit

Permalink
Change: --html-to-org-with-pandoc uses unwind-protect to delete file
Browse files Browse the repository at this point in the history
  • Loading branch information
c1-g committed Feb 16, 2023
1 parent ef75f41 commit dcae2a5
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions org-web-tools.el
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,20 @@ When SELECTOR is non-nil, the HTML is filtered using
(with-temp-buffer
(insert html)
(let ((err-file (make-temp-file "org-web-tools-pandoc-err")))
(if (not (zerop (call-process-region (point-min) (point-max) "pandoc"
t (list t err-file) nil
"--verbose"
(org-web-tools--pandoc-no-wrap-option)
"-f" "html-raw_html-native_divs" "-t" "org")))
;; TODO: Add error output, see org-protocol-capture-html
(progn (delete-region (point-min) (point-max))
(goto-char (point-min))
(insert-file-contents err-file)
(error "Pandoc: %s" (buffer-string)))
(org-web-tools--clean-pandoc-output)
(delete-file err-file)
(buffer-string)))))
(unwind-protect
(if (not (zerop (call-process-region (point-min) (point-max) "pandoc"
t (list t err-file) nil
"--verbose"
(org-web-tools--pandoc-no-wrap-option)
"-f" "html-raw_html-native_divs" "-t" "org")))
;; TODO: Add error output, see org-protocol-capture-html
(progn (delete-region (point-min) (point-max))
(goto-char (point-min))
(insert-file-contents err-file)
(error "Pandoc: %s" (buffer-string)))
(org-web-tools--clean-pandoc-output)
(buffer-string))
(delete-file err-file)))))

(defun org-web-tools--pandoc-no-wrap-option ()
"Return option `org-web-tools--pandoc-no-wrap-option', setting if unset."
Expand Down

0 comments on commit dcae2a5

Please sign in to comment.