emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* how to get multi-line author in ODT export?
@ 2021-08-26 13:43 Eric S Fraga
  2021-08-26 14:24 ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2021-08-26 13:43 UTC (permalink / raw)
  To: Emacs Org mode mailing list

Hello all,

I am trying to generate a multi-line author for a report exported to
ODT.  In LaTeX, I would simply put \\ between lines in a single
#+author: entry, i.e. using @@latex:\\@@ in org.

In normal text, a \\ translates to <text:line-break/> in the ODT export
but this doesn't work in an ODT sub-title entry, for some reason.  This
is somewhat beyond my odt-foo unfortunately.

Can anybody help?

Thank you,
eric

PS -I still do not understand why we cannot use \\ in an AUTHOR field
when it is fine in text...  but I'm sure there's a reasonable
explanation so no worries. :-)

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-628-g366444
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 13:43 how to get multi-line author in ODT export? Eric S Fraga
@ 2021-08-26 14:24 ` Eric S Fraga
  2021-08-26 14:50   ` John Kitchin
  2021-08-26 16:05   ` Juan Manuel Macías
  0 siblings, 2 replies; 9+ messages in thread
From: Eric S Fraga @ 2021-08-26 14:24 UTC (permalink / raw)
  To: Org Mode List

So, as usual, I answer my own question, sort of.

The problem is that org exports the author text enclosed within a
special directives, specifically:

 (format "<text:initial-creator>%s</text:initial-creator>" author))
 
New line directives are not allowed within this declaration, it
seems.  Removing (manually) the initial-creator directive then works.

So, my question would be: is this text:initial-creator tagging
necessary?  If not, can we remove it?  The OpenDocument schema is vague
about whether this is necessary.  If we cannot remove it, i.e if
initial-creator is required in the document, could it be put in
separately (as a meta:initial-creator tag) so that the author field can
be more general?

I am *not* an ODT expert of any sort.  But it is my route to Word
documents when the need arises (which is luckily seldom).

Anyway, no panic: I can simply manually edit the odt file just before
the final processing...

Thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-628-g366444
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 14:24 ` Eric S Fraga
@ 2021-08-26 14:50   ` John Kitchin
  2021-08-26 15:01     ` Eric S Fraga
  2021-08-26 16:05   ` Juan Manuel Macías
  1 sibling, 1 reply; 9+ messages in thread
From: John Kitchin @ 2021-08-26 14:50 UTC (permalink / raw)
  To: Org Mode List


[-- Attachment #1.1: Type: text/plain, Size: 1765 bytes --]

Does something like this work for you:

#+options: author:nil
#+author: Test author - not shown in export

@@odt:<text:author-name>First author
line</text:author-name><text:line-break/><text:author-name>Second
line</text:author-name>@@

Testing with content

This exports to ODT like this for me:
[image: image.png]

John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Thu, Aug 26, 2021 at 10:24 AM Eric S Fraga <e.fraga@ucl.ac.uk> wrote:

> So, as usual, I answer my own question, sort of.
>
> The problem is that org exports the author text enclosed within a
> special directives, specifically:
>
>  (format "<text:initial-creator>%s</text:initial-creator>" author))
>
> New line directives are not allowed within this declaration, it
> seems.  Removing (manually) the initial-creator directive then works.
>
> So, my question would be: is this text:initial-creator tagging
> necessary?  If not, can we remove it?  The OpenDocument schema is vague
> about whether this is necessary.  If we cannot remove it, i.e if
> initial-creator is required in the document, could it be put in
> separately (as a meta:initial-creator tag) so that the author field can
> be more general?
>
> I am *not* an ODT expert of any sort.  But it is my route to Word
> documents when the need arises (which is luckily seldom).
>
> Anyway, no panic: I can simply manually edit the odt file just before
> the final processing...
>
> Thank you,
> eric
>
> --
> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-628-g366444
> : Latest paper written in org: https://arxiv.org/abs/2106.05096
>
>

[-- Attachment #1.2: Type: text/html, Size: 2706 bytes --]

[-- Attachment #2: image.png --]
[-- Type: image/png, Size: 13012 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 14:50   ` John Kitchin
@ 2021-08-26 15:01     ` Eric S Fraga
  0 siblings, 0 replies; 9+ messages in thread
From: Eric S Fraga @ 2021-08-26 15:01 UTC (permalink / raw)
  To: John Kitchin; +Cc: Org Mode List

Hi John,

On Thursday, 26 Aug 2021 at 10:50, John Kitchin wrote:
> Does something like this work for you:

Yes, thank you, hand crafting the author field directly would do the
job indeed!

Thanks again,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-628-g366444
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 14:24 ` Eric S Fraga
  2021-08-26 14:50   ` John Kitchin
@ 2021-08-26 16:05   ` Juan Manuel Macías
  2021-08-26 16:54     ` Juan Manuel Macías
  1 sibling, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2021-08-26 16:05 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: orgmode

Hi Eric,

I think the problem is in this two lines of `org-odt-template', that
creates the meta.xml file inside the odt file:

