mirror of
https://github.com/m-kk/toc.git
synced 2026-07-22 06:44:17 +00:00
No description
Address plugin review requirement to use sentence case for all UI text. Updated ribbon icon tooltip, setting descriptions, and placeholders to follow lowercase convention (e.g., "table of contents" instead of "Table of Contents"). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .github | ||
| .editorconfig | ||
| .eslintignore | ||
| .eslintrc | ||
| .gitignore | ||
| .npmrc | ||
| esbuild.config.mjs | ||
| LICENSE.md | ||
| main.ts | ||
| manifest.json | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| styles.css | ||
| tsconfig.json | ||
| version-bump.mjs | ||
| versions.json | ||
Table of Contents Generator
A modern Obsidian plugin that generates clean, trackable table of contents using frontmatter metadata. Creates invisible TOC markers without cluttering your source view, with advanced configuration options and automatic updates.
Features
Core Functionality
- Invisible Markers: No visible HTML comments - uses YAML frontmatter exclusively for TOC tracking
- Smart Positioning: Intelligent TOC placement at document start or after the last H1 heading
- Automatic Updates: Debounced auto-updates when document changes (configurable)
- Clean Integration: Works seamlessly with Obsidian's metadata cache system
Advanced Configuration
- Heading Depth Control: Exclude H1 headings and set maximum depth (1-6)
- Pattern Exclusion: Regex patterns to exclude specific headings (with ReDoS protection)
- Link Options: Toggle clickable TOC links to headings
- Custom TOC Title: Personalize your table of contents heading
- Duplicate Handling: Smart handling of duplicate heading names
Developer Features
- Debug Command: Built-in TOC marker debugging for troubleshooting
- TypeScript Support: Full type safety with comprehensive interfaces
- Service Architecture: Clean separation of concerns with dedicated service classes
Installation
From Obsidian Community Plugins
- Open Obsidian Settings → Community Plugins
- Disable Safe Mode if needed
- Search for "Table of Contents Generator"
- Install and enable the plugin
Manual Installation
- Download the latest release from GitHub
- Extract files to
.obsidian/plugins/table-of-contents-generator/ - Enable the plugin in Community Plugins settings
Usage
Basic Usage
- Open any note with headings
- Run command
Generate table of contentsor click the TOC ribbon icon - The TOC will be intelligently positioned at document start or after the last H1 heading
Generated TOC Example
---
toc:
generated: true
lastUpdate: "2025-01-15T10:30:00Z"
---
## Table of Contents
- [[#Introduction|Introduction]]
- [[#Getting Started|Getting Started]]
- [[#Advanced Features|Advanced Features]]
- [[#Configuration Options|Configuration Options]]
Configuration Options
Access settings via Settings → Community Plugins → Table of Contents Generator
Content Settings
- TOC Title: Customize the heading text (default: "Table of Contents")
- Include Links: Toggle clickable navigation links to headings
- Exclude H1: Skip document title headings from TOC
- Maximum Depth: Limit heading levels (1-6, default: 4)
Positioning
- Smart Positioning: Automatically places TOC at document start or after the last H1 heading
Filtering & Updates
- Exclude Patterns: Regex patterns to skip specific headings
- Auto-Update: Automatically refresh TOC when document changes
- ReDoS Protection: Safe regex validation prevents performance issues
Commands
- Generate table of contents: Insert or refresh the TOC for the active note
- Debug TOC metadata: Diagnostic tool to inspect TOC state and troubleshoot issues
Technical Details
Frontmatter Metadata
The plugin tracks TOC state using minimal YAML frontmatter:
---
toc:
generated: true # TOC exists in document
lastUpdate: "2025-01-15T10:30:00Z" # ISO timestamp of last update
---
Architecture
- Performance Optimized: 75% reduction in regex operations with pre-compiled patterns
- Security Hardened: Comprehensive ReDoS protection against 10+ dangerous patterns
- Service-Oriented Design: Modular components with centralized TOC detection logic
- TypeScript: Full type safety with strict compliance and modern ES2020 features
- Memory Efficient: Proper cleanup, surgical updates, and optimized string operations
- Modern Build System: esbuild with security-focused dependencies and zero runtime deps
Feedback
Support
If you find this plugin useful, consider a donation! Thank you!
