소스 검색

Implement offsets for ordered lists

   1. [@start:12] will star a lit a number 12
Carsten Dominik 15 년 전
부모
커밋
b82652d90c
3개의 변경된 파일33개의 추가작업 그리고 9개의 파일을 삭제
  1. 6 0
      lisp/ChangeLog
  2. 10 2
      lisp/org-html.el
  3. 17 7
      lisp/org-latex.el

+ 6 - 0
lisp/ChangeLog

@@ -1,5 +1,11 @@
 2010-04-26  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-latex.el (org-export-latex-lists): Accept ordered list
+	item offset cookie.
+
+	* org-html.el (org-export-as-html): Accept ordered list
+	item offset cookie.
+
 	* org-indent.el (org-indent-mode): Turn off `indent-tabs-mode'
 	which messes up alignment of tags.
 

+ 10 - 2
lisp/org-html.el

@@ -710,7 +710,7 @@ PUB-DIR is set, use this as the publishing directory."
 	 table-buffer table-orig-buffer
 	 ind item-type starter didclose
 	 rpl path attr desc descp desc1 desc2 link
-	 snumber fnc item-tag
+	 snumber fnc item-tag initial-number
 	 footnotes footref-seen
 	 id-file href
 	 )
@@ -1284,7 +1284,11 @@ lang=\"%s\" xml:lang=\"%s\">
 		    starter (if (match-beginning 2)
 				(substring (match-string 2 line) 0 -1))
 		    line (substring line (match-beginning 5))
+		    initial-number nil
 		    item-tag nil)
+	      (if (string-match "\\`\\[@start:\\([0-9]+\\)\\][ \t]?" line)
+		  (setq initial-number (match-string 1 line)
+			line (replace-match "" t t line)))
 	      (if (and starter (string-match "\\(.*?\\) ::[ \t]*" line))
 		  (setq item-type "d"
 			item-tag (match-string 1 line)
@@ -1309,11 +1313,15 @@ lang=\"%s\" xml:lang=\"%s\">
 	       ((and starter
 		     (or (not in-local-list)
 			 (> ind (car local-list-indent))))
+		;; check for a specified start number
 		;; Start new (level of) list
 		(org-close-par-maybe)
 		(insert (cond
 			 ((equal item-type "u") "<ul>\n<li>\n")
-			 ((equal item-type "o") "<ol>\n<li>\n")
+			 ((equal item-type "o")
+			  (if initial-number
+			      (format "<ol start=%s>\n<li>\n" initial-number)
+			    "<ol>\n<li>\n"))
 			 ((equal item-type "d")
 			  (format "<dl>\n<dt>%s</dt><dd>\n" item-tag))))
 		(push item-type local-list-type)

+ 17 - 7
lisp/org-latex.el

@@ -2166,13 +2166,23 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 
 (defun org-export-latex-lists ()
   "Convert plain text lists in current buffer into LaTeX lists."
-  (goto-char (point-min))
-  (while (re-search-forward org-list-beginning-re nil t)
-    (org-if-unprotected
-     (beginning-of-line)
-     (insert (org-list-to-latex (org-list-parse-list t)
-				org-export-latex-list-parameters))
-     "\n")))
+  (let (res)
+    (goto-char (point-min))
+    (while (re-search-forward org-list-beginning-re nil t)
+      (org-if-unprotected
+       (beginning-of-line)
+       (setq res (org-list-to-latex (org-list-parse-list t)
+				    org-export-latex-list-parameters))
+       (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
+			    res)
+	 (setq res (replace-match
+		    (concat (format "\\setcounter{enumi}{%d}"
+				    (1- (string-to-number
+					 (match-string 2 res))))
+			    "\n"
+			    (match-string 1 res))
+		    t t res)))
+       (insert res "\n")))))
 
 (defconst org-latex-entities
  '("\\!"