I am using emacs in markdown-mode to preview a markdown document, but there is no a table of contents in the HTML page previewed after typing C-x C-x p.
cat ~/.emacs
(add-to-list 'load-path "~/.emacs.d")
(autoload 'markdown-mode "markdown-mode"
"Major mode for editing Markdown files" t)
(add-to-list 'auto-mode-alist '("\\.markdown\\'" . markdown-mode))
(add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
(autoload 'gfm-mode "markdown-mode"
"Major mode for editing GitHub Flavored Markdown files" t)
(add-to-list 'auto-mode-alist '("README\\.md\\'" . gfm-mode))
(custom-set-variables
'(markdown-command "/usr/bin/pandoc --toc -f markdown_github -t html"))
PS: I can use pandoc command pandoc --toc -f markdown_github
to make a HTML page with a table of contents from a markdown document.
How to solve it? Thx in advanced!
To add a table, use three or more hyphens ( --- ) to create each column's header, and use pipes ( | ) to separate each column. For compatibility, you should also add a pipe on either end of the row. Cell widths can vary, as shown below.
The table of contents (TOC) is implemented as Markdown list. A TOC is just a type of Markdown lists.
It's super easy with the package markdown-toc, in melpa. Just call it with M-x
.
source: http://wikemacs.org/wiki/Markdown#Generate_a_table_of_content
If you have many identical titles, the anchors have to be distinguished, and you'll rely on npm's markdown-toc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With