{"id":15390253,"url":"https://github.com/gajus/markdown-contents","last_synced_at":"2025-04-15T21:27:07.489Z","repository":{"id":23391894,"uuid":"26753660","full_name":"gajus/markdown-contents","owner":"gajus","description":"Generate table of contents for a markdown document.","archived":false,"fork":false,"pushed_at":"2018-08-30T15:02:00.000Z","size":17,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T01:34:23.657Z","etag":null,"topics":["javascript","markdown","table-of-contents","toc"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gajus.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2014-11-17T11:26:49.000Z","updated_at":"2023-04-20T09:45:10.000Z","dependencies_parsed_at":"2022-07-08T04:20:21.870Z","dependency_job_id":null,"html_url":"https://github.com/gajus/markdown-contents","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fmarkdown-contents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fmarkdown-contents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fmarkdown-contents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gajus%2Fmarkdown-contents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gajus","download_url":"https://codeload.github.com/gajus/markdown-contents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249156107,"owners_count":21221712,"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":["javascript","markdown","table-of-contents","toc"],"created_at":"2024-10-01T15:05:06.855Z","updated_at":"2025-04-15T21:27:07.446Z","avatar_url":"https://github.com/gajus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Markdown Contents\n\n[![Travis build status](http://img.shields.io/travis/gajus/markdown-contents/master.svg?style=flat-square)](https://travis-ci.org/gajus/markdown-contents)\n[![Coveralls](https://img.shields.io/coveralls/gajus/markdown-contents.svg?style=flat-square)](https://coveralls.io/github/gajus/markdown-contents)\n[![NPM version](http://img.shields.io/npm/v/markdown-contents.svg?style=flat-square)](https://www.npmjs.org/package/markdown-contents)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social\u0026label=Follow)](https://twitter.com/kuizinas)\n\nGenerate table of contents for a markdown document.\n\nThe underlying implementation is rendering markdown file into HTML and then use [Contents](https://github.com/gajus/contents).\n to generate the table of contents.\n\n## Usage\n\n```js\nimport MarkdownContents from 'markdown-contents';\n\nconst markdown = '';\nconst markdownContents = MarkdownContents(markdown);\n\n/**\n * Generate flat index of the headings.\n *\n * @return {Array}\n */\nmarkdownContents.articles();\n\n/**\n * Generates hierarchical index of the headings from a flat index.\n *\n * @return {Array}\n */\nmarkdownContents.tree();\n\n/**\n * Generate markdown for the table of contents.\n *\n * @return {string}\n */\nmarkdownContents.markdown();\n\n/**\n * Generate markdown contents for an array of contents object definition.\n *\n * @param {Array} tree [{id: '', name: '', descendants: []}]\n * @return {string} markdown\n */\nMarkdownContents.treeToMarkdown();\n\n/**\n * Makes hierarchical index of the articles from a flat index.\n *\n * @param {Array} articles Generated using Contents.articles.\n * @param {boolean} makeUniqueIDs\n * @param {Array} uniqueIDpool\n * @return {Array}\n */\nMarkdownContents.tree();\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fmarkdown-contents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgajus%2Fmarkdown-contents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgajus%2Fmarkdown-contents/lists"}