Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title support for docx export? #3

Closed
brabalan opened this issue Jun 14, 2015 · 20 comments
Closed

Title support for docx export? #3

brabalan opened this issue Jun 14, 2015 · 20 comments

Comments

@brabalan
Copy link

This exporter is very useful! Is it possible to have the title exported when doing docx export?

@kawabata
Copy link
Owner

As far as I've tested, the newest version of Pandoc (version 1.14.0.4)
properly
supports exporting "#+TITLE:" line to ".docx" format.

Could you check if you've installed the newest version?

On Mon, Jun 15, 2015 at 2:26 AM, Alan Schmitt notifications@github.com
wrote:

This exporter is very useful! Is it possible to have the title exported
when doing docx export?


Reply to this email directly or view it on GitHub
#3.


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@brabalan
Copy link
Author

I have this version (I had the .2 but I upgraded).

Here is a file for which it does not work:

#+title: This is a title
#+date: 1/2/3

* First section
foo

* Second section
bar

Here is what I get:
screen shot 2015-06-17 at 10 12 44

@kawabata
Copy link
Owner

Exact same text file produce following document in my env,
both Pandoc 1.13 and 1.14....

Hmm...

On Wed, Jun 17, 2015 at 5:13 PM, Alan Schmitt notifications@github.com
wrote:

I have this version (I had the .2 but I upgraded).

Here is a file for which it does not work:

#+title: This is a title
#+date: 1/2/3

  • First section
    foo
  • Second section
    bar

Here is what I get:
[image: screen shot 2015-06-17 at 10 12 44]
https://cloud.githubusercontent.com/assets/1021637/8202363/7c737c5a-14d9-11e5-89b4-28ff947a7d52.png


Reply to this email directly or view it on GitHub
#3 (comment).


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@brabalan
Copy link
Author

This is not a doc problem: I have the same issue with exporting to pdf or html5 through pandoc. For the later, looking at the source, I see the title tag with nothing in it.

@kawabata
Copy link
Owner

I recalled that I did
'git clone https://github.com/jgm/pandoc-templates templates'
in ~/.pandoc directory.

Even though I couldn't find the docx template there,
would this help?

On Wed, Jun 17, 2015 at 9:47 PM, Alan Schmitt notifications@github.com
wrote:

This is not a doc problem: I have the same issue with exporting to pdf or
html5 through pandoc. For the later, looking at the source, I see the title
tag with nothing in it.


Reply to this email directly or view it on GitHub
#3 (comment).


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@brabalan
Copy link
Author

I tried it and it did not change anything. I tried to reproduce the problem directly with pandoc, and here is what I have found: if I only ask for the conversion, I get this.

% pandoc -t markdown testdoc.org
First section
=============

foo

Second section
==============

bar

However, if I add the --self-contained option, I get this:

% pandoc -t markdown --self-contained testdoc.org
---
date: '1/2/3'
title: This is a title
...

First section
=============

foo

Second section
==============

bar

Could it be that the option is missing when calling pandoc from ox-pandoc?

@kawabata
Copy link
Owner

