Skip to content

Commit

Permalink
Merge pull request #3 from iLiftALot/2-feature-request-option-to-excl…
Browse files Browse the repository at this point in the history
…ude-headings-through-a-global-setting

2 feature request option to exclude headings through a global setting
  • Loading branch information
iLiftALot authored Dec 7, 2024
2 parents 1957f72 + fccebf9 commit 96a7027
Show file tree
Hide file tree
Showing 15 changed files with 267 additions and 89 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Release and Publish

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- 'master'
- master
types:
- closed
workflow_dispatch:
inputs:
version_type:
Expand All @@ -23,6 +23,13 @@ permissions:

jobs:
release:
if: |
github.event_name == 'workflow_dispatch' || (
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'master'
)
runs-on: ubuntu-latest

steps:
Expand Down
62 changes: 53 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,36 @@
There are various other ToC plugins for Obsidian, however, they come with certain limitations which this plugin aims to mitigate and improve upon which includes:

**Seamless Integration & Dynamic Generation**
- Just insert the code block and start typing. There's nothing more to it. Other ToC plugins generate the ToC via command activation. This plugin is designed for performance and simplicity for maximum convenience and organization with no hassle.
- Just insert the code block and start typing. There's nothing more to it.
- Other ToC plugins generate the ToC via command activation.
- This plugin is designed for performance and simplicity for maximum convenience and organization.

**Omit Specific Headings**
- Exclude any heading you want from the ToC by simply adding `<!-- omit -->` to the end of the heading.
- Alternatively, utilize the local settings to omit specific headings.

**HTML & Special Symbols**
- Feel free to include HTML or any kind of special symbols within headings. This plugin will handle these cases elegantly.
- Alternatively, specify which characters should be escaped within the local settings.
- You can additionally specify which characters should be escaped within the local settings.

**Heading Hierarchy Handling**
- Include any type of heading hierarchy you want. Your heading structure doesn't have to be any certain way. Other plugins will prohibit the ToC insertion if the heading hierachy.
- Include any type of heading hierarchy you want. Your heading structure doesn't have to be any certain way.
- Other plugins will prohibit the ToC insertion if the heading hierachy is not in a particular optimal format.

**Markdown Links & Wiki-Links**
- This plugin will handle multiple of both markdown links (`[Title]\(https://link)`) and wiki-links (`[[file-name.md]]`) within headings.

**Settings**<br>
<ul>
<li><u style="color: orange;">Bullet Style</u> - Select your preferred list-bullet style within the settings tab.</li>

<li><u style="color: orange;">Update Delay</u> - Configure the delay between ToC updates.</li>
<li><u style="color: orange;">Excluded Characters</u> - Specify which characters should be escaped within headings.</li>

<li><u style="color: orange;">Exclusions</u> - You will have multiple custimization choices pertaining to exlcuding specific heading text, individual characters, and heading levels.</li>

<li><u style="color: orange;">Indentation Width</u> - Determine your preferred amount of indentation spacing.</li>
<li><a href="https://github.com/iLiftALot/insta-toc?tab=readme-ov-file#usage">Local Settings</a></li>

<li><u><a href="https://github.com/iLiftALot/insta-toc?tab=readme-ov-file#usage">Local File Settings</a></u></li>
</ul>


