{"id":21722695,"url":"https://github.com/czukowski/markdown-toc","last_synced_at":"2025-04-12T21:51:05.394Z","repository":{"id":56960993,"uuid":"69263092","full_name":"czukowski/markdown-toc","owner":"czukowski","description":"Table of Contents generator for cebe/markdown","archived":false,"fork":false,"pushed_at":"2016-09-27T14:54:13.000Z","size":10,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-26T15:54:38.153Z","etag":null,"topics":["markdown","table-of-contents","toc"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/czukowski.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-09-26T15:15:52.000Z","updated_at":"2023-05-04T08:42:48.000Z","dependencies_parsed_at":"2022-08-21T05:40:14.999Z","dependency_job_id":null,"html_url":"https://github.com/czukowski/markdown-toc","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/czukowski%2Fmarkdown-toc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czukowski%2Fmarkdown-toc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czukowski%2Fmarkdown-toc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czukowski%2Fmarkdown-toc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czukowski","download_url":"https://codeload.github.com/czukowski/markdown-toc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637832,"owners_count":21137538,"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":["markdown","table-of-contents","toc"],"created_at":"2024-11-26T02:32:01.831Z","updated_at":"2025-04-12T21:51:05.364Z","avatar_url":"https://github.com/czukowski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Table of Contents generator for cebe/markdown\n=============================================\n\nThis package provides a PHP _trait_ that to use with [cebe's Markdown implementation][cebe/markdown].\nIt allows to generate ToC from headlines in Makrdown documents and render them as lists. Note: the\noutput is a rendered HTML, not Markdown!\n\nInstallation\n------------\n\nRecommended installation is via [composer][composer] by running:\n\n    composer require czukowski/markdown-toc \"~1.0\"\n\nAlternatively you may add the following to the `require` section of your project's `composer.json`\nmanually and then run `composer update` from the command line:\n\n```json\n\"czukowski/markdown-toc\": \"~1.0\"\n```\n\nUsage\n-----\n\nThis package provides a `TOCTrait` that may be used in classes extending the cebe's original Markdown\nparsers.\n\nFor more information on how to extend the parser, refer to the [original Readme file][markdown-usage].\n\nGenerating Table of Contents can then be done by calling either of the two available public methods,\ndepending on whether you are generating ToC from one or multiple files:\n\n```php\n$markdown = new MyMarkdownWithTOC;\n\n// Generate ToC from a single file:\n$toc1 = $markdown-\u003egenerateTableOfContents($source, 'index.md');\n\n// Generate ToC from multiple files:\n$toc2 = $markdown-\u003egenerateTableOfContentsFromMultiple([\n    [$intro, 'intro.md'],\n    [$issues, 'issues.md'],\n    [$reference, 'reference.md'],\n]);\n```\n\nIn the examples above, it's assumed that you've created a class named `MyMarkdownWithTOC` that uses\n`TOCTrait`.\n\nAdditional optional arguments are available that define the list type used and limit the headline\nlevels that ToC is generated from.\n\nReference\n---------\n\n - `generateTableOfContents($markdown, $url, $listType = 'ul', $fromLevel = 1, $toLevel = 6)`:\n   * @param   _string_   `$markdown`   markdown source.\n   * @param   _string_   `$url`        source URL.\n   * @param   _string_   `$listType`   supported values: `ul` and `ol`.\n   * @param   _integer_  `$fromLevel`  use headlines starting with this level\n   * @param   _integer_  `$toLevel`    use headlines up to this level\n   * @return  _string_\n\n - `generateTableOfContentsFromMultiple($sources, $listType = 'ul', $fromLevel = 1, $toLevel = 6)`:\n   * @param   _array_    `$sources`    markdown sources and URLs.\n   * @param   _string_   `$listType`   supported values: `ul` and `ol`.\n   * @param   _integer_  `$fromLevel`  use headlines starting with this level\n   * @param   _integer_  `$toLevel`    use headlines up to this level\n   * @return  _string_\n\nLicense\n-------\n\nThe distribution is permitted under the MIT License. See LICENSE.md for details.\n\n\n  [cebe/markdown]: https://github.com/cebe/markdown\n  [composer]: https://getcomposer.org/\n  [markdown-usage]: https://github.com/cebe/markdown#usage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczukowski%2Fmarkdown-toc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczukowski%2Fmarkdown-toc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczukowski%2Fmarkdown-toc/lists"}