forked from mirrors/org-mode
ox-md.el (org-md-headline): Add anchors when exporting with a table of contents
* ox-md.el (org-md-headline): When exporting with a HTML table of contents, add HTML anchors to Markdown headlines. Thanks to Marko Dimjašević for reporting this.
This commit is contained in:
parent
d8034c3b19
commit
34c2365081
|
@ -182,6 +182,14 @@ a communication channel."
|
||||||
(and (plist-get info :with-priority)
|
(and (plist-get info :with-priority)
|
||||||
(let ((char (org-element-property :priority headline)))
|
(let ((char (org-element-property :priority headline)))
|
||||||
(and char (format "[#%c] " char)))))
|
(and char (format "[#%c] " char)))))
|
||||||
|
(anchor
|
||||||
|
(when (plist-get info :with-toc)
|
||||||
|
(org-html--anchor
|
||||||
|
(or (org-element-property :CUSTOM_ID headline)
|
||||||
|
(concat "sec-"
|
||||||
|
(mapconcat 'number-to-string
|
||||||
|
(org-export-get-headline-number
|
||||||
|
headline info) "-"))))))
|
||||||
;; Headline text without tags.
|
;; Headline text without tags.
|
||||||
(heading (concat todo priority title)))
|
(heading (concat todo priority title)))
|
||||||
(cond
|
(cond
|
||||||
|
@ -202,12 +210,12 @@ a communication channel."
|
||||||
(replace-regexp-in-string "^" " " contents)))))
|
(replace-regexp-in-string "^" " " contents)))))
|
||||||
;; Use "Setext" style.
|
;; Use "Setext" style.
|
||||||
((eq org-md-headline-style 'setext)
|
((eq org-md-headline-style 'setext)
|
||||||
(concat heading tags "\n"
|
(concat heading tags anchor "\n"
|
||||||
(make-string (length heading) (if (= level 1) ?= ?-))
|
(make-string (length heading) (if (= level 1) ?= ?-))
|
||||||
"\n\n"
|
"\n\n"
|
||||||
contents))
|
contents))
|
||||||
;; Use "atx" style.
|
;; Use "atx" style.
|
||||||
(t (concat (make-string level ?#) " " heading tags "\n\n" contents))))))
|
(t (concat (make-string level ?#) " " heading tags anchor "\n\n" contents))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Horizontal Rule
|
;;;; Horizontal Rule
|
||||||
|
|
Loading…
Reference in a new issue