emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Introduce "export features"


From: Timothy
Subject: [PATCH] Introduce "export features"
Date: Sat, 11 Feb 2023 01:20:09 +0800
User-agent: mu4e 1.8.13; emacs 28.2.50

Hello everyone,

I’m thrilled to finally be presenting a feature that I’ve been incubating for a
while now that I call “export features”. This work is based on the observation
that often we include content in export templates that is only relevant in
particular situations.

This leaves one having to choose between a “kitchen sink” approach where
everything that could be used is all included, or a “manual inclusion” approach
where the template is minimal and the relevant setup code must be manually
included each time.

I think it’s fair to say neither situation is ideal, and I’ve become
dissatisfied enough that I’ve sunk some time into working on a better way of
handling this. In this patch set it’s just being applied to LaTeX preambles, but
this is just a start — there are plans to apply this more broadly.

“export features” allow for the specification of qualities of the org buffer
being exported that imply certain “features”, and how those features may be
implemented in a particular export.

This is done by augmenting the backend struct with two new fields:
`feature-conditions' and `feature-implementations'.

The feature conditions are resolved during the annotation of `info', in the Org
buffer after `#+include' expansion and the removal of comments.

The feature implementations are expanded by the backend itself, in the case of
`ox-latex' this currently means during preamble construction.

With this change, `ox-latex' produces more minimal /and/ more capable exports 
out of
the box. The number of default packages has been ~halved, but OOTB capability
has been improved by dynamically adding them to the preamble when needed, and
now `\usepackage{svg}' is automatically added when exporting a buffer that
includes SVG images.

This also opens new frontiers for user customisation. For instance, adding
particular beamer customisations when using the `metropolis' beamer theme with 
the
following snippet:

┌────
│ (org-export-update-features 'beamer
│   (beamer-metropolis
│    :condition (string-match-p \"metropolis$\" (plist-get info :beamer-theme))
│    :snippet my-org-beamer-metropolis-tweaks
│    :order 3))
└────


Hopefully this gives you an idea of the feature. See the patches attached for
the implementation (and some hopefully informative code comments). Feel free to
toss any you may have question my way :)

All the best,
Timothy

-- 
Timothy (‘tecosaur’/‘TEC’), 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/tec>.

Attachment: 0001-ox-Introduce-conditional-generated-preamble.patch
Description: Text Data

Attachment: 0002-ox-latex-Apply-new-generated-preamble-to-export.patch
Description: Text Data

Attachment: 0003-ox-Feature-condition-implementation-convenience.patch
Description: Text Data

Attachment: 0004-oc-Make-use-of-conditional-preamble-for-export.patch
Description: Text Data

Attachment: 0005-ox-Add-struct-feature-conditions-implementations.patch
Description: Text Data

Attachment: 0006-ox-latex-Reformat-feature-announcement-comment.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]