我开始使用标记来做笔记。

我用标记来查看我的笔记,它很漂亮。

但是随着我的笔记变长,我发现很难找到我想要的东西。

我知道markdown可以创建表,但它是否能够创建目录,跳转到部分,或定义页面部分markdown?

或者,是否有降价阅读器/编辑器可以做这些事情。搜索也是一个不错的功能。

简而言之,我想让它成为我很棒的笔记工具,功能就像写一本书一样。


当前回答

我只是开始做同样的事情(在Markdown做笔记)。我使用Sublime Text 2和MarkdownPreview插件。内置markdown解析器支持[TOC]。

其他回答

你可以试一试。

# Table of Contents
1. [Example](#example)
2. [Example2](#example2)
3. [Third Example](#third-example)
4. [Fourth Example](#fourth-examplehttpwwwfourthexamplecom)


## Example
## Example2
## Third Example
## [Fourth Example](http://www.fourthexample.com) 

作为手工制作链接列表的替代方案,让我们概述所有可用的开箱即用的解决方案来插入目录(请评论和扩展以保持最新):

在咕噜5版本中,markdown支持这一点:

<!-- assure you have a blank line before -->
[[_TOC_]]

这也适用于Azure DevOps wiki。


由于Gitlab将降价引擎从Redcarpet切换到Kramdown,他们现在支持以下语法

- TOC
{:toc}

看到https://about.gitlab.com/handbook/markdown-guide/ table-of-contents-toc


MultiMarkdown在4.7有一个下面的宏:

{{TOC}}

根据Jannik的回答: 如果你的Markdown文件是显示在bitbucket.org上的回购,你可以在你想要你的目录(更多信息在这里)的位置使用以下:

[TOC]

根据Paul Jurczak的回答: 当您在文档中写入[TOC]时,Markdown编辑器Typora也会生成一个目录。


我知道,我的回答有点晚了。然而,我自己却错过了这样一个概述。我对尼古拉斯·特里的回答进行了编辑,将其扩展为概述,但被拒绝了。

下面是一个生成目录的简单bash脚本。不需要特殊的依赖项,只需要bash。

https://github.com/Lirt/markdown-toc-bash

它可以很好地处理标题内的特殊符号,标记标题中的链接和忽略代码块。

您可以尝试使用这个ruby脚本从标记文件生成TOC。

 #!/usr/bin/env ruby

require 'uri'

fileName = ARGV[0]
fileName = "README.md" if !fileName

File.open(fileName, 'r') do |f|
  inside_code_snippet = false
  f.each_line do |line|
    forbidden_words = ['Table of contents', 'define', 'pragma']
    inside_code_snippet = !inside_code_snippet if line.start_with?('```')
    next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ } || inside_code_snippet

    title = line.gsub("#", "").strip
    href = URI::encode title.gsub(" ", "-").downcase
    puts "  " * (line.count("#")-1) + "* [#{title}](\##{href})"
  end
end

有两种方法可以在你的降价文档中创建你的TOC(摘要)。

1. 手动

# My Table of content
- [Section 1](#id-section1)
- [Section 2](#id-section2)

<div id='id-section1'/>
## Section 1
<div id='id-section2'/>
## Section 2

2. 以编程方式

例如,你可以使用一个脚本,为你生成摘要,看看我的项目在github - summarizeMD -

我也尝试过其他脚本/npm模块(例如doctoc),但没有人用工作锚重现TOC。