emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* exporting drawers: odt versus LaTeX
@ 2018-04-23 16:05 Eric S Fraga
  2018-04-23 21:26 ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2018-04-23 16:05 UTC (permalink / raw)
  To: emacs-orgmode

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

Hello all,

when I export a drawer to LaTeX, the output from
org-latex-format-drawer-function, which I can re-define, is inserted
directly into the LaTeX document.  In particular, it is not considered a
different paragraph by default.

When I export to odt, the content text passed to the
org-odt-format-drawer-function is already wrapped within a paragraph
style, e.g.:

<text:p text:style-name="Text_20_body">Drawer contents here
</text:p>

This inconsistency is not ideal.  I would prefer the contents to be
passed to the drawer function without this wrapping style.  I don't mind
if the default of the function puts the contents in a paragraph, of
course, but I would like to override this.

I've gone through the code but cannot determine where this is done and
why the ODT export target is treated differently to the LaTeX one.

Any pointers would be welcome.

Thanks,
eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-419-g52ba1a

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-23 16:05 exporting drawers: odt versus LaTeX Eric S Fraga
@ 2018-04-23 21:26 ` Nicolas Goaziou
  2018-04-24  5:37   ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-04-23 21:26 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Eric S Fraga <esflists@gmail.com> writes:

> I've gone through the code but cannot determine where this is done and
> why the ODT export target is treated differently to the LaTeX one.

Both are treated similarly, really. The difference comes from the fact
that LaTeX has no markup for paragraph. Therefore,

  :drawer:
  Paragraph 1

  Paragraph 2
  :end:

will become

  Paragraph 1

  Paragraph 2

in LaTeX, but

  <p>Paragraph 1</p>

  <p>Paragraph 2</p>

in HTML...

You could write a drawer filter trimming paragraph markup if the drawer
consists of a single paragraph (e.g., no blank line).

Regards,

-- 
Nicolas Goaziou

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-23 21:26 ` Nicolas Goaziou
@ 2018-04-24  5:37   ` Eric S Fraga
  2018-04-24  7:36     ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2018-04-24  5:37 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

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

On Monday, 23 Apr 2018 at 23:26, Nicolas Goaziou wrote:
> Hello,
>
> Eric S Fraga <esflists@gmail.com> writes:
>
>> I've gone through the code but cannot determine where this is done and
>> why the ODT export target is treated differently to the LaTeX one.
>
> Both are treated similarly, really. The difference comes from the fact
> that LaTeX has no markup for paragraph. Therefore,

Hi Nicolas,

this is not quite true; in LaTeX, a blank line (\n\n) indicates a
paragraph but org does not treat a drawer as starting a paragraph.  E.g.

#+begin_src org
  ,#+options: d:test
  ,* testing
  This is the first paragraph.
  :test:
  This is a test.
  :END:
#+end_src

generates

    \section{testing}
    \label{sec:org499dcbc}
    This is the first paragraph.
    This is a test.
    \end{document}

and this is what I want as I can put a blank line before the start of
the drawer should I want a new paragraph.

> You could write a drawer filter trimming paragraph markup if the drawer
> consists of a single paragraph (e.g., no blank line).

I could but this is not achieving consistency across the export targets
and would not allow for a single paragraph drawer to be exported inline
or as a separate paragraph.

Thanks,
eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-419-g52ba1a

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-24  5:37   ` Eric S Fraga
@ 2018-04-24  7:36     ` Nicolas Goaziou
  2018-04-24  8:34       ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-04-24  7:36 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Eric S Fraga <esflists@gmail.com> writes:

> this is not quite true; in LaTeX, a blank line (\n\n) indicates a
> paragraph but org does not treat a drawer as starting a paragraph.

Of course it does. Drawers contains paragraphs, not the opposite way.

> E.g.
>
> #+begin_src org
>   ,#+options: d:test
>   ,* testing
>   This is the first paragraph.
>   :test:
>   This is a test.
>   :END:
> #+end_src

To convince yourself, you could put point at the beginning of the first
paragraph and evaluate 

  (goto-char (org-element-property :end (org-element-at-point)))

> generates
>
>     \section{testing}
>     \label{sec:org499dcbc}
>     This is the first paragraph.
>     This is a test.
>     \end{document}
>
> and this is what I want as I can put a blank line before the start of
> the drawer should I want a new paragraph.

Again, you are confused because LaTeX treats blank lines specially. The
"latex" back-end preserves blank lines from the original file. So in
this case, the absence of blank lines makes it think there is a single
paragraph. However, it wasn't the case in the source document.

Regards,

-- 
Nicolas Goaziou                                                0x80A93738

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-24  7:36     ` Nicolas Goaziou
@ 2018-04-24  8:34       ` Eric S Fraga
  2018-04-24 21:43         ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2018-04-24  8:34 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

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

On Tuesday, 24 Apr 2018 at 09:36, Nicolas Goaziou wrote:
> Hello,
>
> Eric S Fraga <esflists@gmail.com> writes:
>
>> this is not quite true; in LaTeX, a blank line (\n\n) indicates a
>> paragraph but org does not treat a drawer as starting a paragraph.
>
> Of course it does. Drawers contains paragraphs, not the opposite way.

Hi Nicolas,

We may have to agree to disagree here.  The export outputs indicate the
opposite.  I understand your reasoning (as given in the rest of the
post) but I think there is a fundamental design issue here.  However, I
can live with it.

So, moving forward, is there an ODT expert that can tell me how to wrap
the contents of a drawer so that the background of the drawer contents,
which obviously consist of 1 or more paragraphs on ODT export, is a
specific colour?  I tried:

#+begin_src emacs-lisp :results none
  ;; format note drawers
  (setq-local org-latex-format-drawer-function
              (lambda (name contents)
                (if (string= name "note")
                    (progn
                      (format "\\hl{%s}" contents)))))
  (setq-local org-odt-format-drawer-function
              (lambda (name contents)
                (if (string= name "note")
                    (progn
                      (format "<text:span text:background=\"#FFFF00\">%s</text:span>" contents)))))
#+end_src 

but this leads to malformed XML according to libreoffice.  The LaTeX
works because I expect note drawers to be short and no more than a
single "paragraph".  For other drawers, I used mdframed in LaTeX to
achieve a similar effect.

(ignore the emacs lisp correctness/style issues...  e.g. progn and what
happens if a different drawer; this is work in progress ;-))

This is all relates to my preemptively moving away from inline tasks for
a number of use cases.

Thank you.
-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.7-475-g3ffc7d

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-24  8:34       ` Eric S Fraga
@ 2018-04-24 21:43         ` Nicolas Goaziou
  2018-04-25  6:17           ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-04-24 21:43 UTC (permalink / raw)
  To: emacs-orgmode

Eric S Fraga <esflists@gmail.com> writes:

> We may have to agree to disagree here.

I'm not sure what we have to agree to disagree on. 

I'm just describing how the Org syntax works. This is documented at
<https://orgmode.org/worg/dev/org-syntax.html>.

For the record,

  p1
  :drawer:
  p2
  :end:
  p3

is seen as

  '((p1) (drawer (p2)) (p3))

But maybe I'm misunderstanding and you have something else in mind.

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-24 21:43         ` Nicolas Goaziou
@ 2018-04-25  6:17           ` Eric S Fraga
  2018-04-30 11:46             ` Nicolas Goaziou
  0 siblings, 1 reply; 9+ messages in thread
From: Eric S Fraga @ 2018-04-25  6:17 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

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

On Tuesday, 24 Apr 2018 at 23:43, Nicolas Goaziou wrote:
> Eric S Fraga <esflists@gmail.com> writes:
>
>> We may have to agree to disagree here.
>
> I'm not sure what we have to agree to disagree on. 

:-)

I think simply that the outcome on export is qualitatively different
depending on target: for LaTeX, the drawer is not (necessarily) a new
paragraph whereas for ODT it is.  This bothers me æsthetically and does
make writing filters etc. more difficult but it's not a deal breaker!

> I'm just describing how the Org syntax works. This is documented at
> <https://orgmode.org/worg/dev/org-syntax.html>.

Yes, I understand.  I am definitely not disagreeing about how org parses
the elements, simply how it exports them.

thanks,
eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.6-419-g52ba1a

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-25  6:17           ` Eric S Fraga
@ 2018-04-30 11:46             ` Nicolas Goaziou
  2018-04-30 13:36               ` Eric S Fraga
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2018-04-30 11:46 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

Eric S Fraga <esflists@gmail.com> writes:

> Yes, I understand.  I am definitely not disagreeing about how org parses
> the elements, simply how it exports them.

Then we agree on this point. 

Export is different because, well, target languages are also
different...

Since empty lines are preserved upon exporting documents, Org is /de
facto/ nice with formats that separate paragraphs with blank lines,
e.g., LaTeX or Texinfo. I.e, it adapts easily to their definition of
a paragraph.

As you noted, this is not the same for other back-ends, as HTML or ODT.
At some point, I wanted to have Org adapt to their own definition of
a paragraph. I.e., a parse-tree filter (provided by the back-end) would
generate pseudo-elements matching the target's definition of
a paragraph. Then, the parse-tree would convert the pseudo-element as
a paragraph whereas it would do nothing for a regular paragraph.

E,g., the following document

  Paragraph
  #+begin_quote
  Quote
  #+end_quote
  Paragraph 2

  Paragraph 3

is parsed as 

  (paragraph "Paragraph") 
  (quote-block (paragraph "Quote"))
  (paragraph "Paragraph 2")
  (paragraph "Paragraph 3")

the HTML parse tree filter would turn it into

  (html-paragraph 
   (paragraph "Paragraph")
   (quote-block (html-paragraph (paragraph "Quote")))
   (paragraph "Paragraph 2"))

  (html-paragraph
   (paragraph "Paragraph 3"))

and since regular paragraph converter would be a no-op, this would
really become:

  (html-paragraph 
   "Paragraph"
   (quote-block (html-paragraph "Quote"))
   "Paragraph 2")

  (html-paragraph "Paragraph 3")

Some parts of the export framework already implement a similar
mechanism, e.g., `org-latex--wrap-latex-matrices'.

But there are a some shortcomings. E.g., is an `html-paragraph' nested
in an `html-paragraph' still valid? What about the quote block being
a table, a plain list? IOW, what is the exact definition of HTML
paragraph?

Since I couldn't answer those questions, I'm mostly a LaTeX guy, this is
not implemented so far.

Regards,

-- 
Nicolas Goaziou

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

* Re: exporting drawers: odt versus LaTeX
  2018-04-30 11:46             ` Nicolas Goaziou
@ 2018-04-30 13:36               ` Eric S Fraga
  0 siblings, 0 replies; 9+ messages in thread
From: Eric S Fraga @ 2018-04-30 13:36 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

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

On Monday, 30 Apr 2018 at 13:46, Nicolas Goaziou wrote:
> Eric S Fraga <esflists@gmail.com> writes:
>
>> Yes, I understand.  I am definitely not disagreeing about how org parses
>> the elements, simply how it exports them.
>
> Then we agree on this point. 

Yes!

> Export is different because, well, target languages are also
> different...

Which makes consistency challenging.  We're seeing this with the
citations thread.

[...]

> Since I couldn't answer those questions, I'm mostly a LaTeX guy, this is
> not implemented so far.

Which is fine with me as I also am a LaTeX guy... :-)

I only need odt when I am sharing with some colleagues that have not yet
seen the light. ;-)

thanks for the detailed explanation in any case.

eric

-- 
Eric S Fraga via Emacs 27.0.50, Org release_9.1.11-620-ga548e4

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 194 bytes --]

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

end of thread, other threads:[~2018-04-30 13:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-23 16:05 exporting drawers: odt versus LaTeX Eric S Fraga
2018-04-23 21:26 ` Nicolas Goaziou
2018-04-24  5:37   ` Eric S Fraga
2018-04-24  7:36     ` Nicolas Goaziou
2018-04-24  8:34       ` Eric S Fraga
2018-04-24 21:43         ` Nicolas Goaziou
2018-04-25  6:17           ` Eric S Fraga
2018-04-30 11:46             ` Nicolas Goaziou
2018-04-30 13:36               ` Eric S Fraga

Code repositories for project(s) associated with this public 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).