diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-09-20 21:50:50 +0200 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2015-09-20 22:58:56 +0200 |
commit | d70a0b62517e71cb62b80ae6227565ffb019f4c1 (patch) | |
tree | 9fd772fc062f3e46cae2235761017541da0ee7ee | |
parent | 54a65250a81a2e230e2760857aa2303836e62ba5 (diff) | |
download | org-mode-d70a0b62517e71cb62b80ae6227565ffb019f4c1.tar.gz |
ox-md: Fix TOC's internal links
* lisp/ox-md.el (org-md-headline): Use CUSTOM-ID when available.
TOC is generated using HTML export back-end, which links to headlines
through their custom ID, when available. By anchoring that custom ID,
we make sure these links are not broken.
Reported-by: dbitouze@wanadoo.fr (Denis Bitouzé)
<http://permalink.gmane.org/gmane.emacs.orgmode/101344>
-rw-r--r-- | lisp/ox-md.el | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lisp/ox-md.el b/lisp/ox-md.el index 2abf189..08358eb 100644 --- a/lisp/ox-md.el +++ b/lisp/ox-md.el @@ -196,8 +196,9 @@ a communication channel." (and char (format "[#%c] " char))))) (anchor (and (plist-get info :with-toc) - (org-html--anchor - (org-export-get-reference headline info) nil nil info))) + (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))) @@ -213,7 +214,7 @@ a communication channel." (car (last (org-export-get-headline-number headline info)))) ".")))) - (concat bullet (make-string (- 4 (length bullet)) ? ) heading tags + (concat bullet (make-string (- 4 (length bullet)) ?\s) heading tags "\n\n" (and contents (replace-regexp-in-string "^" " " contents))))) @@ -224,7 +225,8 @@ a communication channel." "\n\n" contents)) ;; Use "atx" style. - (t (concat (make-string level ?#) " " heading tags anchor "\n\n" contents)))))) + (t (concat (make-string level ?#) " " heading tags anchor "\n\n" + contents)))))) ;;;; Horizontal Rule |