Function: org-md--build-toc
org-md--build-toc is a byte-compiled function defined in ox-md.el.gz.
Signature
(org-md--build-toc INFO &optional N KEYWORD SCOPE)
Documentation
Return a table of contents.
INFO is a plist used as a communication channel.
Optional argument N, when non-nil, is an integer specifying the depth of the table.
When optional argument SCOPE is non-nil, build a table of contents according to the specified element.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-md.el.gz
(defun org-md--build-toc (info &optional n _keyword scope)
"Return a table of contents.
INFO is a plist used as a communication channel.
Optional argument N, when non-nil, is an integer specifying the
depth of the table.
When optional argument SCOPE is non-nil, build a table of
contents according to the specified element."
(concat
(unless scope
(let ((level (plist-get info :md-toplevel-hlevel))
(style (plist-get info :md-headline-style))
(title (org-html--translate "Table of Contents" info)))
(org-md--headline-title style level title nil)))
(mapconcat
(lambda (headline)
(let* ((indentation
(make-string
(* 4 (1- (org-export-get-relative-level headline info)))
?\s))
(bullet
(if (not (org-export-numbered-headline-p headline info)) "- "
(let ((prefix
(format "%d." (org-last (org-export-get-headline-number
headline info)))))
(concat prefix (make-string (max 1 (- 4 (length prefix)))
?\s)))))
(title
(format "[%s](#%s)"
(org-export-data-with-backend
(org-export-get-alt-title headline info)
(org-export-toc-entry-backend 'md)
info)
(or (org-element-property :CUSTOM_ID headline)
(org-export-get-reference headline info))))
(tags (and (plist-get info :with-tags)
(not (eq 'not-in-toc (plist-get info :with-tags)))
(org-make-tag-string
(org-export-get-tags headline info)))))
(concat indentation bullet title tags)))
(org-export-collect-headlines info n scope) "\n")
"\n"))