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

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

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

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

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

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


当前回答

对于Visual Studio Code用户来说,今天(2020年)使用的最佳选择是Markdown All in One插件(扩展)。

要安装它,启动VS Code快速打开(Control/⌘+P),粘贴以下命令,并按enter。

ext install yzhang.markdown-all-in-one

要生成TOC,打开命令面板(Control/⌘+Shift+P),并选择select Markdown:创建内容表选项。


另一个选择是Markdown TOC插件。

要安装它,启动VS Code快速打开(Control/⌘+P),粘贴以下命令,并按enter。

ext install markdown-toc

要生成TOC,打开命令面板(Control/⌘+Shift+P),并选择Markdown TOC:插入/更新选项或使用Control/⌘+MT。

其他回答

这里有一个有用的方法。应该在任何MarkDown编辑器中产生可点击的引用。

# Table of contents
1. [Introduction](#introduction)
2. [Some paragraph](#paragraph1)
    1. [Sub paragraph](#subparagraph1)
3. [Another paragraph](#paragraph2)

## This is the introduction <a name="introduction"></a>
Some introduction text, formatted in heading 2 style

## Some paragraph <a name="paragraph1"></a>
The first paragraph text

### Sub paragraph <a name="subparagraph1"></a>
This is a sub paragraph, formatted in heading 3 style

## Another paragraph <a name="paragraph2"></a>
The second paragraph text

生产:

目录

简介 一些段落 子段 另一个段落

这是介绍

一些介绍文本,格式为标题2的风格

一些段落

第一段文字

子段

这是一个子段落,格式为标题3

另一个段落

第二段文字

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

MultiMarkdown Composer似乎生成了一个目录来辅助编辑。

也可能存在这样或那样的库,它们可以生成TOC:参见Python Markdown TOC扩展。

如果您碰巧使用Eclipse,可以使用Ctrl+O(大纲)快捷键,这将显示相当于目录的内容,并允许在节标题中搜索(自动完成)。

您也可以打开大纲视图(窗口->显示视图->大纲),但它没有自动完成搜索。

您可以尝试使用这个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