(format "<dc:creator>%s</dc:creator>\n" author)
(format "<meta:initial-creator>%s</meta:initial-creator>\n" author)

Perhaps, modifying them like this:

(format "<dc:creator><![CDATA[%s]]></dc:creator>\n" (replace-regexp-in-string "\\\\\\\\" "\n" author))
(format "<meta:initial-creator><![CDATA[%s]]></meta:initial-creator>\n" (replace-regexp-in-string "\\\\\\\\" "\n" author))

We could do this in our documents:

#+AUTHOR: Han Solo \\ Chewbacca

(little tested)

Best regards,

Juan Manuel 

Eric S Fraga writes:

> So, as usual, I answer my own question, sort of.
>
> The problem is that org exports the author text enclosed within a
> special directives, specifically:
>
>  (format "<text:initial-creator>%s</text:initial-creator>" author))
>  
> New line directives are not allowed within this declaration, it
> seems.  Removing (manually) the initial-creator directive then works.
>
> So, my question would be: is this text:initial-creator tagging
> necessary?  If not, can we remove it?  The OpenDocument schema is vague
> about whether this is necessary.  If we cannot remove it, i.e if
> initial-creator is required in the document, could it be put in
> separately (as a meta:initial-creator tag) so that the author field can
> be more general?
>
> I am *not* an ODT expert of any sort.  But it is my route to Word
> documents when the need arises (which is luckily seldom).
>
> Anyway, no panic: I can simply manually edit the odt file just before
> the final processing...
>
> Thank you,
> eric



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 16:05   ` Juan Manuel Macías
@ 2021-08-26 16:54     ` Juan Manuel Macías
  2021-08-26 18:34       ` John Kitchin
  2021-08-27 12:40       ` Eric S Fraga
  0 siblings, 2 replies; 9+ messages in thread
From: Juan Manuel Macías @ 2021-08-26 16:54 UTC (permalink / raw)
  To: Eric S Fraga; +Cc: orgmode

Hi again,

Another simpler approach, with a filter:

#+TITLE: The kessel run in 12 parsecs
#+AUTHOR: Han Solo !!! Chewbacca !!! Lando Calrissian

