emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* New Exporter: plain list depth
@ 2013-04-21 21:19 Yasushi SHOJI
  2013-04-21 22:10 ` Nicolas Goaziou
  0 siblings, 1 reply; 3+ messages in thread
From: Yasushi SHOJI @ 2013-04-21 21:19 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

What is the best way to know the depth of list entries when I writing
an exporter back-end?

let's say I have:

#+BEGIN_SRC org
  * headline 1
    - list 1
    - list 2
      - list 2.1
#+END_SRC

I'd like to convert it to:

#+BEGIN_EXAMPLE
  * headline 1
  - list 1
  - list 2
  -- list 2.1
#+END_EXAMPLE


To generate "--" at the list 2.1, I'd like to find out the list 2.1 is
at depth 2, so that I can use (make-string 2 ?-) for my bullet.

What I came up with instead was to

     1) mark each item in item handler with "-"
     2) add a "-" in each plain-list handler
     3) remove one "-" from all list entries at final-function

it works, but it doesn't look good to me (tm).

I've checked a few exporters, including ox-html and ox-md but couldn't
find a function like org-export-get-relative-level for headline. Does
org-list-to-generic work in this situation?

Thanks,
-- 
            yashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: New Exporter: plain list depth
  2013-04-21 21:19 New Exporter: plain list depth Yasushi SHOJI
@ 2013-04-21 22:10 ` Nicolas Goaziou
  2013-04-23 12:25   ` Yasushi SHOJI
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Goaziou @ 2013-04-21 22:10 UTC (permalink / raw)
  To: Yasushi SHOJI; +Cc: emacs-orgmode

Hello,

Yasushi SHOJI <yashi@atmark-techno.com> writes:

> What is the best way to know the depth of list entries when I writing
> an exporter back-end?
>
> let's say I have:
>
> #+BEGIN_SRC org
>   * headline 1
>     - list 1
>     - list 2
>       - list 2.1
> #+END_SRC
>
> I'd like to convert it to:
>
> #+BEGIN_EXAMPLE
>   * headline 1
>   - list 1
>   - list 2
>   -- list 2.1
> #+END_EXAMPLE
>
>
> To generate "--" at the list 2.1, I'd like to find out the list 2.1 is
> at depth 2, so that I can use (make-string 2 ?-) for my bullet.

Something like the following should work, assuming ITEM is the item
element you have to transcode:

#+begin_src emacs-lisp
(let ((parent item) (depth 0))
  (while (and (setq parent (org-export-get-parent parent))
              (case (org-element-type parent)
                (item t)
                (plain-list (incf depth)))))
  depth)
#+end_src

> Does org-list-to-generic work in this situation?

As a good rule of thumb, it's best to rely on tools provided in ox.el.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: New Exporter: plain list depth
  2013-04-21 22:10 ` Nicolas Goaziou
@ 2013-04-23 12:25   ` Yasushi SHOJI
  0 siblings, 0 replies; 3+ messages in thread
From: Yasushi SHOJI @ 2013-04-23 12:25 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

At Mon, 22 Apr 2013 00:10:25 +0200,
Nicolas Goaziou wrote:
> 
> Yasushi SHOJI <yashi@atmark-techno.com> writes:
> 
> > To generate "--" at the list 2.1, I'd like to find out the list 2.1 is
> > at depth 2, so that I can use (make-string 2 ?-) for my bullet.
> 
> Something like the following should work, assuming ITEM is the item
> element you have to transcode:
> 
> #+begin_src emacs-lisp
> (let ((parent item) (depth 0))
>   (while (and (setq parent (org-export-get-parent parent))
>               (case (org-element-type parent)
>                 (item t)
>                 (plain-list (incf depth)))))
>   depth)
> #+end_src

Thanks!  will try based on your advice.

> > Does org-list-to-generic work in this situation?
> 
> As a good rule of thumb, it's best to rely on tools provided in ox.el.

ok.

regards,
-- 
            yashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-23 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-21 21:19 New Exporter: plain list depth Yasushi SHOJI
2013-04-21 22:10 ` Nicolas Goaziou
2013-04-23 12:25   ` Yasushi SHOJI

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).