Re: [O] Tidy automatically HTML files

2014-06-25 Thread Bastien


Sebastien Vauban sva-news-D0wtAvR13HarG/idocf...@public.gmane.org
writes:

 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?

What's wrong is that

(with-output-to-string (shell-command-on-region ...))

will not give you what you want, since the output of
(shell-command-on-region ...) is not sent to standard-output.

-- 
 Bastien




[O] Tidy automatically HTML files

2014-06-19 Thread Sebastien Vauban
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