diff --git a/README.md b/README.md index d1ca6f7..3ee1d76 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Alternatively, download the [latest release](https://github.com/johansatge/obsid ## Usage -Insert a codeblock with the `table-of-contents` syntax. +Insert a codeblock with the `table-of-contents` (or its short version `toc`) syntax. ```` ```table-of-contents diff --git a/main.js b/main.js index 9a5ab5b..7f6a4a7 100644 --- a/main.js +++ b/main.js @@ -10,6 +10,7 @@ if (isObsidian()) { } const codeblockId = 'table-of-contents' +const codeblockIdShort = 'toc' const availableOptions = { style: { type: 'string', @@ -41,9 +42,11 @@ const availableOptions = { class ObsidianAutomaticTableOfContents extends Plugin { async onload() { - this.registerMarkdownCodeBlockProcessor(codeblockId, (sourceText, element, context) => { + const handler = (sourceText, element, context) => { context.addChild(new Renderer(this.app, element, context.sourcePath, sourceText)) - }) + } + this.registerMarkdownCodeBlockProcessor(codeblockId, handler) + this.registerMarkdownCodeBlockProcessor(codeblockIdShort, handler) this.addCommand({ id: 'insert-automatic-table-of-contents', name: 'Insert table of contents',