Markdown to create pages and table of contents?

后端 未结 30 2413
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 08:49

I started to use markdown to take notes.

I use marked to view my markdown notes and its beautiful.

But as my notes get longer I find it diff

相关标签:
30条回答
  • If you happen to use Eclipse you can use the Ctrl+O (outline) shortcut, this will show the equivalent of the table of contents and allow to search in section titles (autocomplete).

    You can also open the Outline view (Window -> Show View -> Outline) but it has no autocomplete search.

    0 讨论(0)
  • 2020-12-12 09:26

    There is a Ruby script called mdtoc.rb that can auto-generate a GFM Markdown Table of Contents, and it is similar but slightly different to some other scripts posted here.

    Given an input Markdown file like:

    # Lorem Ipsum
    
    Lorem ipsum dolor sit amet, mei alienum adipiscing te, has no possit delicata. Te nominavi suavitate sed, quis alia cum no, has an malis dictas explicari. At mel nonumes eloquentiam, eos ea dicat nullam. Sed eirmod gubergren scripserit ne, mei timeam nonumes te. Qui ut tale sonet consul, vix integre oportere an. Duis ullum at ius.
    
    ## Et cum
    
    Et cum affert dolorem habemus. Sale malis at mel. Te pri copiosae hendrerit. Cu nec agam iracundia necessitatibus, tibique corpora adipisci qui cu. Et vix causae consetetur deterruisset, ius ea inermis quaerendum.
    
    ### His ut
    
    His ut feugait consectetuer, id mollis nominati has, in usu insolens tractatos. Nemore viderer torquatos qui ei, corpora adipiscing ex nec. Debet vivendum ne nec, ipsum zril choro ex sed. Doming probatus euripidis vim cu, habeo apeirian et nec. Ludus pertinacia an pro, in accusam menandri reformidans nam, sed in tantas semper impedit.
    
    ### Doctus voluptua
    
    Doctus voluptua his eu, cu ius mazim invidunt incorrupte. Ad maiorum sensibus mea. Eius posse sonet no vim, te paulo postulant salutatus ius, augue persequeris eum cu. Pro omnesque salutandi evertitur ea, an mea fugit gloriatur. Pro ne menandri intellegam, in vis clita recusabo sensibus. Usu atqui scaevola an.
    
    ## Id scripta
    
    Id scripta alterum pri, nam audiam labitur reprehendunt at. No alia putent est. Eos diam bonorum oportere ad. Sit ad admodum constituto, vide democritum id eum. Ex singulis laboramus vis, ius no minim libris deleniti, euismod sadipscing vix id.
    

    It generates this table of contents:

    $ mdtoc.rb FILE.md 
    #### Table of contents
    
    1. [Et cum](#et-cum)
        * [His ut](#his-ut)
        * [Doctus voluptua](#doctus-voluptua)
    2. [Id scripta](#id-scripta)
    

    See also my blog post on this topic.

    0 讨论(0)
  • 2020-12-12 09:31

    Typora generates Table of Content by adding [TOC] to your document.

    0 讨论(0)
  • 2020-12-12 09:32

    Here's a useful method. Should produce clickable references in any MarkDown editor.

    # 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
    

    Produces:

    Table of contents

    1. Introduction
    2. Some paragraph
      1. Sub paragraph
    3. Another paragraph

    This is the introduction

    Some introduction text, formatted in heading 2 style

    Some paragraph

    The first paragraph text

    Sub paragraph

    This is a sub paragraph, formatted in heading 3 style

    Another paragraph

    The second paragraph text

    0 讨论(0)
  • 2020-12-12 09:32

    If you want to use a javascript/node.js tool, take a look at markdown-toc.

    0 讨论(0)
  • 2020-12-12 09:33

    Anchor tags generated by different Markdown parsers are not even.

    If you are working with Markdown parsers GFM (GitHub Flavored Markdown) or Redcarpet, I wrote a Vim plugin to handle table of contents.

    Features

    1. Generate table of contents for Markdown files.

      Supported Markdown parsers:

      • GFM (GitHub Flavored Markdown)
      • Redcarpet
    2. Update existing table of contents.

    3. Auto update existing table of contents on save.

    Screenshots

    vim-markdown-toc

    Usage

    Generate table of contents

    Move the cursor to the line you want to append table of contents, then type a command below suit you. The command will generate headings after the cursor into table of contents.

    1. :GenTocGFM

      Generate table of contents in GFM link style.

      This command is suitable for Markdown files in GitHub repositories, like README.md, and Markdown files for GitBook.

    2. :GenTocRedcarpet

      Generate table of contents in Redcarpet link style.

      This command is suitable for Jekyll or anywhere else use Redcarpet as its Markdown parser.

      You can view here to know differences between GFM and Redcarpet style toc links.

    Update existing table of contents manually

    Generally you don't need to do this, existing table of contents will auto update on save by default. If you want do it manually, just use :UpdateToc command.

    Downloads and documents

    https://github.com/mzlogin/vim-markdown-toc

    0 讨论(0)
提交回复
热议问题