From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kaushal Modi Subject: Re: Add ability to force-enable TOC Date: Tue, 19 Sep 2017 20:12:41 +0000 Message-ID: References: <87shfia3qm.fsf@nicolasgoaziou.fr> <87h8vya2c3.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114fa8a6e94dcd0559907b60" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duOt5-0003HR-6S for emacs-orgmode@gnu.org; Tue, 19 Sep 2017 16:12:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duOt3-0007s7-Lt for emacs-orgmode@gnu.org; Tue, 19 Sep 2017 16:12:55 -0400 Received: from mail-yw0-x236.google.com ([2607:f8b0:4002:c05::236]:52158) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duOt3-0007rp-Fm for emacs-orgmode@gnu.org; Tue, 19 Sep 2017 16:12:53 -0400 Received: by mail-yw0-x236.google.com with SMTP id p10so538026ywh.8 for ; Tue, 19 Sep 2017 13:12:53 -0700 (PDT) In-Reply-To: <87h8vya2c3.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: Carsten Dominik , emacs-org list --001a114fa8a6e94dcd0559907b60 Content-Type: text/plain; charset="UTF-8" On Tue, Sep 19, 2017 at 3:57 PM Nicolas Goaziou 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)))) info))) 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 --001a114fa8a6e94dcd0559907b60 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Sep 19= , 2017 at 3:57 PM Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
What is exactly the feature you are missing? Your example is a spec= ial
case where _no_ heading is numbered.

I wou= ld not consider this as a special case. It is very common for HTML exports = to not always number the headings.=C2=A0

Blog post= s are also very common examples.. we do not have blog posts with numbered h= 1/h2 headings. But for long blog posts, it often a norm to include a TOC. E= xample:=C2=A0https://scripter.co/notes/string-functions-nim-vs-python/
=

I also use the ascii exporter to export notes taken dur= ing meetings. I do not number them, and with a long notes, TOC is helpful.<= /div>

Numbered headings is more common in texinfo and la= tex, I believe.
=C2=A0
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;
=
=C2=A0I understand that. But would like a way to get back th= e earlier behavior too.

= 2. it allows to use, e.g., @heading instead of @unnumberedsec in Texinfo =C2=A0 =C2=A0export. Thus, we don't need to provide a way to determine = which one
=C2=A0 =C2=A0should 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.e= l
index 2be77a87b33..7b6170cb832 100644
--- a/lisp/ox.e= l
+++ b/lisp/ox.el
@@ -5227,7 +5227,8 @@ Footnote secti= ons and unnumbered headlines are ignored."
=C2=A0 =C2=A0 =C2= =A0(org-element-map (org-element-contents scope) 'headline
= =C2=A0 =C2=A0 =C2=A0 =C2=A0(lambda (headline)
=C2=A0 (unless (or (org-element-property :footnote-se= ction-p headline)
- =C2= =A0 =C2=A0(not (org-export-numbered-headline-p headline info)))
+= =C2=A0 =C2=A0(and (not (numberp (= plist-get info :with-toc)))
+ <= /span> (not (org-export-numbered-headline-p headline info))))
=C2= =A0 =C2=A0(let ((level (org-export-= get-relative-level headline info)))
=C2=A0 =C2=A0 =C2=A0(and (<=3D level n) headline))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0info)))


That way if the file has:

#+OPTIONS: num:nil

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

But if the file has:
<= div>
#+OPTIONS: num:nil toc:4

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

--

Kaus= hal Modi

--001a114fa8a6e94dcd0559907b60--