{"id":21055193,"url":"https://github.com/leisn/markdigtoc","last_synced_at":"2025-05-15T23:32:23.738Z","repository":{"id":45434543,"uuid":"404122038","full_name":"leisn/MarkdigToc","owner":"leisn","description":"A extension for Markdig to generate table of content by parse [toc] in markdown document, currently just for render to html. ","archived":false,"fork":false,"pushed_at":"2022-01-05T09:10:30.000Z","size":42,"stargazers_count":9,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-04T00:29:17.758Z","etag":null,"topics":["markdig","markdown","md2html","toc","toc-generator"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leisn.png","metadata":{"files":{"readme":"Readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-07T21:03:47.000Z","updated_at":"2024-12-26T19:23:18.000Z","dependencies_parsed_at":"2022-09-05T00:41:30.872Z","dependency_job_id":null,"html_url":"https://github.com/leisn/MarkdigToc","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leisn%2FMarkdigToc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leisn%2FMarkdigToc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leisn%2FMarkdigToc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leisn%2FMarkdigToc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leisn","download_url":"https://codeload.github.com/leisn/MarkdigToc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442344,"owners_count":22071863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdig","markdown","md2html","toc","toc-generator"],"created_at":"2024-11-19T16:36:56.102Z","updated_at":"2025-05-15T23:32:18.696Z","avatar_url":"https://github.com/leisn.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MarkdigToc  [![NuGet](https://img.shields.io/nuget/v/Leisn.MarkdigToc)](https://www.nuget.org/packages/Leisn.MarkdigToc/) [![NuGet](https://img.shields.io/nuget/v/Leisn.MarkdigToc.Signed)](https://www.nuget.org/packages/Leisn.MarkdigToc.Signed/)\n\nMarkdigToc is a extension for [Markdig](https://github.com/xoofx/markdig) to generate table of content by parse [toc] in markdown document. \n\n\u003e Currently just for render to html.\n\n## Usage\n\nUse with default options:\n\n\n```csharp\nvar pipeline = new MarkdownPipelineBuilder()\n    .UseAdvancedExtensions() // Add most of all advanced extensions\n    .UseTableOfContent() //Add MarkdigToc extension\n    .Build();\nvar result=Markdown.ToHtml(@\"\n[TOC]\n# t1\n## t1.1\n### t1.1.1\n### t1.1.2\n## t1.2\n\");\nConsole.WriteLine(result);\n```\n\nUse with custom options:\n\n```csharp\nvar pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions() \n    .UseTableOfContent(\n        tocAction: opt=\u003e{ // toc options },\n        idAction: opt=\u003e{ // auto id options }\n\t).Build();\n\n// ...\n```\n\n## Options\n\n### CustomAutoIdOptions\n\nCode copied from `AutoIdentifierExtension`, then added some code and options.\n\n\u003e NOTICE: When use `UseTableOfContent`, it will auto replace (`AutoIdentifierExtension`) or add (`CustomAutoIdExtension`).\n\n* `AutoIdentifierOptions`  **Options**:  `Enum: default AutoIdentifierOptions.Default`\n\n  Option from `AutoIdentifierExtension`: \n\n  * None\n  * AutoLink\n  *  AllowOnlyAscii\n  *  Default\n  * Github\n\n* `GenerateHeadingId? ` **HeadingIdGenerator**: ` Delegate: defalut null`\n\n  Delegate for handle custom heading id creation.\n\n  Arguments:\n\n  * level:  `int`\n\n    The level of current heading, usually be count of char **#**.\n\n  * content:  `string`\n\n    The content of current heading.\n\n  * id:  `string?`\n\n    Not null if already defined id in markdown strings.\n\n    e.g.   *title-id*  for  `# title {#title-id}`\n    \n    \u003e NOTICE:  In order to parse attributes, need `UseGenericAttributes` extension after all of other extensions which you want parse.\n\n### TocOptions\n\n#### Specials\n\n* ` IsUlOnlyContainLi`:  `bool: default true`\n\n  \u003eAccording to [webhint](https://webhint.io/docs/user-guide/hints/hint-axe/structure/?source=devtools) , `ul` and `ol` must only directly contain `li`, `script` or `template` elements.\n\n  Set **false** to mix `ul` and `li` like others do (generate less code).\n  \n* `TitleAsConainerHeader`: `bool: default false`\n\n  Put the tile in `ContainerTag` not inside the` TocTag`\n\n  \u003e NOTICE: working only `ContainerTag` is not null.\n\n#### TOC Container\n\n* `ContainerTag`: `string? : default null`\n\n  If this is not null, the toc will put in a element use `ContainerTag`.\n\n* `ContainerId`: `string? : default null`\n\n  Id attribute for  `ContainerTag`.\n\n* `ContainerClass`: `string? : default null`\n\n  Class attribute for  `ContainerTag`.  e.g. `\"class1 class2\"`\n\n#### TOC Element\n\n* `TocTag`: `string : default nav`\n\n  Tag name for toc element.\n\n* `TocId`: `string? : default null`\n\n  Id attribute for  `TocTag`.\n\n* `TocClass`: `string? : default null`\n\n  Class attribute for  `TocTag`.  e.g. `\"class1 class2\"`\n\n#### TOC Title\n\n\u003e NOTICE: I also parse toc title and use it's attributes from markdown document , but that is not a regular *syntax*, you should know that.\n\n* `OverrideTitle`: `string? : default null`\n\n  Override toc title , ignore defined in markdown document.\n\n* `TitleTag`: `string : default p`\n\n  Tag name for toc title element.\n\n* `TitleId`: `string? : default null`\n\n  Id attribute for  `TitleTag`.\n\n* `TitleClass`: `string? : default null`\n\n  Class attribute for  `TitleTag`.  e.g. `\"class1 class2\"`\n\n#### TOC Items\n\n* `ulClass`: `string? : default p`\n\n  Class attribute for  `ul`  element.\n\n* `liClass`: `string? : default null`\n\n  Class attribute for  `li`  element.\n\n* `aClass`: `string? : default null`\n\n  Class attribute for  `a`  element.\n\n\n\n## Others\n\nMarkdown document:\n\n```markdown\n[TOC]       \n\n##### t5\n#### t4\n### t3\n## t2\n# t1\n## t2\n### t3\n#### t4\n##### t5\n```\n\n`IsUlOnlyContainLi=true` :\n\n```\n●\n    ○\n        ■\n            ■\n                ■ t5\n            ■ t4\n        ■ t3\n    ○ t2\n● t1\n    ○ t2\n        ■ t3\n            ■ t4\n                ■ t5\n```\n\n`IsUlOnlyContainLi=false` :\n\n```\n                ■ t5\n            ■ t4\n        ■ t3\n    ○ t2\n● t1\n    ○ t2\n        ■ t3\n            ■ t4\n                ■ t5\n```\n\n## Thanks\nThanks Atrejoe for signed version","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleisn%2Fmarkdigtoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleisn%2Fmarkdigtoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleisn%2Fmarkdigtoc/lists"}