2

I am exporting my org-mode file via org-export-as-html, but when I check the file type via file my/file.html, it is XML. I notice the first three lines in my HTML exported file is the following:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

which is a reasonable explanation. If I manually re-order these lines to the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

then the file is correctly identified as HTML. How do I correct this issue in my export function? I checked the org-mode docs here but they seem out of date:

http://orgmode.org/manual/HTML-Export-commands.html#HTML-Export-commands

because I do not have their listed commands, but org-export-to-html and org-export-as-html-to-buffer.

Any suggestions would be very helpful.

BTW I am on Emacs 24.3 with Ubuntu 14.04. Here are the first few lines of my org file:

Flatsheet Project Mgmt -*- mode: org -*-
#+TODO: TODO IN-PROGRESS WAITING DONE
#+INFOJS_OPT: view:overview toc:true

* project stuff...
* more project stuff...

UPDATE

I found this link potentially helpful, but their suggestion is not working:

http://doc.norang.ca/org-mode.html

There is a section called 16.8.2 Export HTML without XML header, but their solution below does not work for me:

(setq org-html-xml-declaration (quote (("html" . "")
                                       ("was-html" . "<?xml version=\"1.0\" encoding=\"%s\"?>")
                                       ("php" . "<?php echo \"<?xml version=\\\"1.0\\\" encoding=\\\"%s\\\" ?>\"; ?>"))))
  • 2
    when you do org-version what do you get, and did you try setting the equivalent of org-html-doctype? – pjammer Feb 25 '15 at 12:00
  • XHTML is an XML document. Why do care what file says? – rekado Feb 25 '15 at 13:20
  • @rekado Because my static "web server" (aka Amazon S3) was detecting the file at XML, thus it was not loading the javascript/css properly. – modulitos Feb 25 '15 at 13:46
  • @pjammer you were right, I did not update my org package, which is apparently under heavy development. I was at 7.9x, but I upgrade to the latest stable and it works! It looks like they redid the exporter, which should make everything smoother from here on out :-) – modulitos Feb 25 '15 at 13:49
  • In this case you may answer your question yourself. – rekado Feb 25 '15 at 14:07
1

This was resolved by upgrading to the latest version of org-mode, detailed here

I did it through the ELPA package manager, with marmalade packages, to upgrade org-mode from 7.9 to 8.2. Org-mode seems to be under heavy development, and it has a new export engine, which was probably the cause of my error.

When re-installing a package, just be sure to delete any existing org package directory under .emacs/elpa/org... and restart emacs with emacs -q and THEN install the latest package to avoid conflicts! YMMV but it worked for me.

After that, it exported fine, with a DOCTYPE html declaration at the top of the file. Now the file is recognized as HTML instead of XML.

  • Here's. more information on what's new on Org 8.0 and how it may affect your existing org-mode configuration in your init file. – Kaushal Modi Feb 26 '15 at 12:13
  • An alternative solution would have been to use pandoc to convert from org-mode to html 5. – Ben Oct 8 '15 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.