emacs-orgmode
[Top][All Lists]
Advanced

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

Re: custom function for org-babel src block export


From: David Bremner
Subject: Re: custom function for org-babel src block export
Date: Mon, 25 Dec 2023 18:26:45 -0800

Ihor Radchenko <yantar92@posteo.net> writes:

> David Bremner <david@tethera.net> writes:
>
>> I am generating slides using org-beamer. I would like certain code
>> blocks to export as links containing URL-encoded content of the
>> block.
>
> Check out https://orgmode.org/manual/Advanced-Export-Configuration.html
> You may use export filter or extend ox-beamer backend, creating a new
> custom backend that will export your code blocks as desired.
>

Thanks for the suggestion(s).

I tried defining org-export-filter-src-block-functions (see end)
but I encountered two issues

1) The text already includes the latex environment (in my case
listings). This is solvable, but did make me wonder if I was using the
right filter.

2) I could not figure out how to cleanly access the source language
   (e.g. "stacker" in my example). It didn't seem to be in "info".  I
   guess I can recover it from the text using e.g. regex, but this seems 
fragile, since
   it would break when switching backends.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun db-ox-src-filter (text backend info)
  (when (org-export-derived-backend-p backend 'latex)
    (db-stacker-link text)))

(add-to-list 'org-export-filter-src-block-functions
             #'db-ox-src-filter)



reply via email to

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