TOC compatible with Publish

approved

by Brian Collery

This generates a table of contents that is compatible with publish.

13 stars1,340 downloadsUpdated 3mo ago0BSD
View on GitHub

Automatic Table of contents plugin

Version Downloads

Table of contents plugin that will be compatible with Publish.

How to use

When the plugin is installed. press Ctrl + p to open the command window and then type create table of contents. For now this will create a table of contents for a file at the top of the file.

You can create a table of contents at the cursor by using the create table of contents at cursor command.

This table will update after you update a title. It does not do it after every keystroke though. If you change a title and then add text to a new line it may update then. Note that if there is an issue with updating, there is a command to update the table called update the table of contents.

Set Up

You can adjust a some of the settings for your table of contents. Note that most settings do not adjust table of contents that have already been made. Those you will have to update manually. The one exception to this is the list of characters you want to remove from titles.

Arrow labels

Current arrow Choices:

  • Numbers: Index
  • Arrows: >
  • Bullet Points: -

This plugin allows you to create a table of contents that automatically updates and allows different arrow types or titles. The default arrow type is to number the entries in the table of contents. You can change it to bullet points with - or you can choose to have > as your arrow type. Below is how you change the default arrow types.

Note that this will not change the arrow types of the table of contents you have already made. You can change those manually as in the Table of contents header comment, there is the arrow type option. You can manually change that to the list type that you want.

Title Change

Changing the default title has a similar approach. You can change the default table of contents in the setting folder.

Note that you can still change individual titles on pages. The title on each page can be unique.

Code Blocks

Some code blocks can be include comments that could be taken as a heading. For instance, in python comments are indicated with a #. To remove this line from our list on the table of contents, change the code blocks property to y to remove them from the table of contents.

Note that this action is pointless if you don't have codeblocks in your notes. The default setting on these notes is n for no. If you regularly use code blocks in your notes, you should probably set the default to yes.

Note that this only effects future table of contents. You will have to manually alter tables that were already created.

Style Choices

Create the gifs for

Character Removal from titles

If you wish to have text effect in titles but not have those characters show up in the table of contents, put them into the list of characters to remove from the title. Lets start with an example.

One instance is if you wish to italicise a word in a title. We do this using two astericks on either side of the words we want to see in italics.The italics will show up in the table of contents.

To remove this, put pairs of italics in the list of removed characters. Then the table of contents will no longer show those characters. Note that * have a purpose in Regex expressions so escape characters are inserted to make sure you are removing the asteriks.

Indentation

Indentation starts with the shortest headings

Indentation will start with the level you choose to start with.

Indentation levels are accounted for

Accounts for depths you introduce.

Road map

  • Create a first version of the plugin. This should just be able to make a table of contents.
  • Create Demonstration file.
  • Add a feature to allow for updating the table of contents.
  • Create a feature that allows the app to recognise that there is a table of contents. This will allow the plugin to update the toc in a manner that will be recognised by obsidian publish.
  • Add a feature that will automatically update the table of contents.
  • Allow for different formats of table of contents.
  • Allow for titles with footnotes or links to be referenced. (credit to u/spud80)

Changelog

This project uses semver.

versionDateNotes
3.2.02025-12-26Automatically removes text styling and footnotes from titles
3.1.02025-11-20Added a command to update toc
3.0.42025-11-19Extended escaped character list
3.0.32025-11-17Fixed regex expression to allow more escaped characters be matched
3.0.22025-11-14Fixed regex expressions to allow matching asterisks
3.0.12025-11-13Reduced unneccessary TOC checks
3.0.02025-11-13Can now create a list of characters that won't be displayed in the toc
2.5.12025-11-12If no headings start with #, push the table of contents back
2.5.02025-11-12Allows altered indents in the table of contents
2.4.4 2025-11-12Can remove codeBlocks from toc
2.4.32025-11-09Allow manual changes of title
2.4.22025-11-08Can manually set title for TOC
2.4.12025-11-07Fixed a spacing issue with the new arrow types
2.4.02025-11-07New arrow types and added a setting tab
2.3.42025-11-05Added create TOC at cursor
2.3.3Fixed a minor bug
2.3.22025-07-03No longer modifies the table if nothing has changed
2.3.12025-06-30Fixed a bug that sometimes clipped words people are writing
2.3.02025-06-23No longer adds headings in callouts or quotes
2.2.02025-05-05TOC automatically updates
2.1.02024-12-22Added title to TOC
2.0.02024-12-17Allows toc to be updated
1.1.02024-12-7First Release
1.0.02024-12-5Sample Plugin

License

This project is released under the MIT License.

Support

Buy Me A Coffee

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.