From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Tidy automatically HTML files Date: Thu, 19 Jun 2014 13:34:00 +0200 Message-ID: <86bntpm8uv.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Hello, I'm trying to add Tidy to the HTML export process, so that files are more easy to read and, possibly, to diff. The code I wrote seems correct to me in theory: --8<---------------cut here---------------start------------->8--- ;; check that `tidy' is in PATH, and that configuration file exists (when (and (executable-find "tidy") (file-exists-p "~/.tidyrc")) (defun sva--export-html-final-filter (contents backend info) (if (not (eq backend 'html)) contents (with-output-to-string (insert contents) (shell-command-on-region (point-min) (point-max) "tidy -config ~/.tidyrc" t t "*Tidy errors*" t)))) (add-to-list 'org-export-filter-final-output-functions 'sva--export-html-final-filter)) --8<---------------cut here---------------end--------------->8--- In practice, it isn't, as the results of `shell-command-on-region' is the empty string. Though, when executed interactively on an HTML buffer, it does work as expected. I don't get what's wrong... Maybe one of you can have an idea? Best regards, Seb -- Sebastien Vauban