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

markdown to odt conversion produces corrupt document #9287

Closed
scokobro opened this issue Dec 25, 2023 · 7 comments
Closed

markdown to odt conversion produces corrupt document #9287

scokobro opened this issue Dec 25, 2023 · 7 comments

Comments

@scokobro
Copy link

Running pandoc -f markdown -t odt -o basic.odt basic.md on basic.md, which is as follows...

---
title: Basic Doc
date: 25 Dec 2023
---

# Heading

hello world

results in an odt file that LibreOffice is unable to open. The Libre Office error is: "The file 'basic.odt' is corrupt and therefore cannot be opened." The file can be opened in MSWord, but on save it warns "basic.odt may contain features that are not compatible with this format."

odfvalidator.org reports an error for the odt file as follows:
basic.odt/content.xml[2,1334]: Error: attribute "office:version" has a bad value

I am aware this may be an LO issue but pandoc-discuss is out of action so I thought I'd ask here.
Thanks.

Pandoc Version: 3.1.11
Libre Office: 7.6.4.1
Mac OS 14.1.2

@scokobro scokobro added the bug label Dec 25, 2023
@jgm
Copy link
Owner

jgm commented Dec 27, 2023

I can't reproduce this on my end with pandoc 3.1.11 and LibreOffice for macOS:

Version: 7.4.2.3 / LibreOffice Community
Build ID: 382eef1f22670f7f4118c8c2dd222ec7ad009daf
CPU threads: 8; OS: Mac OS X 12.7.2; UI render: default; VCL: osx
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

I can try updating LibreOffice to see if it makes a difference.

@jgm
Copy link
Owner

jgm commented Dec 27, 2023

Upgrading to LibreOffice 7.6.4.1 -- I can still open basic.odt with no problems.
macOS 12.7.2, but hard to believe that a difference in macOS version would result in this difference.

@jgm
Copy link
Owner

jgm commented Dec 27, 2023

Here's what I get on odfvalidator.org:

image

This is different from what you're seeing, so I'm really puzzled. Can you upload your basic.odt so I can compare it with mine?

@jgm
Copy link
Owner

jgm commented Dec 27, 2023

To fix the validation error above, we need to put office:styles as the root node of a separate file, styles.xml:

image

jgm added a commit that referenced this issue Dec 27, 2023
These styles were going into an office:styles element in content.xml,
but this is invalid.  Instead they must go in styles.xml. See #9287.

The variable `highlighting-styles` no longer has any effect on
the default opendocument template, and highlighting styles are
not included in opendocument output.
@jgm
Copy link
Owner

jgm commented Dec 27, 2023

I've fixed the issue with styles, but this doesn't seem to be your original issue.
My content.xml has office:version="1.3" which seems to work fine.

@scokobro
Copy link
Author

scokobro commented Dec 28, 2023

Thanks for looking into this! Have attached my 'basic.odt'; odfvalidator.org gives me this...
Imgur

basic.odt

(I should maybe have mentioned that this is the 'Apple Silicon' version of LO)

I'll also mention that while I can unzip the odt file on the command line (unzip basic.odt -d file-content), changing the file extension to .zip in the Finder and double clicking to unzip gets me an 'unsupported format' error.

@scokobro
Copy link
Author

scokobro commented Dec 29, 2023

Think I found the source of the problem; it was line 2 in the default.opendocument template I was using, it finished with office:version="1.2">. Changing this to "1.3" fixed it 🙄 ...
Thanks for your help, have a good 2024!

@jgm jgm closed this as completed Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants