emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Tidy automatically HTML files
@ 2014-06-19 11:34 Sebastien Vauban
  2014-06-25  9:17 ` Bastien
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastien Vauban @ 2014-06-19 11:34 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Tidy automatically HTML files
  2014-06-19 11:34 Tidy automatically HTML files Sebastien Vauban
@ 2014-06-25  9:17 ` Bastien
  0 siblings, 0 replies; 2+ messages in thread
From: Bastien @ 2014-06-25  9:17 UTC (permalink / raw)
  To: Sebastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ



Sebastien Vauban <sva-news-D0wtAvR13HarG/iDocfnWg@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-25  9:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-19 11:34 Tidy automatically HTML files Sebastien Vauban
2014-06-25  9:17 ` Bastien

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).