johansatge / obsidian-automatic-table-of-contents Goto Github PK
View Code? Open in Web Editor NEWπ An Obsidian plugin to create a table of contents in a note, that updates itself when the note changes
License: MIT License
π An Obsidian plugin to create a table of contents in a note, that updates itself when the note changes
License: MIT License
Update automatically is convenient, but when my markdown note gets larger, this function will affect the performance of the whole Obsidian application. Hope to give the control of updating ToC to users! Thank you!!
Les services secrets enquΓͺtent sur la tentative dβassassinat de Donald Trump
Hko_android
This is a quick and dirty addition of a title to the TOC plugin, like in Typora.
This how it the TOC block will look after the modification:
Instructions
const
use let
.markdown
.Like this:
Some plugins, eg. Highlightr plugin inject markup via HTML tags which messes up the TOC:
It would be nice if the plugin could strip any HTML tags, a simple regex <(?:"[^"]*"['"]*|'[^']*'['"]*|[^'">])+>
replace to ''
might do it.
Example payload:
<mark style="background: #FFF3A3A6;">Some title</mark>
Preserving the markup as opposed to escaping it would also be nice, but is more a nice to have.
I've got the TOC in my template but don't like the look of the warning when there are no headings.
My proposed solution is a new option that hides the TOC in that case
```table-of-contents
hideWhenEmpty: true
```
which would hide the warning:
Table of contents: no headings found
Dear @johansatge , thanks for the implementation. Very good, works perfectly when exported to PDF. Amazing!
I was wondering: what do you think about adding a parameter to allow the user to define a title? It would turn into a self-contained block.
And what about configuring the size of the border? Right now the block of the TOC has a thick border so, when I add a title before it, the visual is a little strange.
Nonetheless, congratulations and thank you again!
Currently, only unordered lists are supported. I would like support for ordered lists.
The end result would be something like this:
% The code block below
```toc
title: # Table of Contents
style: nestedOrderedList
```
% results in the following toc
# Table of Contents
1. First heading
2. Second Heading
1. First Sub-Heading
2. Second Sub-heading
3. Third Heading
% given these headings in the document
# First heading
# Second Heading
## First Sub-Heading
## Second Sub-heading
# Third Heading
It would be great if the codeblock containing the settings for the TOC could be defined elsewhere, e.g. via the plugin settings page. Then a TOC with a predefined style could be inserted via the Command Palette. The benefit would be that we could insert real Markdown code which would therefore be visible and useable in other Markdown viewers, not only Obsidian, and for example online.
These TOCs inserted via the Command Palette should also be tracked and dynamically updated when headings are added or removed, again with real Markdown, otherwise it would be static and soon outdated.
It would also be cool if a TOC defined via a codeblock could be converted into real Markdown in case you want to export the file or something.
I don't have much experience with your plugin, but it seems like this feature request calls into question what purpose codeblock TOCs would serve if real inserted Markdown would behave the same but with the additional benefit of being portable.
In short, dynamic TOCs are great, but I'd much prefer if it was real Markdown code (VS Code has a plugin which does this FR nicely).
Thanks!
Thanks for this nice Plugin, I got a question, is it possible to make the index and its links clickable in a exported PDF?
It (the links) didn't work for me in the PDF.
It would be nice to have a shorthand trigger phrase toc
instead of table-of-contents
Hello, it is a great honor to use this plug-in you developed on Obsidian.
Here I would like to propose a new idea, you can add a command to document 1 , so that it can generate the directory of document 2γ
In this way, confusion can be avoided when the document is written.
For example: When I edit a document, I have two Windows open at the same time, one to show the directory framework (for example, document 1) and one to write the actual document (for example, document 2).
Thanks again!
Dear all,
The ability to limit minLevel or maxLevel is very useful.
Is it possible to apply the function to Published webpages and mobile?
style: nestedList # TOC style (nestedList|inlineFirstLevel)
minLevel: X # Include headings from the specified level
maxLevel: X # Include headings up to the specified level
includeLinks: true # Make headings clickable
debugInConsole: false # Print debug info in Obsidian console
Thank you!
Thank you for developing this plug-in. When I use automatic-table-of-contents at the beginning of the page, the contents labeled in the following contents disappear in the tag summary. When I removed this directory, the relevant content appeared again in the label usage document statistics.
Greetings,
Ever since the most recent update, whenever I try to generate a simple automatic table of contents, I get this message :
π₯ Could not render table of contents (Invalid regular expression: /[[/gs: Unterminated character class)
I am using Win 10, Obsidian 1.5.3. Here are the other plugins I use :
If your working with multiple files and combining them into a single file. Then the table of content loses purpose as its no longer able to track embedded headings. A solution could be adding an option to add notes:
which the user could link the note they embedded directly, or the plugin could just directly identify the headings inside the embeds and add them into the TOC.
What it could maybe look like?
An example of what the embed could look like:
title:
notes: thisNote, anotherNote, anotherNote # Or maybe it could detect which notes have been embedded in the file and automatically add it in instead of adding it in manually
style: nestedList # TOC style (nestedList|nestedOrderedList|inlineFirstLevel)
minLevel: 0 # Include headings from the specified level
maxLevel: 0 # Include headings up to the specified level
includeLinks: true # Make headings clickable
debugInConsole: false # Print debug info in Obsidian console
Checklist
Otherwise, as right now, the readme wont be shown in obsidian: This plugin did not provide a README file.
The option style: inlineFirstLevel
is great to show the ToC inline, instead of vertically. However, many of my notes do not contain any first level headings at all (because of styling reasons) making this option not work. Would it please be possible to make the option be either something like:
inlineFourthLevel
or adding another option like: inlineLevel: 4
Hello
When headers contain underscore _, the underscore is removed inside the toc.
the toc should keep the underscore that come from the header.
How to reproduce :
Tested on MacOs with obsidian 1.5.12
plugins installed:
Thanks.
Dear @johansatge ,
appreciated, very usefull plugin.
Do you plan to add a minLevel option to exclude the (redundant) title of the document, which is generally at the first level?
Best regards.
Hi and thx for this amazing plugin!
it does not seem to render any color (in html) in the heading names, ie
[travel.Taiwan.2023-09-14](app://obsidian.md/index.html#travel.Taiwan.2023-09-14)
[Visit summary](app://obsidian.md/index.html#Visit%20summary)
[<span style="background:#5ed3ff;color:#ffffff">Sites π½</span>](app://obsidian.md/index.html#%3Cspan%20style=%22background:#5ed3ff;color:#ffffff%22%3ESites%20%F0%9F%97%BD%3C/span%3E)
[<span style="background:#00de79;color:#ffffff">Dishes πΆοΈ</span>](app://obsidian.md/index.html#%3Cspan%20style=%22background:#00de79;color:#ffffff%22%3EDishes%20%F0%9F%8C%B6%EF%B8%8F%3C/span%3E)
[<span style="background:#05aa5e;color:#ffffff">Food π³</span>](app://obsidian.md/index.html#%3Cspan%20style=%22background:#05aa5e;color:#ffffff%22%3EFood%20%F0%9F%8D%B3%3C/span%3E)
[<span style="background:#ff0066;color:#ffffff">Calander π
</span>](app://obsidian.md/index.html#%3Cspan%20style=%22background:#ff0066;color:#ffffff%22%3ECalander%20%F0%9F%93%85%3C/span%3E)
[<span style="background:#ffda36;color:#ffffff">Notes ποΈ</span>](app://obsidian.md/index.html#%3Cspan%20style=%22background:#ffda36;color:#ffffff%22%3ENotes%20%F0%9F%97%92%EF%B8%8F%3C/span%3E)
[<span style="background:#ff00ff;color:#ffffff">Bike π²</span>](app://obsidian.md/index.html#%3Cspan%20style=%22background:#ff00ff;color:#ffffff%22%3EBike%20%F0%9F%9A%B2%3C/span%3E)
Visit summary
Sites π½
is this a bug or is that an inherit limitation in obsidian ?
thx!
Z
I'm using it well.
Automatically creating a TOC is great.
Please add the ability to fold in future upgrades.
Thank you
Simply the ability to open the dynamic ToC for the currently focused file in a dedicated section in the Side Panel.
Higher rank css rules over power the css rule of link causing the display none to be shown.
We should probably add display: none !important;
for the link so that its not over ruled by previous rules.
Solved with a bit of css.
.block-language-table-of-contents li a[style="display: none;"] {
display: none !important;
}
title:
style: nestedOrderedList # TOC style (nestedList|nestedOrderedList|inlineFirstLevel)
minLevel: 0 # Include headings from the specified level
maxLevel: 0 # Include headings up to the specified level
includeLinks: true # Make headings clickable
debugInConsole: false # Print debug info in Obsidian console
Checklist:
Have a " | " character in some titles, and this adds one to the beginning as well
Assuming it's due to how they're parsed(?), but this is a minor bug so feel free to take your time
Hi friend, I love this plugin so much it is awesome. One thing I would love is being able to put the table of contents for a note in a separate note.
The reason being is that I take notes for my lessons and each lesson is in a separate note in a folder for that class. Then I make a quick reference for that folder to quickly get to the chapters I need. But if I make a table of contents inside of a note for another note than that would be perfect! You could include the specific note or notes that you would like to make that table of contents for in the code block and then it would go through like normal.
Thanks again for your great plugin!
Have a great day.
It would be a lot neater to have a way of setting defaults for this addition.
For example, basically all of my notes have a top-level h1
, so I'd prefer to hide these from the TOCs generated. I can add minLevel: 2
in each codeblock, but setting them for my entire workspace would be a lot cleaner. I can imagine that this can be useful for other settings as well
Hi, interesting concept, but doesn't it run with android 11 yet?
Hi. It would be useful to be able to exclude a specific heading by text. The ideal API would be as follows (the last line):
style: nestedList
exclude: ["Contents", "References"]
This would then hide only the subheadings called "Contents" and "References" from the rendered TOC. An alternative syntax would be to use regex.
For a real-world example of how this would work in other systems, check out Confluence's Table of Contents macro (screenshot below).
Hi,
I'd like to be able to set a "starting point" for the table of contents. Say I do not want the first h1 and sub headings to be part of the toc. Ex:
# document information
## table of contents
``table-of-contents
first-heading: 2
``
## changelog
## other stuff
# first section in toc
## etc
# second section in toc
## etc
Would result in table of contents starting from "first section in toc":
Hope this makes sense. Thanks.
Headings with links displayed incorrectly and non-functional navigation:
### [[CSharp#|C#]] Process Injection:
[}} Process Injection:](app://obsidian.md/index.html#{{CSharp#-C#}}%20Process%20Injection:)
}} Process Injection:
and navigation does not workHeadings with bold or italic:
## AV Signature Detection Bypass: **Custom Runner and Obfuscated Shellcode**
[AV Signature Detection Bypass: **Custom Runner and Obfuscated Shellcode**](app://obsidian.md/index.html#AV%20Signature%20Detection%20Bypass:%20**Custom%20Runner%20and%20Obfuscated%20Shellcode**)
Id love to have the ability of being able to generate the TOC from "note1.md" into "note2.md". Useful for a "overview" document.
If you've generated a Table of Contents (TOC), whether normal or documented, within a note and pinned that note, clicking any entry from the generated TOC will open a new tab with the location instead of navigating to the heading within the currently opened document.
Please see the attached screen recording below:
I don't know if its possible, but i have a long doc that display lots of embeded notes ( ![[Note1.md]] ).
I want to make a TOC who can display even the title in the embeded
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.