summaryrefslogtreecommitdiff
path: root/lisp/ox-md.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ox-md.el')
-rw-r--r--lisp/ox-md.el38
1 files changed, 26 insertions, 12 deletions
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index b8c4704..c8ea1fa 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -1,6 +1,6 @@
;;; ox-md.el --- Markdown Back-End for Org Export Engine -*- lexical-binding: t; -*-
-;; Copyright (C) 2012-2016 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2017 Free Software Foundation, Inc.
;; Author: Nicolas Goaziou <n.goaziou@gmail.com>
;; Keywords: org, wp, markdown
@@ -59,7 +59,7 @@ The first %s placeholder will be replaced with the localized Footnotes section
heading, the second with the contents of the Footnotes section."
:group 'org-export-md
:type 'string
- :version "25.2"
+ :version "26.1"
:package-version '(Org . "9.0"))
(defcustom org-md-footnote-format "<sup>%s</sup>"
@@ -67,7 +67,7 @@ heading, the second with the contents of the Footnotes section."
The %s will be replaced by the footnote reference itself."
:group 'org-export-md
:type 'string
- :version "25.2"
+ :version "26.1"
:package-version '(Org . "9.0"))
@@ -217,11 +217,6 @@ a communication channel."
(and (plist-get info :with-priority)
(let ((char (org-element-property :priority headline)))
(and char (format "[#%c] " char)))))
- (anchor
- (and (plist-get info :with-toc)
- (format "<a id=\"%s\"></a>"
- (or (org-element-property :CUSTOM_ID headline)
- (org-export-get-reference headline info)))))
;; Headline text without tags.
(heading (concat todo priority title))
(style (plist-get info :md-headline-style)))
@@ -239,10 +234,29 @@ a communication channel."
"."))))
(concat bullet (make-string (- 4 (length bullet)) ?\s) heading tags "\n\n"
(and contents (replace-regexp-in-string "^" " " contents)))))
- (t (concat (org-md--headline-title style level title anchor tags) contents))))))
-
-
-;; Headline Title
+ (t
+ (let ((anchor
+ (and (org-md--headline-referred-p headline info)
+ (format "<a id=\"%s\"></a>"
+ (or (org-element-property :CUSTOM_ID headline)
+ (org-export-get-reference headline info))))))
+ (concat (org-md--headline-title style level title anchor tags)
+ contents)))))))
+
+
+(defun org-md--headline-referred-p (headline info)
+ "Non-nil when HEADLINE is being referred to.
+INFO is a plist used as a communication channel. Links and table
+of contents can refer to headlines."
+ (or (plist-get info :with-toc)
+ (org-element-map (plist-get info :parse-tree) 'link
+ (lambda (link)
+ (eq headline
+ (pcase (org-element-property :type link)
+ ((or "custom-id" "id") (org-export-resolve-id-link link info))
+ ("fuzzy" (org-export-resolve-fuzzy-link link info))
+ (_ nil))))
+ info t)))
(defun org-md--headline-title (style level title &optional anchor tags)
"Generate a headline title in the preferred Markdown headline style.