[Top][All Lists]

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

Re: [O] Add ability to force-enable TOC

From: Kaushal Modi
Subject: Re: [O] Add ability to force-enable TOC
Date: Tue, 19 Sep 2017 20:12:41 +0000

On Tue, Sep 19, 2017 at 3:57 PM Nicolas Goaziou <address@hidden> wrote:
What is exactly the feature you are missing? Your example is a special
case where _no_ heading is numbered.

I would not consider this as a special case. It is very common for HTML exports to not always number the headings. 

Blog posts are also very common examples.. we do not have blog posts with numbered h1/h2 headings. But for long blog posts, it often a norm to include a TOC. Example: https://scripter.co/notes/string-functions-nim-vs-python/

I also use the ascii exporter to export notes taken during meetings. I do not number them, and with a long notes, TOC is helpful.

Numbered headings is more common in texinfo and latex, I believe.
But we also had to deal with
situations where only _some_ headings were numbered.

In any case, this change solves two problems:

1. it makes all export back-ends consistent with TOC;

 I understand that. But would like a way to get back the earlier behavior too.

2. it allows to use, e.g., @heading instead of @unnumberedsec in Texinfo
   export. Thus, we don't need to provide a way to determine which one
   should be used.

I admit the second point is probably only convenient for the lazy me:
I don't have to find a proper way to support @heading commands in
Texinfo export anymore.

How about this updated patch?

diff --git a/lisp/ox.el b/lisp/ox.el
index 2be77a87b33..7b6170cb832 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -5227,7 +5227,8 @@ Footnote sections and unnumbered headlines are ignored."
     (org-element-map (org-element-contents scope) 'headline
       (lambda (headline)
  (unless (or (org-element-property :footnote-section-p headline)
-    (not (org-export-numbered-headline-p headline info)))
+    (and (not (numberp (plist-get info :with-toc)))
+ (not (org-export-numbered-headline-p headline info))))
   (let ((level (org-export-get-relative-level headline info)))
     (and (<= level n) headline))))

That way if the file has:

#+OPTIONS: num:nil

No TOC will be exported (even though the org-export-with-toc default is t).

But if the file has:

#+OPTIONS: num:nil toc:4

As the toc value is a number, the TOC will be exported even though num is nil.


Kaushal Modi

reply via email to

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