{"id":16485337,"url":"https://github.com/morganconrad/outliner","last_synced_at":"2025-07-01T12:04:05.598Z","repository":{"id":71409959,"uuid":"441550680","full_name":"MorganConrad/outliner","owner":"MorganConrad","description":"Create outlines from HTML Headings","archived":false,"fork":false,"pushed_at":"2021-12-24T20:54:20.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-01T00:11:44.409Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/MorganConrad.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-24T20:36:13.000Z","updated_at":"2022-03-07T17:20:41.000Z","dependencies_parsed_at":"2023-03-17T11:15:13.397Z","dependency_job_id":null,"html_url":"https://github.com/MorganConrad/outliner","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MorganConrad/outliner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Foutliner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Foutliner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Foutliner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Foutliner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MorganConrad","download_url":"https://codeload.github.com/MorganConrad/outliner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MorganConrad%2Foutliner/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262959562,"owners_count":23391057,"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":[],"created_at":"2024-10-11T13:25:29.624Z","updated_at":"2025-07-01T12:04:05.571Z","avatar_url":"https://github.com/MorganConrad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"outliner\n====\n\nConvert Heading tags (h2, h3, ...) to an outline with links.  _e.g._\n\n```html\n\u003cbody\u003e\n  \u003ch1\u003eTop Heading\u003c/h1\u003e\n    \u003ch2 id=\"1\"\u003eHeading 1\u003c/h2\u003e\n    lorem ipsum\n    \u003ch2 id=\"2\"\u003eHeading 2\u003c/h2\u003e\n    lorem ipsum\n      \u003ch3 id=\"2.1\"\u003eHeading 2.1\u003c/h3\u003e\n      lorem ipsum\n      \u003ch3 id=\"2.2\"\u003eHeading 2.2\u003c/h3\u003e\n      lorem ipsum\n      \u003ch3 id=\"2.3\"\u003eHeading 2.3\u003c/h3\u003e\n      lorem ipsum\n        \u003ch4 id=\"2.3.1\"\u003eHeading 2.3.1\u003c/h4\u003e\n          lorem ipsum\n        \u003ch4 id=\"2.3.2\"\u003eHeading 2.3.2\u003c/h4\u003e\n          lorem ipsum\n\n    \u003ch2 id=\"3\"\u003eHeading 3\u003c/h2\u003e\n\u003c/body\u003e\n```\nbecomes something like (spacing added for clarity):\n\n```html\n\u003cul class=\"outliner-ul\"\u003e\n  \u003cli \u003e\u003ca class=\"outliner-a\" href=\"#1\"\u003eHeading 1\u003c/a\u003e\u003c/li\u003e\n  \u003cli \u003e\u003ca class=\"outliner-a\" href=\"#2\"\u003eHeading 2\u003c/a\u003e\n    \u003cul class=\"outliner-ul\"\u003e\n      \u003cli \u003e\u003ca class=\"outliner-a\" href=\"#2.1\"\u003eHeading 2.1\u003c/a\u003e\u003c/li\u003e\n      \u003cli \u003e\u003ca class=\"outliner-a\" href=\"#2.2\"\u003eHeading 2.2\u003c/a\u003e\u003c/li\u003e\n      \u003cli \u003e\u003ca class=\"outliner-a\" href=\"#2.3\"\u003eHeading 2.3\u003c/a\u003e\u003c/li\u003e\n    \u003c/ul\u003e\n  \u003c/li\u003e\n  \u003cli \u003e\u003ca class=\"outliner-a\" href=\"#3\"\u003eHeading 3\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\n```\n\n\n\n## Usage\n\n```js\nimport { buildOutline } from \"outliner\";\n\nlet inputHtml = get html from your webpage\n\nlet outline = buildOutline(inputHtml, options);\n\n// insert outline.html into your web page somewhere\n```\n\n## Options\n\n### minH (default = 2)\n\n\u0026nbsp;\u0026nbsp;Minimum header level to use\n\n### maxH (default = 3)\n\n\u0026nbsp;\u0026nbsp;Maximum header level to use\n\n### linkRoot (default = \"#\")\n\n\u0026nbsp;\u0026nbsp;Preprend this to all created hrefs, _unless_ they start with \"http\"\n\n### a (default = '')\n\n\u0026nbsp;\u0026nbsp;Add this inside all a tags.  In the example above, `options.a = 'class=\"outliner-a\"'`\n\n### ul (default = '')\n\n\u0026nbsp;\u0026nbsp;Add this inside all ul tags.  In the example above, `options.ul = 'class=\"outliner-ul\"'`\n\n### li (default = '')\n\n\u0026nbsp;\u0026nbsp;Add this inside all a tags.  In the example above, `options.li = ''`\n\n### rootEl (default = null)\n\n\u0026nbsp;\u0026nbsp;A \"root node\" is needed to hold the headings, at least temporarily.  By default, one will be created, and then \"left out\" when creating the resulting outline.  However, if you want it kept, provide an object here for the rootElement.  It may contain\n\n```\n{\n   id,    // the href or id\n   text\n}\n```\n\n## Complex Options\n\nBy passing functions for `createA`, `createUL`, or `openLI` you can take near complete control over the format of your outline.  All three take the form (e.g. createA)\n\n```js\nfunction createA(node, options) {\n  // return a string bound by '\u003ca ...\u003e ... \u003c/a\u003e\n}\n\nfunction createUL(node, children, options) {\n  // return a string bound by '\u003cul ...\u003e ... \u003c/ul\u003e\n  // (or, if you prefer order, \u003col ... \u003c/ol\u003e)\n}\n\nfunction openLI(node, options) {\n  // return a string starting with '\u003cli ...\n  // the code will add a closing \u003c/li\u003e when appropriate\n}\n\n```\n\nThe `node` is an instance of an HNode, with the fields\n\n```js\n{\n  parent: an HNode or null,\n  children: HNode[],\n  attribs: {},\n  id: a String, or '', used for the href link\n  level: integer, for example 2 for an h2,\n  name: string, for example \"h2\",\n  text: string or ''\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorganconrad%2Foutliner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorganconrad%2Foutliner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorganconrad%2Foutliner/lists"}