Even though in my environment, specifying "self-contained" or not does not affect the result,
you may want to specify that option by default, as
e.g.
(setq org-pandoc-options '((self-contained . t) (standalone . t) (mathjax . t) (parse-raw . t)))

may help you.

@brabalan
Copy link
Author

It still does not work … and looking at the docs, I see that --standalone should be sufficient. When I run pandoc manually with the arguments stated in the Messages buffer, I get the correct result.

I tried debugging and the problem happens before: the title and date lines are removed from the generated temporary org file. I see that this happens in org-export-to-file but I don't understand what is going on there. I'm using version release_8.3beta-1229-ge900eb of org.

@kawabata
Copy link
Owner

Would you try if 'M-x org-org-export-to-org' and see if it also removes
:title and :date line?
In that case, that would be the problem of default settings of org exporter.
"The Filter System" appeared in the middle of "ox.el" source code provides
explanations
of various preprocessors. Perhaps you may set any of such filters?

On Mon, Jun 22, 2015 at 6:47 PM, Alan Schmitt notifications@github.com
wrote:

It still does not work … and looking at the docs, I see that --standalone
should be sufficient. When I run pandoc manually with the arguments stated
in the Messages buffer, I get the correct result.

I tried debugging and the problem happens before: the title and date lines
are removed from the generated temporary org file. I see that this happens
in org-export-to-file but I don't understand what is going on there. I'm
using version release_8.3beta-1229-ge900eb of org.


Reply to this email directly or view it on GitHub
#3 (comment).


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@brabalan
Copy link
Author

The org-org-export-to-org does not remove the Title and Date lines. In fact it adds and Author line at the beginning.

@kawabata
Copy link
Owner

What would happen if you try invoking emacs with "-q" option (meaning skip
loading user customization file?) and then exports file to docx format?

In my environment, invoking emacs with "-q" option and loading dash.el, ht.el, and
ox-pandoc.el exports titles properly.

Regards,

@brabalan
Copy link
Author

I am seeing the same problem with running in a new emacs with -Q: the org-org-export-to-org works correctly, but the pandoc export does not. The temporary org file that is created does not have the metadata information, and I think this is the core of the problem. I do not understand why it is the case, though.

@brabalan
Copy link
Author

I've asked for help on the org mailing list, and here is what I found. I can replicate the problem (missing metadata in the temporary org file) using this test exporter:

(org-export-define-derived-backend 'mytest 'org
  :translate-alist '((template . org-pandoc-template))
  :export-block "MYTEST"
  :menu-entry '(?t "test" as/org-export-test))

(defun as/org-export-test (&optional a s v b e)
  (org-export-to-file 'mytest
      (org-export-output-file-name
       (concat (make-temp-name ".tmp") ".org") s)))

According to this message http://article.gmane.org/gmane.emacs.orgmode/98738 the problem is that the org exporter uses the org-org-template function to deal with the metadata, so you might need to call is from org-pandoc-template.

@kawabata
Copy link
Owner

Now I think I understand a problem.

It seems ox-org.el distributed by MELPA nor the one with Emacs 24.4
does not provide org-org-template, while newest HEAD does.

I wonder what would be the best way to solve this problem while keeping
compatibility with existing standard or popular org-mode distributions.

On Mon, Jun 29, 2015 at 1:47 AM, Alan Schmitt notifications@github.com
wrote:

I've asked for help on the org mailing list, and here is what I found. I
can replicate the problem (missing metadata in the temporary org file)
using this test exporter:

(org-export-define-derived-backend 'mytest 'org
:translate-alist '((template . org-pandoc-template))
:export-block "MYTEST"
:menu-entry '(?t "test" as/org-export-test))

(defun as/org-export-test (&optional a s v b e)
(org-export-to-file 'mytest
(org-export-output-file-name
(concat (make-temp-name ".tmp") ".org") s)))

According to this message
http://article.gmane.org/gmane.emacs.orgmode/98738 the problem is that
the org exporter uses the org-org-template function to deal with the
metadata, so you might need to call is from org-pandoc-template.


Reply to this email directly or view it on GitHub
#3 (comment).


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@brabalan
Copy link
Author

I'll ask and will let you know.

@kawabata
Copy link
Owner

As you see the official org-mode newest package distribution directory
(http://orgmode.org/elpa/), they've stopped refereshing the package
since December, last year (file size has been the same since then.)

That causes the great difference between offical package distribution and
HEAD version. I hope that they would be syncrhonized, so that people
who prefer package installation can also enjoy the newest version.

(For people who want stability, org-mode equipped in standard Emacs
would suffice.)

Anyway, I've never noticed this thing and I thought I've been using the
newest HEAD version of org-mode, which is not true ;-p

On Mon, Jun 29, 2015 at 6:37 PM, Alan Schmitt notifications@github.com
wrote:

I'll ask and will let you know.


Reply to this email directly or view it on GitHub
#3 (comment).


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@kawabata
Copy link
Owner

Perhaps the quickest hack would be something like:


@@ -1168,7 +1168,9 @@ Option table is created in this stage."
(epub-chapter-level . :epub-chapter-level)
(epub-cover-image . :epub-cover-image)
(bibliography . :bibliography))))

  • contents)
  • (if (functionp 'org-org-template)
  •  (org-org-template contents info)
    
  • contents))

(defun org-pandoc-put-options (options)

"Put alist OPTIONS to `org-pandoc-option-table'."

But that would cause compiler warning for an environment
that does not have org-org-template function.

I found that 'org-org-template' is introduced to org-mode HEAD
in December 2013, but is not included (or merged) to official
branch (including the one with Emacs 24.4 and ELPA package)
since then....

On Tue, Jun 30, 2015 at 12:08 AM, kawabata taichi <kawabata.taichi@gmail.com

wrote:

As you see the official org-mode newest package distribution directory
(http://orgmode.org/elpa/), they've stopped refereshing the package
since December, last year (file size has been the same since then.)

That causes the great difference between offical package distribution and
HEAD version. I hope that they would be syncrhonized, so that people
who prefer package installation can also enjoy the newest version.

(For people who want stability, org-mode equipped in standard Emacs
would suffice.)

Anyway, I've never noticed this thing and I thought I've been using the
newest HEAD version of org-mode, which is not true ;-p

On Mon, Jun 29, 2015 at 6:37 PM, Alan Schmitt notifications@github.com
wrote:

I'll ask and will let you know.


Reply to this email directly or view it on GitHub
#3 (comment).


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com


川幡 太一 (KAWABATA, Taichi) E-mail: kawabata.taichi@gmail.com

@brabalan
Copy link
Author

Your hack works great and solves the problem, thanks.

Regarding org and Melpa, there has been a long discussion about this back in March: http://lists.gnu.org/archive/html/emacs-orgmode/2015-03/msg00247.html

@kawabata
Copy link
Owner

kawabata commented Jul 5, 2015

I've uploaded the change to use ox-org template if it exists.
I hope it would work properly.

@brabalan
Copy link
Author

brabalan commented Jul 6, 2015

It does, thanks.

@brabalan brabalan closed this as completed Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants