tecosaur / org-latex-preview-todos

A tracker for the Org LaTeX Preview effort on https://git.tecosaur.net/tec/org-mode
5 stars 0 forks source link

ODT export support #21

Open tecosaur opened 9 months ago

tecosaur commented 9 months ago

It's halfway there, but it's a pain (to me at least) and love it if somebody else could do it :pray:.

yantar92 commented 7 months ago

Some details:

  1. org-odt--translate-latex-fragments uses LaTeX preview code.
  2. On main, now-obsolete org-format-latex was used
  3. On dev org-latex-preview-replace-fragments (non-existing) is used: https://code.tecosaur.net/tec/org-mode/src/branch/dev/lisp/ox-odt.el#L3819 (so, ox-odt is broken on dev branch for now)
  4. One needs to rewrite that part of the function to use the new org-latex-preview API.
karthink commented 6 months ago

@tecosaur By "halfway there", do you mean you've done some of it already? If yes, is your work committed?

yantar92 commented 6 months ago

I looked closer into this and the way we need to change ox-odt is probably similar to what org-html-prepare-latex-images does. However, I am concerned that org-html-prepare-latex-images is using internal org-latex-preview API. It would be better if org-latex-preview exposed (and documeted!) better API to retrieve fragments programatically.

karthink commented 6 months ago

I implemented latex preview support for ox-odt over the weekend. I ended up duplicating a bunch of code from ox-html, so I agree with the point about org-latex-preview exposing a better way to get preview images. I'll work on this in the coming weekend.

On Wed, Mar 13, 2024, 4:58 AM Ihor Radchenko @.***> wrote:

I looked closer into this and the way we need to change ox-odt is probably similar to what org-html-prepare-latex-images does. However, I am concerned that org-html-prepare-latex-images is using internal org-latex-preview API. It would be better if org-latex-preview exposed (and documeted!) better API to retrieve fragments programatically.

— Reply to this email directly, view it on GitHub https://github.com/tecosaur/org-latex-preview-todos/issues/21#issuecomment-1994213847, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBVOLENRPLXBFJ3IT2YTUDYYA5ODAVCNFSM6AAAAABBPMKF7CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOJUGIYTGOBUG4 . You are receiving this because you commented.Message ID: @.***>

karthink commented 6 months ago

A couple of updates:

  1. ODT export support has been added. In the process, there are a couple of improvements to ox-odt as well: svg image exports via the dvisvgm are now supported, and there is some support for scaling images to match the text size. Baseline alignment for inline fragments is not available, and it doesn't look like this is possible. The current state of LaTeX preview based image exports for ODT is still much better than before, so I'm content to leave this be.
  2. org-latex-preview now provides an external API for export backends and for general elisp scripting to generate preview images for a parse tree. Both the ox-html and ox-odt backends are now using this API.

This issue can be closed after someone tests ODT exports.

karthink commented 6 months ago

I should add that ox-odt is quite broken on the whole. Several of my test exports failed because of errors unrelated to org-latex-preview, i.e. errors with the preexisting version. I tracked a couple of the errors down, and I can fix it but I don't understand the original intent of that code so I don't want to touch it.

I'm not sure I would call it usable.

yantar92 commented 5 months ago

karthink @.***> writes:

  1. ODT export support has been added. In the process, there are a couple of improvements to ox-odt as well: svg image exports via the dvisvgm are now supported, and there is some support for scaling images to match the text size. Baseline alignment for inline fragments is not available, and it doesn't look like this is possible. The current state of LaTeX preview based image exports for ODT is still much better than before, so I'm content to leave this be.

AFAIU, the "proper" way to export formulas to odt is via mathml convertor.

Is there any place where I can test the update? I only know Timothy's repo, but I do not see any new commits there.

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

yantar92 commented 5 months ago

karthink @.***> writes:

I should add that ox-odt is quite broken on the whole. Several of my test exports failed because of errors unrelated to org-latex-preview, i.e. errors with the preexisting version. I tracked a couple of the errors down, and I can fix it but I don't understand the original intent of that code so I don't want to touch it.

I'm not sure I would call it usable.

A number of people use it without issues. If you encountered issues, please do report them.

-- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at https://orgmode.org/. Support Org development at https://liberapay.com/org-mode, or support my work at https://liberapay.com/yantar92

karthink commented 5 months ago

AFAIU, the "proper" way to export formulas to odt is via mathml convertor.

That makes sense given the ODT format. Basic support for image-based LaTeX preview means this is at least not a blocker any more.

Is there any place where I can test the update? I only know Timothy's repo, but I do not see any new commits there.

He hasn't applied the patches yet, they should be on the repo soon.

A number of people use it without issues. If you encountered issues, please do report them

Will do. The issues mostly center on image links (not LaTeX preview images) being malformed.

tecosaur commented 5 months ago

He hasn't applied the patches yet, they should be on the repo soon.

They were applied about an hour ago :slightly_smiling_face:

karthink commented 3 months ago

Can someone test exporting an Org doc with equations to ODT via dvisvgm/dvipng? It should be working, but I'd like confirmation before closing this.