emacs-orgmode
[Top][All Lists]
Advanced

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

[O] [PATCH] org-html: Fix logic for export of section numbers


From: Lawrence Mitchell
Subject: [O] [PATCH] org-html: Fix logic for export of section numbers
Date: Tue, 29 Mar 2011 09:30:27 +0100
User-agent: Gnus/5.110014 (No Gnus v0.14) Emacs/24.0.50 (gnu/linux)

* lisp/org-html.el (org-export-as-html) (org-html-level-start): Fix
logic for section number printing when NUM is an integer.

Fixes a bug introduced in 9f57b8e which considered all non-integer
values of the num option to be nil.
---
Bernt Hansen wrote:

> Hi Lawrence,

> Numbering of the Table of Contents is broken in master for HTML export.
> git bisect identifies the following commit as the cause of this regression.

Indeed, I introduced a logic error that considered non-integer
values of the num option as nil even when non-nil.  I believe
this patch fixes the problem, your test case now works as
expected again.

Cheers,
Lawrence

 lisp/org-html.el |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lisp/org-html.el b/lisp/org-html.el
index 62fce1b..48b6740 100644
--- a/lisp/org-html.el
+++ b/lisp/org-html.el
@@ -1356,7 +1356,9 @@ lang=\"%s\" xml:lang=\"%s\">
                                   (if (string-match quote-re0 txt)
                                       (setq txt (replace-match "" t t txt)))
                                   (setq snumber (org-section-number level))
-                                  (if (and num (integerp num) (>= num level))
+                                  (if (and num (if (integerp num)
+                                                   (>= num level)
+                                                 num))
                                       (setq txt (concat snumber " " txt)))
                                   (if (<= level (max umax umax-toc))
                                       (setq head-count (+ head-count 1)))
@@ -2404,16 +2406,16 @@ When TITLE is nil, just close all open levels."
            (setq title (concat
                         (format "<span class=\"section-number-%d\">%s</span>"
                                 level
-                                (if (and (integerp num)
-                                         ;; fix up num to take into
-                                         ;; account the top-level
-                                         ;; heading value
-                                         (>= (+ num
-                                                org-export-html-toplevel-hlevel
-                                                -1)
-                                             level))
-                                          snumber
-                                        ""))
+                                (if (and num
+                                         (if (integerp num)
+                                             ;; fix up num to take into
+                                             ;; account the top-level
+                                             ;; heading value
+                                             (>= (+ num 
org-export-html-toplevel-hlevel -1)
+                                                 level)
+                                           num))
+                                    snumber
+                                  ""))
                         " " title)))
        (unless (= head-count 1) (insert "\n</div>\n"))
        (setq href (cdr (assoc (concat "sec-" snu) 
org-export-preferred-target-alist)))
-- 
1.7.4.rc2.18.gb20e9



reply via email to

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