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 .
Support Org development at ,
or support my work at .