org-mode-ox-odt
org-mode-ox-odt copied to clipboard
Author results in empty field unless date provided as well
Compiling the following snippet...
#+title: Title
#+author: John Doe
Content.
... results in...

... where the author is missing, there's an empty field instead. When I add a date however, the author appears as expected:
#+title: Title
#+author: John Doe
#+date: [2022-03-01 Tue]
Content.

Note also that it has to be a valid Org Mode date -- this doesn't work:
#+title: Title
#+author: John Doe
#+date: foo
Content.

Ideally, I think the author should be properly inserted irrespective of whether the date is provided or not.
Hm -- the weird thing is, the author is there in content.xml
in both cases. This is the diff between the first two examples -- the only difference is the date:
diff -ru no-date/content.xml with-date/content.xml
--- no-date/content.xml 2022-03-01 23:50:32.000000000 +0100
+++ with-date/content.xml 2022-03-01 23:55:26.000000000 +0100
@@ -2189,6 +2189,7 @@
<text:p text:style-name="OrgTitle">
<text:title>Title</text:title></text:p>
<text:p text:style-name="OrgDocInfo"><text:initial-creator>John Doe</text:initial-creator></text:p>
+<text:p text:style-name="OrgDocInfo"><text:span text:style-name="OrgInactiveTimestamp">[2022-03-01 Tue]</text:span></text:p>
<!-- begin -->
<text:p text:style-name="Text_20_body">Content.</text:p>
diff -ru no-date/meta.xml with-date/meta.xml
--- no-date/meta.xml 2022-03-01 23:50:32.000000000 +0100
+++ with-date/meta.xml 2022-03-01 23:55:26.000000000 +0100
@@ -8,7 +8,9 @@
office:version="1.2">
<office:meta>
<dc:creator>John Doe</dc:creator>
+<dc:date>2022-03-01T00:00:00</dc:date>
<dc:title>Title</dc:title>
+<meta:creation-date>2022-03-01T00:00:00</meta:creation-date>
<meta:initial-creator>John Doe</meta:initial-creator>
</office:meta>
</office:document-meta>
\ No newline at end of file
Maybe it's a LibreOffice bug then?
FWIW, MS Word and the quick preview feature of Finder on macOS both do show the author in the document with no date.
This looks like a bug in the LibreOffice side, or as you have noticed the behaviour is unexpected.
Speaking as a programmer, in view of how the LibreOffice renders metadata in it's own UI, it considers Author and Date, as a pair.
This looks like a bug in the LibreOffice side, or as you have noticed the behaviour is unexpected.
Speaking as a programmer, in view of how the LibreOffice renders metadata in it's own UI, it considers Author and Date, as a pair.
As you see in the screenshot below, you can
- Use
View -> Field names
to see the fields - Use
File -> Properties
to see what is actually there in themeta.xml
file.
Bttw, on the Org
side, you can use C-c C-e #
, and choose d
(for the default) for inserting template. If you did that I am sure you wouldn't have an arbitrary type-written string in #+date:
in first place.
You can report LibreOffice bugs here https://bugs.documentfoundation.org/
Here is a screenshot
Bttw, on the Org side, you can use C-c C-e #, and choose d (for the default) for inserting template. If you did that I am sure you wouldn't have an arbitrary type-written string in #+date: in first place.
To clarify: I don't need to put arbitrary strings in #+date:
, I was just testing what happens, whether it makes a difference (it does). Still, thanks for reminding me about templates, they're useful and I always forget about them :)
Anyway, I think I've gotten to the bottom of this: if you always enter a <meta:creation-date/>
in meta.xml
, defaulting to the current timestamp when #+date:
is not provided (or when it's invalid -- org-mode-ox-odt
just discards it instead, which is why it behaves the same as if no date was provided), then the author (DocInformation:Created
) field displays just fine.
This is what the ODT exporter in upstream Org Mode does (no idea whether it's intentional or a lucky coincidence).
Do you consider this an acceptable workaround to include? I'll try and report this as a bug to LO, but even if it gets accepted and fixed, older versions of LO will still be around for quite some time.
Personally, defaulting to the current timestamp feels acceptable to me. Perhaps unless #+options: date:nil
is explicitly specified -- but even in that case, the user is probably mainly concerned with the date not appearing in the exported content, and not about whether it's included in the metadata, especially if the tradeoff is the author field not being displayed.
While typing up the LO bug report, I came across this bug which relates some confusion over author-related fields. Long story short, Insert → Field → Author, which inserts the DocInformation:Created
field, was renamed to Insert → Field → First Author, to distinguish it from Insert → Field → More Fields... → Author, which inserts the Author
field.
This made me wonder whether using the Author
field instead of DocInformation:Created
would help avoid the bug where the author isn't displayed when a creation date isn't provided -- and it does. Just swap <text:initial-creator>John Doe</text:initial-creator>
for <text:author-name>John Doe</text:author-name>
. Make sure not to use <text:author-name text:fixed="false">John Doe</text:author-name>
, otherwise the field will change to reflect the user data of whoever opens the file. So that's another possible workaround on your side, if you consider this semantically acceptable.
For reference, here is the LO bug I submitted.