diff --git a/lisp/ox.el b/lisp/ox.el index 2a7e45dde..a6afc304a 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1710,7 +1710,6 @@ Return updated plist." ;; properties. (nconc `(:headline-numbering ,(org-export--collect-headline-numbering data info) - :unnumbered-headline-id ,(org-export--collect-unnumbered-headline-id data info) :exported-data ,(make-hash-table :test 'eq :size 4001)) info)) @@ -1757,17 +1756,6 @@ for a footnotes section." when (> idx relative-level) do (aset numbering idx 0)))))) options))) -(defun org-export--collect-unnumbered-headline-id (data options) - "Return numbering of all exportable, unnumbered headlines. -DATA is the parse tree. OPTIONS is the plist holding export -options. Unnumbered headlines are numbered as a function of -occurrence." - (let ((num 0)) - (org-element-map data 'headline - (lambda (headline) - (unless (org-export-numbered-headline-p headline options) - (list headline (incf num))))))) - (defun org-export--selected-trees (data info) "List headlines and inlinetasks with a select tag in their tree. DATA is parsed data as returned by `org-element-parse-buffer'. @@ -3721,9 +3709,6 @@ process, leading to a different order when footnotes are nested." ;; `org-export-get-headline-number' returns a number to unnumbered ;; headlines (used for internal id). ;; -;; `org-export-get-headline-id' returns the unique internal id of a -;; headline. -;; ;; `org-export-low-level-p', `org-export-first-sibling-p' and ;; `org-export-last-sibling-p' are three useful predicates when it ;; comes to fulfill the `:headline-levels' property. @@ -3757,17 +3742,6 @@ and the last level being considered as high enough, or nil." (let ((level (org-export-get-relative-level headline info))) (and (> level limit) (- level limit)))))) -(defun org-export-get-headline-id (headline info) - "Return a unique ID for HEADLINE. -INFO is a plist holding contextual information." - (let ((numbered (org-export-numbered-headline-p headline info))) - (concat - (if numbered "sec-" "unnumbered-") - (mapconcat #'number-to-string - (if numbered - (org-export-get-headline-number headline info) - (cdr (assq headline (plist-get info :unnumbered-headline-id)))) "-")))) - (defun org-export-get-headline-number (headline info) "Return numbered HEADLINE numbering as a list of numbers. INFO is a plist holding contextual information." diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 891a32876..f92cf230c 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -1946,53 +1946,19 @@ Paragraph[fn:1]" (org-test-with-parsed-data "* Headline" (org-element-map tree 'headline (lambda (h) (org-export-numbered-headline-p h info)) - (plist-put info :section-numbers t))))) - -(ert-deftest test-org-export/org-export-get-headline-id () - "Test `org-export-get-headline-id' specifications." - ;; Numbered headlines have IDs akin to "sec-N". - (should - (equal "sec-1" - (org-test-with-parsed-data "* H" - (org-export-get-headline-id - (org-element-map tree 'headline #'identity info t) - info)))) - ;; The ID of numbered headlines reflect the hierarchy. - (should - (equal "sec-1-1" - (org-test-with-parsed-data "* H1\n** H2" - (org-export-get-headline-id - (org-element-map tree 'headline - (lambda (h) - (and (equal "H2" (org-element-property :raw-value h)) h)) - info t) - info)))) - ;; Unnumbered headlines have IDs akin to "unnumbered-N". - (should - (equal "unnumbered-1" - (org-test-with-parsed-data - "* H\n:PROPERTIES:\n:UNNUMBERED: t\n:END:" - (org-export-get-headline-id - (org-element-map tree 'headline #'identity info t) - info)))) - ;; The ID of Unnumbered headlines do not reflect the hierarchy. - (should - (equal "unnumbered-2" - (org-test-with-parsed-data - "* H1\n:PROPERTIES:\n:UNNUMBERED: t\n:END:\n** H2" - (org-export-get-headline-id - (org-element-map tree 'headline - (lambda (h) - (and (equal "H2" (org-element-property :raw-value h)) h)) - info t) - info)))) - ;; When #+OPTIONS: num:nil all headlines are unnumbered. - (should - (equal "unnumbered-1" - (org-test-with-parsed-data "* H\n#+OPTIONS: num:nil" - (org-export-get-headline-id - (org-element-map tree 'headline 'identity info t) - info)))) + (plist-put info :section-numbers t)))) + ;; With #+OPTIONS: num:nil all headlines are unnumbered. + (should-not + (org-test-with-parsed-data "* H\n#+OPTIONS: num:nil" + (org-export-numbered-headline-p + (org-element-map tree 'headline 'identity info t) + info))) + ;; Headlines with a non-nil UNNUMBERED property are not numbered. + (should-not + (org-test-with-parsed-data "* H\n:PROPERTIES:\n:UNNUMBERED: t\n:END:" + (org-export-numbered-headline-p + (org-element-map tree 'headline #'identity info t) + info))) ;; UNNUMBERED ignores inheritance. Any non-nil value among ;; ancestors disables numbering. (should