forked from mirrors/org-mode
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>
This commit is contained in:
parent
54a65250a8
commit
d70a0b6251
|
@ -196,8 +196,9 @@ a communication channel."
|
||||||
(and char (format "[#%c] " char)))))
|
(and char (format "[#%c] " char)))))
|
||||||
(anchor
|
(anchor
|
||||||
(and (plist-get info :with-toc)
|
(and (plist-get info :with-toc)
|
||||||
(org-html--anchor
|
(format "<a id=\"%s\"></a>"
|
||||||
(org-export-get-reference headline info) nil nil info)))
|
(or (org-element-property :CUSTOM_ID headline)
|
||||||
|
(org-export-get-reference headline info)))))
|
||||||
;; Headline text without tags.
|
;; Headline text without tags.
|
||||||
(heading (concat todo priority title))
|
(heading (concat todo priority title))
|
||||||
(style (plist-get info :md-headline-style)))
|
(style (plist-get info :md-headline-style)))
|
||||||
|
@ -213,7 +214,7 @@ a communication channel."
|
||||||
(car (last (org-export-get-headline-number
|
(car (last (org-export-get-headline-number
|
||||||
headline info))))
|
headline info))))
|
||||||
"."))))
|
"."))))
|
||||||
(concat bullet (make-string (- 4 (length bullet)) ? ) heading tags
|
(concat bullet (make-string (- 4 (length bullet)) ?\s) heading tags
|
||||||
"\n\n"
|
"\n\n"
|
||||||
(and contents
|
(and contents
|
||||||
(replace-regexp-in-string "^" " " contents)))))
|
(replace-regexp-in-string "^" " " contents)))))
|
||||||
|
@ -224,7 +225,8 @@ a communication channel."
|
||||||
"\n\n"
|
"\n\n"
|
||||||
contents))
|
contents))
|
||||||
;; Use "atx" style.
|
;; 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
|
;;;; Horizontal Rule
|
||||||
|
|
Loading…
Reference in a new issue