* [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' @ 2024-08-31 20:34 Rudolf Adamkovič 2024-09-01 16:52 ` Ihor Radchenko 0 siblings, 1 reply; 9+ messages in thread From: Rudolf Adamkovič @ 2024-08-31 20:34 UTC (permalink / raw) To: emacs-orgmode; +Cc: Rudolf Adamkovic From: Rudolf Adamkovic <rudolf@adamkovic.org> * etc/ORG-NEWS (Texinfo exporter now supports numeric =toc= values in =#+OPTIONS:=): Announce the new feature. * lisp/ox.el (org-export-excluded-from-toc-p): Return nil for all headlines that are above the `toc' value in export `#+OPTIONS'. * testing/lisp/test-ox-texinfo.el (test-ox-texinfo/headings-and-table-of-contents): Add a test. --- etc/ORG-NEWS | 12 ++++++ lisp/ox.el | 6 ++- testing/lisp/test-ox-texinfo.el | 66 +++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 392788055..f93776754 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -77,6 +77,18 @@ You can now create links to =shortdoc= documentation groups for Emacs Lisp functions (see =M-x shortdoc-display-group=). Requires Emacs 28 or newer. +<<<<<<< HEAD +======= +*** Texinfo exporter now supports numeric =toc= values in =#+OPTIONS:= + +For example, given =H:3= and =toc:2= in =#+OPTIONS:=, all headings at +the 1st and 2nd level appear in the table of contents and those at the +3rd level do not. The latter will be instead exported as if they had +the =UNNUMBERED= property set to =notoc=, that is using the Texinfo +command given in the =unnumbered-no-toc-3= list position of the +=org-texinfo-classes= variable, as documented. + +>>>>>>> ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' ** New and changed options # Chanes deadling with changing default values of customizations, diff --git a/lisp/ox.el b/lisp/ox.el index 7a0ab4dc7..acc535f72 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5625,7 +5625,11 @@ contents. However, it is useful if some additional processing is required on headlines excluded from table of contents." (or (org-element-property :footnote-section-p headline) (org-export-low-level-p headline info) - (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)))) + (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)) + (let ((toc-depth (plist-get info :with-toc))) + (and (wholenump toc-depth) + (> (org-element-property :level headline) + toc-depth))))) (defun org-export-toc-entry-backend (parent &rest transcoders) "Return an export backend appropriate for table of contents entries. diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index b16a344e7..e2bacd4d9 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -345,5 +345,71 @@ body (should-not (org-element-contents section)) (should (eq first-heading (org-element-parent section))))))) +\f +;;; Headings and table of contents + +(ert-deftest test-ox-texinfo/headings-and-table-of-contents () + "Test headings with regards to table of contents." + (should + (org-test-with-temp-text + (string-join + (list "#+OPTIONS: h:2 toc:1 num:nil" + "* Level 1" + "** Level 1-1" + "*** Level 1-1-1" + "*** Level 1-1-2" + "** Level 1-2" + "*** Level 1-2-1" + "*** Level 1-2-2" + "* Level 2" + "** Level 2-1" + "*** Level 2-1-1" + "*** Level 2-1-2" + "** Level 2-2" + "*** Level 2-2-1" + "*** Level 2-2-2") + "\n") + (let ((export-buffer "*Test Texinfo Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'texinfo export-buffer + nil nil nil nil nil + #'texinfo-mode) + (with-current-buffer export-buffer + (goto-char (point-min)) + (and + (re-search-forward "^@menu$") + (re-search-forward "^* Level 1::$") + (re-search-forward "^* Level 2::$") + (re-search-forward "^@detailmenu$") + (re-search-forward "^Level 1$") + (re-search-forward "^* Level 1-1::$") + (re-search-forward "^* Level 1-2::$") + (re-search-forward "^Level 2$") + (re-search-forward "^* Level 2-1::$") + (re-search-forward "^* Level 2-2::$") + (re-search-forward "^@node Level 1$") + (re-search-forward "^@unnumbered Level 1$") + (re-search-forward "^@menu$") + (re-search-forward "^* Level 1-1::$") + (re-search-forward "^* Level 1-2::$") + (re-search-forward "^@heading Level 1-1$") + (re-search-forward "^@anchor{Level 1-1-1}Level 1-1-1$") + (re-search-forward "^@anchor{Level 1-1-2}Level 1-1-2$") + (re-search-forward "^@heading Level 1-2$") + (re-search-forward "^@anchor{Level 1-2-1}Level 1-2-1$") + (re-search-forward "^@anchor{Level 1-2-2}Level 1-2-2$") + (re-search-forward "^@node Level 2$") + (re-search-forward "^@unnumbered Level 2$") + (re-search-forward "^@menu$") + (re-search-forward "^* Level 2-1::$") + (re-search-forward "^* Level 2-2::$") + (re-search-forward "^@heading Level 2-1$") + (re-search-forward "^@anchor{Level 2-1-1}Level 2-1-1$") + (re-search-forward "^@anchor{Level 2-1-2}Level 2-1-2$") + (re-search-forward "^@anchor{Level 2-2}$") + (re-search-forward "^@heading Level 2-2$") + (re-search-forward "^@anchor{Level 2-2-1}Level 2-2-1$") + (re-search-forward "^@anchor{Level 2-2-2}Level 2-2-2$"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here -- 2.46.0 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-08-31 20:34 [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' Rudolf Adamkovič @ 2024-09-01 16:52 ` Ihor Radchenko 2024-09-03 22:29 ` Rudolf Adamkovič 0 siblings, 1 reply; 9+ messages in thread From: Ihor Radchenko @ 2024-09-01 16:52 UTC (permalink / raw) To: Rudolf Adamkovič; +Cc: emacs-orgmode Rudolf Adamkovič <rudolf@adamkovic.org> writes: > From: Rudolf Adamkovic <rudolf@adamkovic.org> > > * etc/ORG-NEWS (Texinfo exporter now supports numeric =toc= values in > =#+OPTIONS:=): Announce the new feature. > * lisp/ox.el (org-export-excluded-from-toc-p): Return nil for all > headlines that are above the `toc' value in export `#+OPTIONS'. > * testing/lisp/test-ox-texinfo.el > (test-ox-texinfo/headings-and-table-of-contents): Add a test. AFAIU, it is a bugfix. Right? If it is, the patch name is rather confusing. Also, what about `org-export-collect-headlines'. It also ignores numeric value of :with-toc. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-09-01 16:52 ` Ihor Radchenko @ 2024-09-03 22:29 ` Rudolf Adamkovič 2024-09-09 17:57 ` Ihor Radchenko 0 siblings, 1 reply; 9+ messages in thread From: Rudolf Adamkovič @ 2024-09-03 22:29 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 437 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > AFAIU, it is a bugfix. Right? > > If it is, the patch name is rather confusing. I can never tell! Fixed. > Also, what about `org-export-collect-headlines'. It also ignores > numeric value of :with-toc. Fixed. Thank you for letting me know! I am exporting only to HTML, where Org-generated top-level menus do not appear. So, I missed it. P.S. I also fixed the incorrect test. Rudy [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-texinfo-Support-numeric-values-of-toc-in-OPTIONS.patch --] [-- Type: text/x-patch, Size: 7137 bytes --] From 54ff91953d1a456852506ac162eee2a0cf99d3b0 Mon Sep 17 00:00:00 2001 From: Rudolf Adamkovic <rudolf@adamkovic.org> Date: Sat, 24 Aug 2024 15:26:18 +0200 Subject: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' * etc/ORG-NEWS (Texinfo exporter now supports numeric =toc= values in =#+OPTIONS:=): Announce the change. * lisp/ox.el (org-export-excluded-from-toc-p): Return nil for all headlines that are above the `toc' value in the export `#+OPTIONS'. (org-export-collect-headlines): Exclude all headlines that are above the `toc' value in the export `#+OPTIONS' , using the updated `org-export-excluded-from-toc-p' function. * testing/lisp/test-ox-texinfo.el (test-ox-texinfo/menus-nodes-headings): Add a test. --- etc/ORG-NEWS | 6 +++ lisp/ox.el | 16 ++++--- testing/lisp/test-ox-texinfo.el | 81 +++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 392788055..344591ebb 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -223,6 +223,12 @@ This way, attachments will remain accessible when opening symlinked Org file. When no attach dir exists, Org mode will still prefer creating it in the "default" directory - where the symlink is located. +*** Texinfo exporter now considers numeric =toc= values in =#+OPTIONS:= + +For example, given =H:3= and =toc:2= in =#+OPTIONS:=, all headings at +the 1st and 2nd level appear in the table of contents and those at the +3rd level do not. + * Version 9.7 ** Important announcements and breaking changes diff --git a/lisp/ox.el b/lisp/ox.el index 7a0ab4dc7..c16e3acf6 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5555,12 +5555,10 @@ Footnote sections are ignored." (+ (org-export-get-relative-level scope info) n)) limit)))) (org-element-map (org-element-contents scope) 'headline - (lambda (h) - (and (not (org-element-property :footnote-section-p h)) - (not (equal "notoc" - (org-export-get-node-property :UNNUMBERED h t))) - (>= n (org-export-get-relative-level h info)) - h)) + (lambda (headline) + (and (not (org-export-excluded-from-toc-p headline info)) + (>= n (org-export-get-relative-level headline info)) + headline)) info))) (defun org-export-collect-elements (type info &optional predicate) @@ -5625,7 +5623,11 @@ contents. However, it is useful if some additional processing is required on headlines excluded from table of contents." (or (org-element-property :footnote-section-p headline) (org-export-low-level-p headline info) - (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)))) + (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)) + (let ((toc-depth (plist-get info :with-toc))) + (and (wholenump toc-depth) + (> (org-element-property :level headline) + toc-depth))))) (defun org-export-toc-entry-backend (parent &rest transcoders) "Return an export backend appropriate for table of contents entries. diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index b16a344e7..fc9b6dabd 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -345,5 +345,86 @@ body (should-not (org-element-contents section)) (should (eq first-heading (org-element-parent section))))))) +\f +;;; Structure + +(ert-deftest test-ox-texinfo/menus-nodes-headings () + "Test menus, nodes, and headings." + (should + (org-test-with-temp-text + (string-join + (list "#+OPTIONS: H:3 toc:2 num:nil" + "* Heading 1" + "** Heading 1-1" + "*** Heading 1-1-1" + "*** Heading 1-1-2" + "** Heading 1-2" + "*** Heading 1-2-1" + "*** Heading 1-2-2" + "* Heading 2" + "** Heading 2-1" + "*** Heading 2-1-1" + "*** Heading 2-1-2" + "** Heading 2-2" + "*** Heading 2-2-1" + "*** Heading 2-2-2") + "\n") + (let ((export-buffer "*Test Texinfo Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'texinfo export-buffer + nil nil nil nil nil + #'texinfo-mode) + (with-current-buffer export-buffer + (goto-char (point-min)) + (and + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 1::$") + (re-search-forward "^* Heading 2::$") + (re-search-forward "^@detailmenu$") + (re-search-forward "^Heading 1$") + (re-search-forward "^* Heading 1-1::$") + (re-search-forward "^* Heading 1-2::$") + (re-search-forward "^Heading 2$") + (re-search-forward "^* Heading 2-1::$") + (re-search-forward "^* Heading 2-2::$") + (re-search-forward "^@end detailmenu$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 1$") + (re-search-forward "^@unnumbered Heading 1$") + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 1-1::$") + (re-search-forward "^* Heading 1-2::$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 1-1$") + (re-search-forward "^@unnumberedsec Heading 1-1$") + (re-search-forward "^@anchor{Heading 1-1-1}$") + (re-search-forward "^@subheading Heading 1-1-1$") + (re-search-forward "^@anchor{Heading 1-1-2}$") + (re-search-forward "^@subheading Heading 1-1-2$") + (re-search-forward "^@node Heading 1-2$") + (re-search-forward "^@unnumberedsec Heading 1-2$") + (re-search-forward "^@anchor{Heading 1-2-1}$") + (re-search-forward "^@subheading Heading 1-2-1$") + (re-search-forward "^@anchor{Heading 1-2-2}$") + (re-search-forward "^@subheading Heading 1-2-2$") + (re-search-forward "^@node Heading 2$") + (re-search-forward "^@unnumbered Heading 2$") + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 2-1::$") + (re-search-forward "^* Heading 2-2::$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 2-1$") + (re-search-forward "^@unnumberedsec Heading 2-1$") + (re-search-forward "^@anchor{Heading 2-1-1}$") + (re-search-forward "^@subheading Heading 2-1-1$") + (re-search-forward "^@anchor{Heading 2-1-2}$") + (re-search-forward "^@subheading Heading 2-1-2$") + (re-search-forward "^@node Heading 2-2$") + (re-search-forward "^@unnumberedsec Heading 2-2$") + (re-search-forward "^@anchor{Heading 2-2-1}$") + (re-search-forward "^@subheading Heading 2-2-1$") + (re-search-forward "^@anchor{Heading 2-2-2}$") + (re-search-forward "^@subheading Heading 2-2-2$"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here -- 2.39.3 (Apple Git-146) [-- Attachment #3: Type: text/plain, Size: 200 bytes --] -- "I love deadlines. I love the whooshing noise they make as they go by." --- Douglas Adams, The Salmon of Doubt, 2002 Rudolf Adamkovič <rudolf@adamkovic.org> [he/him] http://adamkovic.org ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-09-03 22:29 ` Rudolf Adamkovič @ 2024-09-09 17:57 ` Ihor Radchenko 2024-09-11 22:33 ` Rudolf Adamkovič 0 siblings, 1 reply; 9+ messages in thread From: Ihor Radchenko @ 2024-09-09 17:57 UTC (permalink / raw) To: Rudolf Adamkovič; +Cc: emacs-orgmode Rudolf Adamkovič <rudolf@adamkovic.org> writes: >> Also, what about `org-export-collect-headlines'. It also ignores >> numeric value of :with-toc. > > Fixed. Thank you for letting me know! I am exporting only to HTML, > where Org-generated top-level menus do not appear. So, I missed it. > > P.S. I also fixed the incorrect test. Thanks! > - (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)))) > + (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)) > + (let ((toc-depth (plist-get info :with-toc))) > + (and (wholenump toc-depth) > + (> (org-element-property :level headline) > + toc-depth))))) Should be relative level, I think. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-09-09 17:57 ` Ihor Radchenko @ 2024-09-11 22:33 ` Rudolf Adamkovič 2024-09-15 12:16 ` Ihor Radchenko 0 siblings, 1 reply; 9+ messages in thread From: Rudolf Adamkovič @ 2024-09-11 22:33 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > Should be relative level, I think. I am a bit lost here, on both why and how. :) Rudy -- "'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and if it were so, it would be; but as it isn't, it ain't. That's logic.'" --- Lewis Carroll, Through the Looking Glass, 1871/1872 Rudolf Adamkovič <rudolf@adamkovic.org> [he/him] http://adamkovic.org ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-09-11 22:33 ` Rudolf Adamkovič @ 2024-09-15 12:16 ` Ihor Radchenko 2024-12-15 11:32 ` Ihor Radchenko 0 siblings, 1 reply; 9+ messages in thread From: Ihor Radchenko @ 2024-09-15 12:16 UTC (permalink / raw) To: Rudolf Adamkovič; +Cc: emacs-orgmode Rudolf Adamkovič <rudolf@adamkovic.org> writes: > Ihor Radchenko <yantar92@posteo.net> writes: > >> Should be relative level, I think. > > I am a bit lost here, on both why and how. :) See `org-export-collect-headlines' and how it uses `org-export-get-relative-level' to determine whether a given heading is too deeply nested to be included into TOC. `org-export-get-relative-level' is also used within individual backends when dealing with :with-toc export option. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-09-15 12:16 ` Ihor Radchenko @ 2024-12-15 11:32 ` Ihor Radchenko 2024-12-20 20:26 ` Rudolf Adamkovič 0 siblings, 1 reply; 9+ messages in thread From: Ihor Radchenko @ 2024-12-15 11:32 UTC (permalink / raw) To: Rudolf Adamkovič; +Cc: emacs-orgmode Ihor Radchenko <yantar92@posteo.net> writes: > See `org-export-collect-headlines' and how it uses > `org-export-get-relative-level' to determine whether a given heading is > too deeply nested to be included into TOC. > > `org-export-get-relative-level' is also used within individual backends > when dealing with :with-toc export option. > ... It has been a while since the last message in this thread. May I know if you need any further help with the patch? -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-12-15 11:32 ` Ihor Radchenko @ 2024-12-20 20:26 ` Rudolf Adamkovič 2024-12-24 11:22 ` Ihor Radchenko 0 siblings, 1 reply; 9+ messages in thread From: Rudolf Adamkovič @ 2024-12-20 20:26 UTC (permalink / raw) To: Ihor Radchenko; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 279 bytes --] Ihor Radchenko <yantar92@posteo.net> writes: > It has been a while since the last message in this thread. > May I know if you need any further help with the patch? My apologies for the radio silence, I was busy with school. Please see the attached patch! Will this do? Rudy [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0001-ox-texinfo-Support-numeric-values-of-toc-in-OPTIONS.patch --] [-- Type: text/x-patch, Size: 7137 bytes --] From ec7316614463d1c8217dac434fb8bad48446cd09 Mon Sep 17 00:00:00 2001 From: Rudolf Adamkovic <rudolf@adamkovic.org> Date: Sat, 24 Aug 2024 15:26:18 +0200 Subject: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' * etc/ORG-NEWS (Texinfo exporter now supports numeric =toc= values in =#+OPTIONS:=): Announce the change. * lisp/ox.el (org-export-excluded-from-toc-p): Return nil for all headlines that are above the `toc' value in the export `#+OPTIONS'. (org-export-collect-headlines): Exclude all headlines that are above the `toc' value in the export `#+OPTIONS' , using the updated `org-export-excluded-from-toc-p' function. * testing/lisp/test-ox-texinfo.el (test-ox-texinfo/menus-nodes-headings): Add a test. --- etc/ORG-NEWS | 6 +++ lisp/ox.el | 16 ++++--- testing/lisp/test-ox-texinfo.el | 81 +++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 7 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 08857962b..3b2ca5f46 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -355,6 +355,12 @@ The Texinfo exporter no longer removes links from headings. This applies to all headings, below and above the =H= and =toc= export =#+OPTIONS:=. +*** Texinfo exporter now considers numeric =toc= values in =#+OPTIONS:= + +For example, given =H:3= and =toc:2= in =#+OPTIONS:=, all headings at +the 1st and 2nd level appear in the table of contents and those at the +3rd level do not. + * Version 9.7 ** Important announcements and breaking changes diff --git a/lisp/ox.el b/lisp/ox.el index 8410acc2b..6ddbd245c 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -5558,12 +5558,10 @@ Footnote sections are ignored." (+ (org-export-get-relative-level scope info) n)) limit)))) (org-element-map (org-element-contents scope) 'headline - (lambda (h) - (and (not (org-element-property :footnote-section-p h)) - (not (equal "notoc" - (org-export-get-node-property :UNNUMBERED h t))) - (>= n (org-export-get-relative-level h info)) - h)) + (lambda (headline) + (and (not (org-export-excluded-from-toc-p headline info)) + (>= n (org-export-get-relative-level headline info)) + headline)) info))) (defun org-export-collect-elements (type info &optional predicate) @@ -5628,7 +5626,11 @@ contents. However, it is useful if some additional processing is required on headlines excluded from table of contents." (or (org-element-property :footnote-section-p headline) (org-export-low-level-p headline info) - (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)))) + (equal "notoc" (org-export-get-node-property :UNNUMBERED headline t)) + (let ((toc-depth (plist-get info :with-toc))) + (and (wholenump toc-depth) + (> (org-export-get-relative-level headline info) + toc-depth))))) (defun org-export-toc-entry-backend (parent &rest transcoders) "Return an export backend appropriate for table of contents entries. diff --git a/testing/lisp/test-ox-texinfo.el b/testing/lisp/test-ox-texinfo.el index 681af7363..61f939ce1 100644 --- a/testing/lisp/test-ox-texinfo.el +++ b/testing/lisp/test-ox-texinfo.el @@ -484,5 +484,86 @@ body (should (search-forward "@uref{https://example.com, Foo@comma{} Bar}")) (should (search-forward "@uref{https://example.com, Foo@comma{} Bar@}}"))))))) +\f +;;; Structure + +(ert-deftest test-ox-texinfo/menus-nodes-headings () + "Test menus, nodes, and headings." + (should + (org-test-with-temp-text + (string-join + (list "#+OPTIONS: H:3 toc:2 num:nil" + "* Heading 1" + "** Heading 1-1" + "*** Heading 1-1-1" + "*** Heading 1-1-2" + "** Heading 1-2" + "*** Heading 1-2-1" + "*** Heading 1-2-2" + "* Heading 2" + "** Heading 2-1" + "*** Heading 2-1-1" + "*** Heading 2-1-2" + "** Heading 2-2" + "*** Heading 2-2-1" + "*** Heading 2-2-2") + "\n") + (let ((export-buffer "*Test Texinfo Export*") + (org-export-show-temporary-export-buffer nil)) + (org-export-to-buffer 'texinfo export-buffer + nil nil nil nil nil + #'texinfo-mode) + (with-current-buffer export-buffer + (goto-char (point-min)) + (and + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 1::$") + (re-search-forward "^* Heading 2::$") + (re-search-forward "^@detailmenu$") + (re-search-forward "^Heading 1$") + (re-search-forward "^* Heading 1-1::$") + (re-search-forward "^* Heading 1-2::$") + (re-search-forward "^Heading 2$") + (re-search-forward "^* Heading 2-1::$") + (re-search-forward "^* Heading 2-2::$") + (re-search-forward "^@end detailmenu$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 1$") + (re-search-forward "^@unnumbered Heading 1$") + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 1-1::$") + (re-search-forward "^* Heading 1-2::$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 1-1$") + (re-search-forward "^@unnumberedsec Heading 1-1$") + (re-search-forward "^@anchor{Heading 1-1-1}$") + (re-search-forward "^@subheading Heading 1-1-1$") + (re-search-forward "^@anchor{Heading 1-1-2}$") + (re-search-forward "^@subheading Heading 1-1-2$") + (re-search-forward "^@node Heading 1-2$") + (re-search-forward "^@unnumberedsec Heading 1-2$") + (re-search-forward "^@anchor{Heading 1-2-1}$") + (re-search-forward "^@subheading Heading 1-2-1$") + (re-search-forward "^@anchor{Heading 1-2-2}$") + (re-search-forward "^@subheading Heading 1-2-2$") + (re-search-forward "^@node Heading 2$") + (re-search-forward "^@unnumbered Heading 2$") + (re-search-forward "^@menu$") + (re-search-forward "^* Heading 2-1::$") + (re-search-forward "^* Heading 2-2::$") + (re-search-forward "^@end menu$") + (re-search-forward "^@node Heading 2-1$") + (re-search-forward "^@unnumberedsec Heading 2-1$") + (re-search-forward "^@anchor{Heading 2-1-1}$") + (re-search-forward "^@subheading Heading 2-1-1$") + (re-search-forward "^@anchor{Heading 2-1-2}$") + (re-search-forward "^@subheading Heading 2-1-2$") + (re-search-forward "^@node Heading 2-2$") + (re-search-forward "^@unnumberedsec Heading 2-2$") + (re-search-forward "^@anchor{Heading 2-2-1}$") + (re-search-forward "^@subheading Heading 2-2-1$") + (re-search-forward "^@anchor{Heading 2-2-2}$") + (re-search-forward "^@subheading Heading 2-2-2$"))))))) + (provide 'test-ox-texinfo) ;;; test-ox-texinfo.el end here -- 2.39.5 (Apple Git-154) [-- Attachment #3: Type: text/plain, Size: 190 bytes --] -- "The whole science is nothing more than a refinement of everyday thinking." --- Albert Einstein, 1879-1955 Rudolf Adamkovič <rudolf@adamkovic.org> [he/him] http://adamkovic.org ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' 2024-12-20 20:26 ` Rudolf Adamkovič @ 2024-12-24 11:22 ` Ihor Radchenko 0 siblings, 0 replies; 9+ messages in thread From: Ihor Radchenko @ 2024-12-24 11:22 UTC (permalink / raw) To: Rudolf Adamkovič; +Cc: emacs-orgmode Rudolf Adamkovič <rudolf@adamkovic.org> writes: > Please see the attached patch! Thanks! Applied, onto main. https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=d1b77a6c57 -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92> ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-12-24 11:22 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-08-31 20:34 [PATCH] ox-texinfo: Support numeric values of `toc' in `#+OPTIONS' Rudolf Adamkovič 2024-09-01 16:52 ` Ihor Radchenko 2024-09-03 22:29 ` Rudolf Adamkovič 2024-09-09 17:57 ` Ihor Radchenko 2024-09-11 22:33 ` Rudolf Adamkovič 2024-09-15 12:16 ` Ihor Radchenko 2024-12-15 11:32 ` Ihor Radchenko 2024-12-20 20:26 ` Rudolf Adamkovič 2024-12-24 11:22 ` Ihor Radchenko
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.