Giter Site home page Giter Site logo

potato-indexer's Introduction

Potato Indexer

It was pointed out that the correct term is Table of Contents, so if you see indexer/index anywhere just know that it means Table of Contents. Sorry for the confusion :)


If you've ever needed an easy way to generate a table of contents for your note or for a sub-section of your note, then you're in luck!

With this super simple plugin all you have to do is open the command palette, Ctrl(on MacOS CMD) + P, and search for potato indexer.

Two commands will show:

  • Generate table of contents for current note
  • Generate table of contents for selected content. This requires you to select the existing index in case of an update.

Pick whichever suits your needs at that moment.

potato-indexer's People

Contributors

loyalpotato avatar

Stargazers

gapmiss avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

potato-indexer's Issues

Add button to reset setting to default

Obsidian has this for a few of their settings.
It's using lucide-rotate-ccw as an icon.

You can probably find out how it works by looking into the source code (search the icon above) in the developer console of obsidian

Updating indexer removes newline or line

For example:

Testing

  • A
  • B

Content Index

...


Running the update the index of the note again will put it as this:

  • B## Content Index

And once more, will delete that line.

Generate the correct amount of tabs

When generating the tabs, do it based on how many titles there are. If I select a h2 title and h3 it will have two tabs instead of 1 and 2

Could you add a setting to choose a stop header size to the indexer?

What I mean by this is that the indexer generates links for every header, which would be fine.

Though in my use-case it would be much more legible and useful if I could limit the indexer to only link headers from H1 to H4, since the I often use smaller headers like H5 and H6 for legibility on the note and have to manually erase them from the generated index.

Not sure if this is where I should write this suggestion, but thank you for the tool regardless!!

difference between table of contents and index

Unless I am deceived, you are generating a table of contents, not an index.
A table of contents is a sequential list of all the headings in a document.
An index is a list of all the significant words in a document cross-referenced to their position in the document.

This is confusing, as these are entirely separate things.

Incorrect tab depth for first header

Given the following example:

### A
### B
### C

Selecting them and running the create index for selection cmd, will produce the following (_ represents a tab):

## Content Index

- [A](###A)
__- [B](###B)
__- [C](###C)

This also occurs when indexing the whole note.

##### One

## Content Index

- [One](#####One)
__- [Two](##Two)

## Two

Index falls below the first H1

          Currently in Potato Indexer 1.1.1 and Obsidian 1.4.16 index falls below the first H1 

To replicate -

Create new Document
Name Document
Create H1 Headings
Generate index for current note
Index falls below first H1

First

Content Index

some content

Second

Some Content

Third

Some Content

It may have something to do with how Obsidian handles Titles
Since it automatically inserts the first H1 as the title does not show the first H1 and the first actual H1 is interpreted as the title.

I'm not familiar enough with typescript to make a pull request unfortunately but I think it is here. You can just seek first H1 nd then add index above

indexSvc.ts

  const lines = content.split("\n");
  let index = "\n## Content Index\n\n";
  const indexPos: number[] = [];

and also .editorconfig

# top-most EditorConfig file
root = true

Originally posted by @synj00 in #3 (comment)

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.