help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: viewing docx files


From: Tomas Nordin
Subject: Re: viewing docx files
Date: Mon, 30 Jan 2017 22:49:49 +0100

Tomas Nordin <tomasn@posteo.net> writes:

> Devin Prater <r.d.t.prater@gmail.com> writes:
>
>> Hi all. I'm running Gnu-Emacs (latest brew install emacs version) on MacOS 
>> Sierra. I run Emacs in the terminal, and use the Emacspeak package for 
>> access, since I am blind. I received an email (gnews), with an attachment, 
>> two docx files for reading. I was able to download the attachments to my ~/ 
>> directory. I opened the file (c-x c-f then tab completion), but it opened 
>
> I wonder if you would like to eval and try this:
>
> (defun docx2html (file)
>   "Convert FILE to html in a buffer and display it."
>   (interactive "f")
>   (let ((html-buffer (format "*%s --> html*" file)))
>     (call-process "pandoc" file html-buffer nil "--to=html")
>     (switch-to-buffer html-buffer))
>   )

Here is an updated version tested on my machine to work on all files
docx I can find. I have been assuming that you mean that it is a good
thing to have a buffer with hyper text markup. This version is ignoring
error output and provide the file as an argument to pandoc instead of
providing it as stdin. One should have pandoc version >= 1.13, I had an
older version before and docx reading was not supported.

(defun docx2html (file)
  "Convert FILE to html in a buffer and display it."
  (interactive "f")
  (let ((html-buffer (format "*%s --> html*" file)))
    (call-process "pandoc" nil `(,html-buffer nil) nil "--to=html" 
(expand-file-name file))
    (switch-to-buffer html-buffer))
  )

Those are the errors I have seen and we ignore:

pandoc: /usr/lib/x86_64-linux-gnu/liblua5.1.so.0: no version information
available (required by pandoc)

and

pandoc: unable to decommit memory: Invalid argument

It has been nice to experience this because with the html-buffer I
simply mark-whole-buffer and say shr-render-region, and have a nice
document in text in emacs.

--
Tomas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]