emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] How to get list item depth within the exporter framework?


From: Richard Lawrence
Subject: Re: [O] How to get list item depth within the exporter framework?
Date: Mon, 27 Jul 2015 10:51:10 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Hi Marcin,

Marcin Borkowski <address@hidden> writes:

> as I mentioned, I'm writing a simple exporter.  However, I stumbled on
> something apparently simple.  How to get the current list level within
> org-whatever-item transcoder?

I ran into this problem once; the solution I found was to just walk up
the AST via org-export-get-parent until you run out of parents.

Something like this should work (untested, and probably needs to be
tweaked, as my Elisp is a little rusty):

(defun find-depth (element)
  "Find the depth of a (list) element during export."
  (let ((parent (org-export-get-parent element)))
     (case (org-element-type parent)
       ('item (1+ (find-depth parent)))
       ('plain-list (find-depth (org-export-get-parent parent)))
       (t 1))))

Hope that helps!

Best,
Richard




reply via email to

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