소스 검색

Merge branch 'master' of orgmode.org:org-mode

Bastien Guerry 12 년 전
부모
커밋
88fd65f251
2개의 변경된 파일61개의 추가작업 그리고 17개의 파일을 삭제
  1. 2 1
      contrib/lisp/org-e-ascii.el
  2. 59 16
      contrib/lisp/org-md.el

+ 2 - 1
contrib/lisp/org-e-ascii.el

@@ -511,7 +511,8 @@ title."
 				   (mapconcat 'identity tag-list ":"))))))
 	 (priority
 	  (and (plist-get info :with-priority)
-	       (concat (org-element-property :priority element) " ")))
+	       (let ((char (org-element-property :priority element)))
+		 (and char (format "(#%c) " char)))))
 	 (first-part (concat numbers todo priority text)))
     (concat
      first-part

+ 59 - 16
contrib/lisp/org-md.el

@@ -32,6 +32,24 @@
 (require 'org-e-html)
 
 
+
+;;; User-Configurable Variables
+
+(defgroup org-export-md nil
+  "Options specific to Markdown export back-end."
+  :tag "Org Markdown"
+  :group 'org-export
+  :version "24.2")
+
+(defcustom org-md-headline-style 'atx
+  "Style used to format headlines.
+This variable can be set to either `atx' or `setext'."
+  :group 'org-export-md
+  :type '(choice
+	  (const :tag "Use \"atx\" style" atx)
+	  (const :tag "Use \"Setext\" style" setext)))
+
+
 
 ;;; Define Back-End
 
@@ -129,22 +147,47 @@ channel."
 CONTENTS is the headline contents.  INFO is a plist used as
 a communication channel."
   (unless (org-element-property :footnote-section-p headline)
-    (let ((level (org-export-get-relative-level headline info))
-	  (title (org-export-data (org-element-property :title headline) info))
-	  (todo (and (plist-get info :with-todo-keywords)
-		     (let ((todo (org-element-property :todo-keyword headline)))
-		       (and todo (org-export-data todo info)))))
-	  (tags (and (plist-get info :with-tags)
-		     (org-export-get-tags headline info)))
-	  (priority (and (plist-get info :with-priority)
-			 (org-element-property :priority headline))))
-      (concat (make-string level ?#)
-	      (and todo (concat " " todo))
-	      (and priority (concat " " priority))
-	      " " title
-	      (and tags (format " :%s:"
-				(mapconcat 'identity tags ":")))
-	      "\n\n" contents))))
+    (let* ((level (org-export-get-relative-level headline info))
+	   (title (org-export-data (org-element-property :title headline) info))
+	   (todo (and (plist-get info :with-todo-keywords)
+		      (let ((todo (org-element-property :todo-keyword
+							headline)))
+			(and todo (concat (org-export-data todo info) " ")))))
+	   (tags (and (plist-get info :with-tags)
+		      (let ((tag-list (org-export-get-tags headline info)))
+			(and tag-list
+			     (format "     :%s:"
+				     (mapconcat 'identity tag-list ":"))))))
+	   (priority
+	    (and (plist-get info :with-priority)
+		 (let ((char (org-element-property :priority headline)))
+		   (and char (format "[#%c] " char)))))
+	   ;; Headline text without tags.
+	   (heading (concat todo priority title)))
+      (cond
+       ;; Cannot create an headline.  Fall-back to a list.
+       ((or (org-export-low-level-p headline info)
+	    (not (memq org-md-headline-style '(atx setext)))
+	    (and (eq org-md-headline-style 'atx) (> level 6))
+	    (and (eq org-md-headline-style 'setext) (> level 2)))
+	(let ((bullet
+	       (if (not (org-export-numbered-headline-p headline info)) "-"
+		 (concat (number-to-string
+			  (car (last (org-export-get-headline-number
+				      headline info))))
+			 "."))))
+	  (concat bullet (make-string (- 4 (length bullet)) ? ) heading tags
+		  "\n\n"
+		  (and contents
+		       (replace-regexp-in-string "^" "    " contents)))))
+       ;; Use "Setext" style.
+       ((eq org-md-headline-style 'setext)
+	(concat heading tags "\n"
+		(make-string (length heading) (if (= level 1) ?= ?-))
+		"\n\n"
+		contents))
+       ;; Use "atx" style.
+       (t (concat (make-string level ?#) " " heading tags "\n\n" contents))))))
 
 
 ;;;; Horizontal Rule