Expand All @@ -68,7 +75,6 @@ There are various other ToC plugins for Obsidian, however, they come with certai
```

- Alternatively, utilize the local settings:

```yml
---
omit: [
Expand All @@ -78,15 +84,33 @@ There are various other ToC plugins for Obsidian, however, they come with certai
---
```

<center>↕️&nbsp;&nbsp;&nbsp;&nbsp;↕️&nbsp;&nbsp;&nbsp;&nbsp;↕️&nbsp;&nbsp;&nbsp;&nbsp;↕️</center>

```yml
---
omit:
- Heading 1
- Heading 2
---
```
---

**Local ToC Settings Guide**
> <center style="font-size: large; color: red;"><b>⚠️ <u>FORMAT CAUTION</u> ⚠️</b></center>
>
> The local settings use <b style="color: yellow;"><u>YAML formatting</u></b>, which is a format that is very particular about perfect spacing.
> I'll be implementing auto-correction logic soon to account for this, but for the time being ensure that you are <b style="color: yellow;"><u>only indenting with 2 spaces</u></b>, otherwise you will get errors.

- Type Guide:
```yml
---
title:
name: [string: any]
- The title of the ToC.
level: [number: 1 | 2 | 3 | 4 | 5 | 6]
- The heading level of the title
- The heading level of the title.
center: [boolean: true | false]
- Optionally center position of the title.
exclude: [string: any | RegExp: /.../]
- Exclude specific headings based on a string of characters (e.g., ",._-+=") or a regular expression (e.g., /[^a-zA-Z0-9]/).
- NOTE: Currently, this will include global excluded characters as well.
Expand All @@ -103,12 +127,13 @@ There are various other ToC plugins for Obsidian, however, they come with certai
---
```

- Example:
- Example 1:
```yml
---
title:
name: "Table of Contents"
level: 2
center: false
exclude: ",._-+"
style:
listType: "dash"
Expand All @@ -122,6 +147,25 @@ There are various other ToC plugins for Obsidian, however, they come with certai
---
```

- Example 2:
```yml
---
title:
name: "Table of Contents"
level: 1
center: true
exclude: /[^a-zA-Z0-9]/
style:
listType: number
omit:
- Heading 3
- Heading 4
levels:
min: 2
max: 6
---
```


## Installation

Expand Down Expand Up @@ -194,7 +238,7 @@ npm install insta-toc
<ul>
<li><input type="checkbox">PDF</input></li>
<li><input type="checkbox">HTML</input></li>
<input type="checkbox">Markdown</input></li>
<li><input type="checkbox">Markdown</input></li>
<li><input type="checkbox">...</input></li>
</ul>
</ul>
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "insta-toc",
"name": "Insta TOC",
"version": "6.2.0",
"version": "6.3.0",
"minAppVersion": "0.15.0",
"description": "Simultaneously generate, update, and maintain a table of contents for your notes.",
"author": "Nick C.",
Expand Down
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insta-toc",
"version": "6.2.0",
"version": "6.3.0",
"description": "Simultaneously generate, update, and maintain a table of contents for your notes in real time.",
"repository": {
"directory": ".",
Expand All @@ -15,9 +15,9 @@
"dev": "node esbuild.config.mjs && terser -o dist/dev/main.js dist/dev/main.js",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production && terser -o dist/build/main.js dist/build/main.js",
"bump-version": "node version-bump.mjs",
"upload:patch": "npm version patch --no-git-tag-version && npm run bump-version && npm run build && git add . && VERSION=$(node -p \"require('./package.json').version\") && git commit -m \"Automated update for version $VERSION\" && git tag -a $VERSION -m \"Version $VERSION\" && git push origin --follow-tags",
"upload:minor": "npm version minor --no-git-tag-version && npm run bump-version && npm run build && git add . && VERSION=$(node -p \"require('./package.json').version\") && git commit -m \"Automated update for version $VERSION\" && git tag -a $VERSION -m \"Version $VERSION\" && git push origin --follow-tags",
"upload:major": "npm version major --no-git-tag-version && npm run bump-version && npm run build && git add . && VERSION=$(node -p \"require('./package.json').version\") && git commit -m \"Automated update for version $VERSION\" && git tag -a $VERSION -m \"Version $VERSION\" && git push origin --follow-tags"
"upload:patch": "npm version patch --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master",
"upload:minor": "npm version minor --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master",
"upload:major": "npm version major --no-git-tag-version && npm run bump-version && npm run build && git add . && git commit -m \"Automated update for version $npm_package_version\" && git push origin master"
},
"keywords": [
"obsidian",
Expand Down Expand Up @@ -49,7 +49,7 @@
"vitest": "^2.1.5"
},
"dependencies": {
"deepmerge-ts": "7.1.3",
"mergician": "^2.0.2",
"turndown": "^7.2.0"
}
}
8 changes: 6 additions & 2 deletions src/ManageToc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class ManageToc {
}---\n\n${
'#'.repeat(this.validator.localTocSettings.title.level)
} ${
this.validator.localTocSettings.title.name
this.validator.localTocSettings.title.center
? '<center>' + this.validator.localTocSettings.title.name + '</center>'
: this.validator.localTocSettings.title.name
}\n\n${
tocHeadingRefs.join('\n')
}`;
Expand Down Expand Up @@ -115,7 +117,9 @@ export class ManageToc {
}---\n\n${
'#'.repeat(this.validator.localTocSettings.title.level)
} ${
this.validator.localTocSettings.title.name
this.validator.localTocSettings.title.center
? '<center>' + this.validator.localTocSettings.title.name + '</center>'
: this.validator.localTocSettings.title.name
}\n\n${
tocHeadingRefs.join('\n')
}`;
Expand Down
8 changes: 6 additions & 2 deletions src/Settings.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import { DefaultExcludedChars } from "./constants";
import { BulletType, IndentLevel, UpdateDelay } from "./types";
import { BulletType, HeadingLevel, IndentLevel, UpdateDelay } from "./types";

export interface InstaTocSettings {
bulletType: BulletType;
indentSize: IndentLevel;
updateDelay: UpdateDelay;
tocTitle: string;
excludedHeadingLevels: HeadingLevel[];
excludedHeadingText: string[];
excludedChars: string[];
}

export const DEFAULT_SETTINGS: InstaTocSettings = {
bulletType: 'dash',
indentSize: 4,
indentSize: 2,
updateDelay: 2000,
tocTitle: 'Table of Contents',
excludedHeadingLevels: [],
excludedHeadingText: [],
excludedChars: DefaultExcludedChars
}
Loading

0 comments on commit 96a7027

Please sign in to comment.