emacs-orgmode
[Top][All Lists]
Advanced

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

How does =org-md-item= produce the correct indentation for nested lists?


From: Rohit Patnaik
Subject: How does =org-md-item= produce the correct indentation for nested lists?
Date: Fri, 12 Apr 2024 23:07:13 -0500
User-agent: Cyrus-JMAP/3.11.0-alpha0-379-gabd37849b7-fm-20240408.001-gabd37849

Hello,

I was looking at the implementation for =org-md-item=, in ox-md.el, and I'm
wondering how indentation logic for nested lists works. Specifically, I was
looking at the following code:

#+BEGIN_SRC elisp
(concat bullet
        (make-string (- 4 (length bullet)) ? )
        (pcase (org-element-property :checkbox item)
          (`on "[X] ")
          (`trans "[-] ")
          (`off "[ ] "))
        (let ((tag (org-element-property :tag item)))
          (and tag (format "**%s:** "(org-export-data tag info))))
        (and contents
         (org-trim (replace-regexp-in-string "^" "    " contents))))
#+END_SRC

and I'm wondering why it's adding indentation in front of the bullet. Naively, I
would expect the result of this snippet, for an unordered list to be something
like:

=-        [item contents]=

That is, it concatenate the bullet, then three spaces (4 - length of bullet),
then another four spaces, then the contents of the item. Instead, what I see is
a four-space indent, followed by the bullet and its padding, followed by the
item contents:

=    -   [item contents]=

This is the correct result, but I don't see how the code from ox-md.el produces
that result.

The reason I'm asking is because I have similar logic in the org-mode exporter
I'm writing for PMWiki markup:

https://github.com/quanticle/ox-pmwiki/blob/master/ox-pmwiki.el#L214

and I would like to change the logic so that instead of indenting with spaces,
it repeats the list marker (** for a second level nested list, *** for 3 levels
of nesting, etc). 

Thanks,
Rohit Patnaik



reply via email to

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