GithubHelp home page GithubHelp logo

Comments (6)

thlorenz avatar thlorenz commented on June 8, 2024

doctoc places the TOC always on top of the file and includes the main title like you described.
I usually go in and edit the file afterwards.

Since the toc is always on top it helps doctoc to replace it with an updated one if necessary see here.

This could be improved however and I'd love to see and pull in contributions that improve this.

from doctoc.

lazd avatar lazd commented on June 8, 2024

It would be nice to see the table of contents go under the heading and quote:

# My Cool Project
> Definitely the coolest thing since the ice age

## How to be cool

There's only one rule: act cool.

## When it's not cool to be cool

Funerals.

When toc'd, I'd like to see:

# The Cool Project
> Definitely the coolest thing since the ice age

- [The Cool Project](#the-cool-project)
    - [How to be cool](#the-art-of-being-cool)
    - [When it's not cool to be cool](#when-its-not-cool-to-be-cool)

## How to be cool

There's only one rule: act cool.

## When it's not cool to be cool

Funerals.

from doctoc.

thlorenz avatar thlorenz commented on June 8, 2024

Actually in that case The Cool Project should probably not be part of the toc, since the toc is below that heading, don't you think?
So if we'd omit that, we would possibly have to adjust indentation level as well.

This could easily be implemented, i.e.. with update-section, we just have the hash out all the edge cases like the ones I just mentioned first.

from doctoc.

lazd avatar lazd commented on June 8, 2024

Yeah, I totally agree -- The Cool Project shouldn't be part of the TOC.

from doctoc.

thlorenz avatar thlorenz commented on June 8, 2024

Ok, and I this will already take care of correct indentation even if there is no # header.

So this should be fairly simple with the update-section module I mentioned above. I'm a bit swamped right now so it may be a while.
However any PR that beats me to it along with nice tests will be very welcome ;)

from doctoc.

thlorenz avatar thlorenz commented on June 8, 2024

This fix has been published with 0.5.1. doctoc now replaces existing tocs instead of always adding a new one to the top of the file.

from doctoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.