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

Simplify preamble generation and detach from ox-latex #35

Open karthink opened 1 month ago

karthink commented 1 month ago

Generating the org-latex-preview--preamble-content for an Org buffer currently involves running org-export--annotate-info in a duplicate of the current buffer. For a preview run we scan the buffer and prepare all features for export. For medium-large Org buffers this is a long blocking operation and quite wasteful: we should only care about the LaTeX keywords. This is also error-prone -- often LaTeX previews fail to be generated because unrelated features like org-cite aren't properly set up and cause an error in the org-export--annotate-info stage.

Contrary to the title, completely detaching preamble generation from ox-latex is not a good idea, of course. But it would be good to make org-export--annotate-info more modular, or use a different function that only addresses the LaTeX aspects relevant to LaTeX previews.

yantar92 commented 1 month ago

karthink @.***> writes:

Generating the org-latex-preview--preamble-content for an Org buffer currently involves running org-export--annotate-info in a duplicate of the current buffer. For a preview run we instead scan the buffer and prepare all features for export. For medium-large Org buffers this is a long blocking operation and quite wasteful: we should only care about the LaTeX keywords. This is also error-prone -- Often LaTeX previews fail to be generated because unrelated features like org-cite aren't properly set up and cause an error in the org-export--annotate-info stage.

For org-cite in particular, see :with-cite-processors You can disable a number of features with appropriate export parameters.

Contrary to the title, completely detaching preamble generation from ox-latex is not a good idea, of course. But it would be good to make org-export--annotate-info more modular, or use a different function that only addresses the LaTeX aspects relevant to LaTeX previews.

Maybe you can use a similar idea to :with-cite-processors - add a set of export options to disable heavy parts of the exporter. Then, you can use a custom derived "preview" backend that will disable things you don't need.

-- 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