How svonjoi/obsidian-heading-level-indent works
1. Project type and runtime
- This is an Obsidian community plugin written in TypeScript.
- It runs inside the Obsidian desktop app and augments note rendering/editing rather than serving a standalone UI.
2. Core purpose
- The plugin adds visual indentation to content under Markdown headings so document hierarchy is easier to scan.
- Indentation is based on heading level and can be customized through plugin settings.
3. Primary entrypoint
- src/main.ts is the plugin bootstrap and central coordinator.
- It is responsible for loading settings, registering listeners/hooks, and wiring the plugin’s editing and reading-view behavior into Obsidian.
4. Runtime subsystems
- src/editingMode.ts handles behavior in the editor / live preview context.
- src/renderedMode.ts handles behavior in rendered/reading view.
- These are the two main execution paths, reflecting Obsidian’s split between editable Markdown and rendered Markdown.
5. Per-document control
- src/FrontmatterListener.ts adds note-level enable/disable logic using frontmatter.
- The heading-indent frontmatter key acts as a document boundary:
- omitted or true → indentation enabled
- false → indentation disabled
- This means the plugin can be active globally but selectively suppressed per note.
6. Configuration boundary
- src/settings.ts holds the plugin’s user-configurable options, including indentation customization.
- Settings likely influence the indentation amount or behavior per heading level and are shared by both editing and rendered modes.
7. Data flow at runtime
- A note is opened or updated.
- Frontmatter is inspected to decide whether heading indentation should apply.
- The active mode determines whether editingMode or renderedMode applies the visual treatment.
- The plugin then adjusts the displayed structure without changing the underlying note content.
8. Rendering strategy
- The plugin is visually invasive rather than content-transforming: it changes presentation of blocks under headings.
- The readme indicates support across code blocks, blockquotes, callouts, tables, LaTeX blocks, embeds, and canvas-related content, so the indentation logic likely needs to account for multiple rendered block types.
9. Packaging and build tooling
- esbuild.config.mjs is the build bundler configuration for producing the plugin artifact.
- manifest.json defines the Obsidian plugin metadata used by the app and community marketplace.
- versions.json and version-bump.mjs indicate release/version management for distributing plugin updates.
10. Quality and repo tooling
- eslint.config.js, biome.json, and tsconfig.json show the repo uses standard TypeScript linting/formatting/type-checking.
- These tools support development, but they do not affect the runtime architecture.
11. Important architectural boundary
- The plugin does not appear to introduce a server, database, or external API dependency.
- The key boundary is between note metadata + Obsidian view state on one side and visual indentation behavior on the other.
12. How to diagram it
- Model the system as:
- Obsidian host app
- Plugin entrypoint
- Settings/frontmatter decision layer
- Two view-specific applicators: editing and rendered mode
- Build/release tooling as a separate offline pipeline
- The main runtime arrows are from note content + frontmatter + settings into mode-specific indentation rendering.
Main entry points: main.ts Plugin entry · renderedMode.ts Rendered mode · editingMode.ts Editing mode · FrontmatterListener.ts Frontmatter
Components 16
Runtime
Plugin execution inside Obsidian
- Obsidian · Desktop note editor and renderer that loads the plugin
- Plugin entry · Central coordinator for activation and hook registration
src/main.ts - Settings · User options that control indentation behavior
src/settings.ts - Frontmatter · Per-note enable or disable switch based on heading-indent metadata
src/FrontmatterListener.ts - Editing mode · Applies indentation in live preview and editor context
src/editingMode.ts - Rendered mode · Applies indentation in reading view and rendered content
src/renderedMode.ts - Indented view · Presentation layer that visually shifts content under headings
- Note content · Headings and nested blocks being displayed
- Block types · Code blocks, callouts, tables, embeds, quotes, and similar rendered content
Tooling
Build and release pipeline
- esbuild config · Build configuration for the plugin artifact
esbuild.config.mjs - Manifest · Obsidian plugin metadata and marketplace identity
manifest.json - Versions · Version compatibility and release tracking
versions.json - Version bump · Automates release version updates
version-bump.mjs - TypeScript · Compiler and module settings for the source code
tsconfig.json - ESLint · JavaScript and TypeScript linting rules
eslint.config.js - Biome · Formatting and code quality rules
biome.json
Connections 21
- Obsidian → Plugin entry: loads · Obsidian activates the plugin entrypoint
- Plugin entry → Settings: initializes · Loads shared configuration at startup
- Plugin entry → Frontmatter: registers · Installs note-level enable/disable listener
- Plugin entry → Editing mode: wires · Connects editor and live preview behavior
- Plugin entry → Rendered mode: wires · Connects reading view behavior
- Frontmatter → Editing mode: permits · Allows editing-mode indentation when enabled
- Frontmatter → Rendered mode: permits · Allows rendered-mode indentation when enabled
- Settings → Editing mode: configures · Provides indentation options to editor path
- Settings → Rendered mode: configures · Provides indentation options to reader path
- Note content → Frontmatter: checks · Note metadata determines whether the plugin applies
- Note content → Editing mode: flows into · Editable markdown is processed in the editor path
- Note content → Rendered mode: flows into · Rendered markdown is processed in the reader path
- Block types → Rendered mode: special-cases · Rendered block structures need tailored indentation handling
- Editing mode → Indented view: applies · Transforms live editor presentation
- Rendered mode → Indented view: applies · Transforms reading-view presentation
- esbuild config → Plugin entry: bundles · Builds the plugin source into distributable output
- Manifest → Obsidian: declares · Describes plugin identity to Obsidian
- Versions → Version bump: drives · Version data used during release updates
- TypeScript → Plugin entry: checks · Type checking applies to the source tree
- ESLint → Plugin entry: checks · Linting applies to the source tree
- Biome → Plugin entry: checks · Formatting and code quality apply to the source tree