#+BIND: org-export-filter-plain-text-functions (author-lb-filter)
#+begin_src emacs-lisp :exports results :results none
  (defun author-lb-filter (text backend info)
    (cond ((org-export-derived-backend-p backend 'odt)
           (replace-regexp-in-string "!!!" "\n" text))
          ((org-export-derived-backend-p backend 'latex)
           (replace-regexp-in-string "!!!" "\\\\\\\\" text))))
#+end_src

Content...

Best regards,

Juan Manuel

Juan Manuel Macías writes:

> Hi Eric,
>
> I think the problem is in this two lines of `org-odt-template', that
> creates the meta.xml file inside the odt file:
>
> (format "<dc:creator>%s</dc:creator>\n" author)
> (format "<meta:initial-creator>%s</meta:initial-creator>\n" author)
>
> Perhaps, modifying them like this:
>
> (format "<dc:creator><![CDATA[%s]]></dc:creator>\n" (replace-regexp-in-string "\\\\\\\\" "\n" author))
> (format "<meta:initial-creator><![CDATA[%s]]></meta:initial-creator>\n" (replace-regexp-in-string "\\\\\\\\" "\n" author))
>
> We could do this in our documents:
>
> #+AUTHOR: Han Solo \\ Chewbacca
>
> (little tested)
>
> Best regards,
>
> Juan Manuel
>
> Eric S Fraga writes:
>
>> So, as usual, I answer my own question, sort of.
>>
>> The problem is that org exports the author text enclosed within a
>> special directives, specifically:
>>
>>  (format "<text:initial-creator>%s</text:initial-creator>" author))
>>
>> New line directives are not allowed within this declaration, it
>> seems.  Removing (manually) the initial-creator directive then works.
>>
>> So, my question would be: is this text:initial-creator tagging
>> necessary?  If not, can we remove it?  The OpenDocument schema is vague
>> about whether this is necessary.  If we cannot remove it, i.e if
>> initial-creator is required in the document, could it be put in
>> separately (as a meta:initial-creator tag) so that the author field can
>> be more general?
>>
>> I am *not* an ODT expert of any sort.  But it is my route to Word
>> documents when the need arises (which is luckily seldom).
>>
>> Anyway, no panic: I can simply manually edit the odt file just before
>> the final processing...
>>
>> Thank you,
>> eric
>
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 16:54     ` Juan Manuel Macías
@ 2021-08-26 18:34       ` John Kitchin
  2021-08-27  1:46         ` Juan Manuel Macías
  2021-08-27 12:40       ` Eric S Fraga
  1 sibling, 1 reply; 9+ messages in thread
From: John Kitchin @ 2021-08-26 18:34 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode, Eric S Fraga

[-- Attachment #1: Type: text/plain, Size: 2944 bytes --]

That is really nice, thanks for sharing it!
John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



On Thu, Aug 26, 2021 at 12:55 PM Juan Manuel Macías <maciaschain@posteo.net>
wrote:

> Hi again,
>
> Another simpler approach, with a filter:
>
> #+TITLE: The kessel run in 12 parsecs
> #+AUTHOR: Han Solo !!! Chewbacca !!! Lando Calrissian
>
> #+BIND: org-export-filter-plain-text-functions (author-lb-filter)
> #+begin_src emacs-lisp :exports results :results none
>   (defun author-lb-filter (text backend info)
>     (cond ((org-export-derived-backend-p backend 'odt)
>            (replace-regexp-in-string "!!!" "\n" text))
>           ((org-export-derived-backend-p backend 'latex)
>            (replace-regexp-in-string "!!!" "\\\\\\\\" text))))
> #+end_src
>
> Content...
>
> Best regards,
>
> Juan Manuel
>
> Juan Manuel Macías writes:
>
> > Hi Eric,
> >
> > I think the problem is in this two lines of `org-odt-template', that
> > creates the meta.xml file inside the odt file:
> >
> > (format "<dc:creator>%s</dc:creator>\n" author)
> > (format "<meta:initial-creator>%s</meta:initial-creator>\n" author)
> >
> > Perhaps, modifying them like this:
> >
> > (format "<dc:creator><![CDATA[%s]]></dc:creator>\n"
> (replace-regexp-in-string "\\\\\\\\" "\n" author))
> > (format "<meta:initial-creator><![CDATA[%s]]></meta:initial-creator>\n"
> (replace-regexp-in-string "\\\\\\\\" "\n" author))
> >
> > We could do this in our documents:
> >
> > #+AUTHOR: Han Solo \\ Chewbacca
> >
> > (little tested)
> >
> > Best regards,
> >
> > Juan Manuel
> >
> > Eric S Fraga writes:
> >
> >> So, as usual, I answer my own question, sort of.
> >>
> >> The problem is that org exports the author text enclosed within a
> >> special directives, specifically:
> >>
> >>  (format "<text:initial-creator>%s</text:initial-creator>" author))
> >>
> >> New line directives are not allowed within this declaration, it
> >> seems.  Removing (manually) the initial-creator directive then works.
> >>
> >> So, my question would be: is this text:initial-creator tagging
> >> necessary?  If not, can we remove it?  The OpenDocument schema is vague
> >> about whether this is necessary.  If we cannot remove it, i.e if
> >> initial-creator is required in the document, could it be put in
> >> separately (as a meta:initial-creator tag) so that the author field can
> >> be more general?
> >>
> >> I am *not* an ODT expert of any sort.  But it is my route to Word
> >> documents when the need arises (which is luckily seldom).
> >>
> >> Anyway, no panic: I can simply manually edit the odt file just before
> >> the final processing...
> >>
> >> Thank you,
> >> eric
> >
> >
>
>

[-- Attachment #2: Type: text/html, Size: 4111 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 18:34       ` John Kitchin
@ 2021-08-27  1:46         ` Juan Manuel Macías
  0 siblings, 0 replies; 9+ messages in thread
From: Juan Manuel Macías @ 2021-08-27  1:46 UTC (permalink / raw)
  To: John Kitchin; +Cc: orgmode, Eric S Fraga

Hi John,

you're welcome. I realized that in these lines of the meta.xml file:

<dc:creator> ... </dc:creator>
<meta:initial-creator> ... </meta:initial-creator>

line breaks can be achieved simply by adding a new line without marks (as
discussed in this thread:
https://stackoverflow.com/questions/10917555/adding-a-new-line-break-tag-in-xml/10923392)

Best regards,

Juan Manuel

John Kitchin writes:

> That is really nice, thanks for sharing it!
> John
>
> -----------------------------------
> Professor John Kitchin (he/him/his)
> Doherty Hall A207F
> Department of Chemical Engineering
> Carnegie Mellon University
> Pittsburgh, PA 15213
> 412-268-7803
> @johnkitchin
> http://kitchingroup.cheme.cmu.edu
>
> On Thu, Aug 26, 2021 at 12:55 PM Juan Manuel Macías
> <maciaschain@posteo.net> wrote:
>
>     Hi again,
>
>     Another simpler approach, with a filter:
>
>     #+TITLE: The kessel run in 12 parsecs
>     #+AUTHOR: Han Solo !!! Chewbacca !!! Lando Calrissian
>
>     #+BIND: org-export-filter-plain-text-functions (author-lb-filter)
>     #+begin_src emacs-lisp :exports results :results none
>       (defun author-lb-filter (text backend info)
>         (cond ((org-export-derived-backend-p backend 'odt)
>                (replace-regexp-in-string "!!!" "\n" text))
>               ((org-export-derived-backend-p backend 'latex)
>                (replace-regexp-in-string "!!!" "\\\\\\\\" text))))
>     #+end_src
>
>     Content...
>
>     Best regards,
>
>     Juan Manuel
>
>     Juan Manuel Macías writes:
>
>     > Hi Eric,
>     >
>     > I think the problem is in this two lines of `org-odt-template',
>     that
>     > creates the meta.xml file inside the odt file:
>     >
>     > (format "<dc:creator>%s</dc:creator>\n" author)
>     > (format "<meta:initial-creator>%s</meta:initial-creator>\n"
>     author)
>     >
>     > Perhaps, modifying them like this:
>     >
>     > (format "<dc:creator><![CDATA[%s]]></dc:creator>\n"
>     (replace-regexp-in-string "\\\\\\\\" "\n" author))
>     > (format "<meta:initial-creator><![CDATA
>     [%s]]></meta:initial-creator>\n" (replace-regexp-in-string
>     "\\\\\\\\" "\n" author))
>     >
>     > We could do this in our documents:
>     >
>     > #+AUTHOR: Han Solo \\ Chewbacca
>     >
>     > (little tested)
>     >
>     > Best regards,
>     >
>     > Juan Manuel
>     >
>     > Eric S Fraga writes:
>     >
>     >> So, as usual, I answer my own question, sort of.
>     >>
>     >> The problem is that org exports the author text enclosed within
>     a
>     >> special directives, specifically:
>     >>
>     >>  (format "<text:initial-creator>%s</text:initial-creator>"
>     author))
>     >>
>     >> New line directives are not allowed within this declaration, it
>     >> seems.  Removing (manually) the initial-creator directive then
>     works.
>     >>
>     >> So, my question would be: is this text:initial-creator tagging
>     >> necessary?  If not, can we remove it?  The OpenDocument schema
>     is vague
>     >> about whether this is necessary.  If we cannot remove it, i.e
>     if
>     >> initial-creator is required in the document, could it be put in
>     >> separately (as a meta:initial-creator tag) so that the author
>     field can
>     >> be more general?
>     >>
>     >> I am *not* an ODT expert of any sort.  But it is my route to
>     Word
>     >> documents when the need arises (which is luckily seldom).
>     >>
>     >> Anyway, no panic: I can simply manually edit the odt file just
>     before
>     >> the final processing...
>     >>
>     >> Thank you,
>     >> eric
>     >
>     >
>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to get multi-line author in ODT export?
  2021-08-26 16:54     ` Juan Manuel Macías
  2021-08-26 18:34       ` John Kitchin
@ 2021-08-27 12:40       ` Eric S Fraga
  1 sibling, 0 replies; 9+ messages in thread
From: Eric S Fraga @ 2021-08-27 12:40 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: orgmode

Juan Manuel,

thank you very much.  This is both very useful and ever so simple!  I
did have to set org-export-allow-bind-keywords for this to work (in case
others wonder why nothing seems to happen ;-)).

Thanks again,
eric

-- 
: Eric S Fraga via Emacs 28.0.50, Org release_9.4.6-628-g366444
: Latest paper written in org: https://arxiv.org/abs/2106.05096


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-08-27 12:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-26 13:43 how to get multi-line author in ODT export? Eric S Fraga
2021-08-26 14:24 ` Eric S Fraga
2021-08-26 14:50   ` John Kitchin
2021-08-26 15:01     ` Eric S Fraga
2021-08-26 16:05   ` Juan Manuel Macías
2021-08-26 16:54     ` Juan Manuel Macías
2021-08-26 18:34       ` John Kitchin
2021-08-27  1:46         ` Juan Manuel Macías
2021-08-27 12:40       ` Eric S Fraga

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).