I am trying to write on org-mode backend to generate Jupyter Notebook, specifically optimized for producing slides using RISE (see https://github.com/hkarl/org-juslides if interested).

Suppose I have a src-code block. How can I find out the tags of its enclosing headline (if any tags exist)?

The closest thing I found is this How can I get the tags for a headline in a clock report formula?, and Org-mode backend: access properties in heading - but they are after somewhat different problems.

I know how to get at attributes of the src-block itself, but I'd rather not have to repeat a "skipslide" tag already set in the headline.

I suppose it would be possible traversing org-element-lineage, but that seems like vast overkill. Is there any simpler option?

Any pointers much appreciated!

(defun org-juslides-src-block (src-block contents info)
  (let ( (code (org-export-format-code-default src-block info))
     (animate (org-export-read-attribute :attr_juslides src-block :animate))
    (print "src block")
    (print (org-element-lineage src-block '('heading) ))
    (print animate)
    (org-juslides-cell "code"
               (if animate
  • Untested, but maybe (org-export-get-tags (org-export-get-parent-headline src-block) info '("invalid" "tags") t)
    – rasmus
    Jun 14, 2016 at 16:34
  • Wonderful, right on spot! Thanks a lot! Jun 15, 2016 at 9:26

1 Answer 1


Solved by rasmus, with kudos:

(org-export-get-tags (org-export-get-parent-headline src-block) info '("invalid" "tags") t) 

(or, in detail, to also consider the option to use an attribute in the src-block itself):

  (let* ( 
     (tags (org-export-get-tags (org-export-get-parent-headline src-block) info '("invalid" "tags") t))
     (skipslide (or (member "skipslide" tags)
            (org-export-read-attribute :attr_juslides src-block :skip)

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .