2

org-mode section numbers (when exported to html) by default starts count from 1, however it is traditional in computer science to start counting from zero. How to make org-mode section numbers start counting from 0 instead of 1?

  • 1
    Is this question about exporting to HTML? – db48x Feb 10 '17 at 0:25
1

Plain lists are turned into HTML by the function org-html-plain-list, which calls org-html-begin-plain-list. org-html-begin-plain-list outputs the <ol> tag, and has a provision for outputting a start attribute as well, but org-html-plain-list doesn't use it. Interestingly, in the version of org-mode that I happen to have (which is 6 months old), there's a commented out section of code that looks like someone was thinking about implementing this:

(defun org-html-plain-list (plain-list contents info)
  "Transcode a PLAIN-LIST element from Org to HTML.
CONTENTS is the contents of the list.  INFO is a plist holding
contextual information."
  (let* (arg1 ;; (assoc :counter (org-element-map plain-list 'item
     (type (org-element-property :type plain-list)))
    (format "%s\n%s%s"
        (org-html-begin-plain-list type)
        contents (org-html-end-plain-list type))))

It looks like it would look for a COUNTER property nearby in the org file. Of course, that would still make you put something in for every single list you used, but it would be a start.

What you could do is use add-advice to override org-html-begin-plain-list, so that it always outputs a start="0" attribute on ordered lists. You might double-check what the latest version of org-mode does as well; perhaps they've improved it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.