开源软件名称(OpenSource Name):ardumont/markdown-toc开源软件地址(OpenSource Url):https://github.com/ardumont/markdown-toc开源编程语言(OpenSource Language):Emacs Lisp 92.8%开源软件介绍(OpenSource Introduction):markdown-tocTable of Contents A simple mode to create TOC in a well-formed markdown file. Note that the TOC is well-formed if the markdown is (cf. #15). UseCreateInside a markdown file, the first time, place yourself where you want to insert the TOC: M-x markdown-toc-generate-toc This will compute the TOC and insert it at current position. You can also execute: M-x markdown-toc-generate-or-refresh-toc to either gnerate a TOC when none exists or refresh the currently existing one. Here is one possible output: <!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**Table of Contents**
- [Use](#use)
- [Create](#create)
- [Update](#update)
- [Create elsewhere](#create-elsewhere)
- [Install](#install)
- [emacs package repository](#emacs-package-repository)
- [Setup](#setup)
- [melpa stable](#melpa-stable)
- [melpa](#melpa)
- [marmalade](#marmalade)
- [Install](#install)
- [emacs-lisp file](#emacs-lisp-file)
- [Inspiration](#inspiration) User toc manipulationIf the user would want to enhance the generated toc, (s)he could use the following function markdown-toc-user-toc-structure-manipulation-fn: It expects as argument the toc-structure markdown-toc uses to generate the toc. The remaining code expects a similar structure. Example: '((0 . "some markdown page title")
(0 . "main title")
(1 . "Sources")
(2 . "Marmalade (recommended)")
(2 . "Melpa-stable")
(2 . "Melpa (~snapshot)")
(1 . "Install")
(2 . "Load org-trello")
(2 . "Alternative")
(3 . "Git")
(3 . "Tar")
(0 . "another title")
(1 . "with")
(1 . "some")
(1 . "heading")) So for example, as asked in #16, one could drop the first element: (custom-set-variables '(markdown-toc-user-toc-structure-manipulation-fn 'cdr)) Or drop all h1 titles... or whatever: (require 'dash)
(custom-set-variables '(markdown-toc-user-toc-structure-manipulation-fn
(lambda (toc-structure)
(-filter (lambda (l) (let ((index (car l)))
(<= 1 index)))
toc-structure))) UpdateTo update the existing TOC, simply execute: M-x markdown-toc-refresh-toc This will update the current TOC. Create elsewhereTo create another updated TOC elsewhere, execute M-x markdown-toc-generate-toc again, this will remove the old TOC and insert the updated one from where you stand. RemoveTo remove a TOC, execute M-x markdown-toc-delete-toc. CustomizeCurrently, you can customize the following:
Customize them as following format: (custom-set-variables
'(markdown-toc-header-toc-start "<!-- customized start-->")
'(markdown-toc-header-toc-title "**customized title**")
'(markdown-toc-header-toc-end "<!-- customized end -->")
'(markdown-toc-indentation-space 4)) Minor modemarkdown-toc-mode provides a minor mode with the following default binding:
To (de)activate this in an org file: /M-x markdown-toc-mode/ You can also use emacs to setup your own bindings. Installemacs package repositoryYou need to add melpa or melpa-stable package repository before installing it. Setupmelpa stable(require 'package)
(add-to-list 'package-archives '("melpa-stable" .
"http://melpa-stable.milkbox.net/packages/"))
(package-initialize) Then hit M-x eval-buffer to evaluate the buffer's contents. melpa(require 'package)
(add-to-list 'package-archives '("melpa" .
"http://melpa.milkbox.net/packages/"))
(package-initialize) Then hit M-x eval-buffer to evaluate the buffer's contents. InstallM-x package-install RET markdown-toc RET emacs-lisp fileRetrieve the markdown-toc.el https://github.com/ardumont/markdown-toc/releases. Then hit M-x package-install-file RET markdown-toc.el RET Inspirationhttps://github.com/thlorenz/doctoc The problem I had with doctoc is the installation process. I do not want to install the node tools just for this. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论