瀏覽代碼

Fix issues with numbering of lists found during odt to doc conversion

* contrib/lisp/org-lparse.el (org-do-lparse): Add new let
bound variable org-lparse-list-level.
(org-lparse-begin-list, org-lparse-end-list): New functions.
(org-lparse-export-list-line, org-lparse-begin-level)
(org-lparse-end-level): Use new functions.

* contrib/lisp/org-odt.el (org-odt-begin-list): Fixed
signature so that it is consistent with how org-lparse library
invokes it. Forcibly emit text:continue-numbering="false"
attribute for the top-level <text:list> element. This fixes
numbering issue found during odt to doc conversion. See
http://thread.gmane.org/gmane.comp.documentfoundation.libreoffice.devel/14739
(org-odt-begin-list-item, org-odt-end-list-item): Use
org-lparse-begin-list and org-lparse-end-list.

* contrib/lisp/org-xhtml.el (org-xhtml-format-toc-item)
(org-xhtml-begin-toc, org-xhtml-end-toc): Use
org-lparse-begin-list and org-lparse-end-list.
(org-xhtml-begin-list): Fixed signature so that it is
consistent with how org-lparse library invokes it.
Jambunathan K 13 年之前
父節點
當前提交
99466ce716
共有 3 個文件被更改,包括 31 次插入18 次删除
  1. 16 4
      contrib/lisp/org-lparse.el
  2. 8 7
      contrib/lisp/org-odt.el
  3. 7 7
      contrib/lisp/org-xhtml.el

+ 16 - 4
contrib/lisp/org-lparse.el

@@ -719,6 +719,9 @@ version."
   (setq-default org-maybe-keyword-time-regexp org-maybe-keyword-time-regexp)
   (let* (org-lparse-encode-pending
 	 org-lparse-par-open
+	 (org-lparse-list-level 0)	; list level starts at 1. A
+					; value of 0 implies we are
+					; outside of any list
 	 org-lparse-outline-text-open
 	 (org-lparse-latex-fragment-fallback ; currently used only by
 					; odt exporter
@@ -1661,7 +1664,7 @@ the alist of previous items."
 	      (org-lparse-end-list-item type)
 	      ;; We're ending last item of the list: end list.
 	      (when lastp
-		(org-lparse-end 'LIST type)
+		(org-lparse-end-list type)
 		(org-lparse-begin-paragraph))))
 	  (funcall get-closings pos))
     (cond
@@ -1690,7 +1693,7 @@ the alist of previous items."
 			  count-tmp)))))
 	(when firstp
 	  (org-lparse-end-paragraph)
-	  (org-lparse-begin 'LIST type))
+	  (org-lparse-begin-list type))
 
 	(let ((arg (cond ((equal type "d") desc-tag)
 			 ((equal type "o") counter))))
@@ -2024,7 +2027,7 @@ When TITLE is nil, just close all open levels."
 	      (org-lparse-end-list-item)
 	    (aset org-levels-open (1- level) t)
 	    (org-lparse-end-paragraph)
-	    (org-lparse-begin 'LIST 'unordered))
+	    (org-lparse-begin-list 'unordered))
 	  (org-lparse-begin
 	   'LIST-ITEM 'unordered target
 	   (org-lparse-format 'HEADLINE title extra-targets tags)))
@@ -2045,7 +2048,7 @@ When TITLE is nil, just close all open levels."
 	     (if (<= l umax)
 		 (org-lparse-end-outline-text-or-outline)
 	       (org-lparse-end-list-item)
-	       (org-lparse-end 'LIST 'unordered))
+	       (org-lparse-end-list 'unordered))
 	     (aset org-levels-open (1- l) nil))))
 
 (defvar org-lparse-outline-text-open)
@@ -2073,6 +2076,15 @@ When TITLE is nil, just close all open levels."
 		      ("u" . unordered)
 		      ("d" . description)))))
 
+(defvar org-lparse-list-level) ; dynamically bound in org-do-lparse
+(defun org-lparse-begin-list (ltype)
+  (incf org-lparse-list-level)
+  (org-lparse-begin 'LIST ltype))
+
+(defun org-lparse-end-list (ltype)
+  (decf org-lparse-list-level)
+  (org-lparse-end 'LIST ltype))
+
 (defvar org-lparse-table-rowgrp-info)
 (defun org-lparse-begin-table-rowgroup (&optional is-header-row)
   (push (cons (1+ org-lparse-table-rownum) :start) org-lparse-table-rowgrp-info)

+ 8 - 7
contrib/lisp/org-odt.el

@@ -564,14 +564,15 @@ PUB-DIR is set, use this as the publishing directory."
      (list))
     (t (error "Unknown environment %s" style))))
 
-(defun org-odt-begin-list (ltype &optional arg1)
+(defvar org-lparse-list-level) ; dynamically bound in org-do-lparse
+(defun org-odt-begin-list (ltype)
   (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
 		  ltype))
   (let* ((style-name (org-odt-get-style-name-for-entity 'list ltype))
-	 (extra (if style-name
-		    (format " text:style-name=\"%s\""  style-name) "")))
-
-    ;; FIXME: Handle arg1 incase of ordered lists.
+	 (extra (concat (when (= org-lparse-list-level 1)
+			  " text:continue-numbering=\"false\"")
+			(when style-name
+			  (format " text:style-name=\"%s\""  style-name)))))
     (case ltype
       ((ordered unordered description)
        (org-lparse-end-paragraph)
@@ -608,7 +609,7 @@ PUB-DIR is set, use this as the publishing directory."
 	 '("<text:list-item>" . "</text:list-item>")
 	 (org-odt-format-stylized-paragraph 'definition-term term)))
        (org-lparse-begin 'LIST-ITEM 'unordered)
-       (org-lparse-begin 'LIST 'description)
+       (org-lparse-begin-list 'description)
        (org-lparse-begin 'LIST-ITEM 'unordered)))
     (t (error "Unknown list type"))))
 
@@ -620,7 +621,7 @@ PUB-DIR is set, use this as the publishing directory."
      (org-lparse-insert-tag "</text:list-item>"))
     (description
      (org-lparse-end-list-item)
-     (org-lparse-end 'LIST 'description)
+     (org-lparse-end-list 'description)
      (org-lparse-end-list-item))
     (t (error "Unknown list type"))))
 

+ 7 - 7
contrib/lisp/org-xhtml.el

@@ -1016,13 +1016,13 @@ that uses these same face definitions."
   (when (> level org-last-level)
     (let ((cnt (- level org-last-level)))
       (while (>= (setq cnt (1- cnt)) 0)
-	(org-lparse-begin 'LIST 'unordered)
+	(org-lparse-begin-list 'unordered)
 	(org-lparse-begin 'LIST-ITEM 'unordered))))
   (when (< level org-last-level)
     (let ((cnt (- org-last-level level)))
       (while (>= (setq cnt (1- cnt)) 0)
 	(org-lparse-end-list-item)
-	(org-lparse-end 'LIST 'unordered))))
+	(org-lparse-end-list 'unordered))))
 
   (org-lparse-end-list-item)
   (org-lparse-begin 'LIST-ITEM 'unordered)
@@ -1034,14 +1034,14 @@ that uses these same face definitions."
    (org-lparse-format 'HEADING lang-specific-heading
 		     (or (org-lparse-get 'TOPLEVEL-HLEVEL) 1)))
   (org-lparse-insert-tag "<div id=\"text-table-of-contents\">")
-  (org-lparse-begin 'LIST 'unordered)
+  (org-lparse-begin-list 'unordered)
   (org-lparse-begin 'LIST-ITEM 'unordered))
 
 (defun org-xhtml-end-toc ()
   (while (> org-last-level (1- org-min-level))
     (setq org-last-level (1- org-last-level))
     (org-lparse-end-list-item)
-    (org-lparse-end 'LIST 'unordered))
+    (org-lparse-end-list 'unordered))
   (org-lparse-insert-tag "</div>")
   (org-lparse-insert-tag "</div>")
 
@@ -1387,12 +1387,12 @@ lang=\"%s\" xml:lang=\"%s\">
 (defun org-xhtml-end-environment (style)
   (org-xhtml-format-environment style 'END))
 
-(defun org-xhtml-begin-list (ltype &optional arg1)
+(defun org-xhtml-begin-list (ltype)
   (setq ltype (or (org-lparse-html-list-type-to-canonical-list-type ltype)
 		  ltype))
-
   (case ltype
-    (ordered (let ((extra (if arg1 (format " start=\"%d\"" arg1) "")))
+    (ordered (let* ((arg1 nil)
+		    (extra (if arg1 (format " start=\"%d\"" arg1) "")))
 	       (org-lparse-insert-tag "<ol%s>" extra)))
     (unordered (org-lparse-insert-tag "<ul>"))
     (description (org-lparse-insert-tag "<dl>"))