|
@@ -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 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,48 @@ 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 (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)
|
|
|
+ (org-element-property :priority headline)))
|
|
|
+ (heading (concat (and todo (concat " " todo))
|
|
|
+ (and priority (concat " " 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 (and tags (concat " " tags)) "\n\n"
|
|
|
+ (and contents
|
|
|
+ (replace-regexp-in-string "^" " " contents)))))
|
|
|
+ ;; Use "Setext" style.
|
|
|
+ ((eq org-md-headline-style 'setext)
|
|
|
+ (concat heading (and tags (concat " " tags)) "\n"
|
|
|
+ (make-string (length heading) (if (= level 1) ?= ?-))
|
|
|
+ "\n\n"
|
|
|
+ contents))
|
|
|
+ ;; Use "atx" style.
|
|
|
+ (t (concat (make-string level ?#) heading (and tags (concat " " tags))
|
|
|
+ "\n\n"
|
|
|
+ contents))))))
|
|
|
|
|
|
|
|
|
;;;; Horizontal Rule
|