{"id":27374352,"url":"https://github.com/teneplaysofficial/markdom","last_synced_at":"2025-04-13T11:56:09.300Z","repository":{"id":287633123,"uuid":"963562337","full_name":"TenEplaysOfficial/markdom","owner":"TenEplaysOfficial","description":"A Markdown and HTML parser for Node.js with TOC generation and anchor support.","archived":false,"fork":false,"pushed_at":"2025-04-12T23:38:42.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T00:24:35.230Z","etag":null,"topics":["cli","javascript","markdown","markdown-parser","nodejs","npm-package","parser","rollup","typescript","vitest"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@tenedev/markdom","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/TenEplaysOfficial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"patreon":"teneplays"}},"created_at":"2025-04-09T21:44:45.000Z","updated_at":"2025-04-12T23:41:31.000Z","dependencies_parsed_at":"2025-04-13T00:24:42.542Z","dependency_job_id":"83d2c26e-aafd-415e-87de-a17b02fd0af2","html_url":"https://github.com/TenEplaysOfficial/markdom","commit_stats":null,"previous_names":["teneplaysofficial/markdom"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TenEplaysOfficial%2Fmarkdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TenEplaysOfficial%2Fmarkdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TenEplaysOfficial%2Fmarkdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TenEplaysOfficial%2Fmarkdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TenEplaysOfficial","download_url":"https://codeload.github.com/TenEplaysOfficial/markdom/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710442,"owners_count":21149188,"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":["cli","javascript","markdown","markdown-parser","nodejs","npm-package","parser","rollup","typescript","vitest"],"created_at":"2025-04-13T11:56:08.624Z","updated_at":"2025-04-13T11:56:09.292Z","avatar_url":"https://github.com/TenEplaysOfficial.png","language":"JavaScript","funding_links":["https://patreon.com/teneplays"],"categories":[],"sub_categories":[],"readme":"# Markdom\n\n[![npm](https://img.shields.io/npm/v/@tenedev/markdom?color=blue\u0026label=NPM\u0026logo=npm\u0026style=flat-square)](https://www.npmjs.com/package/@tenedev/markdom)\n[![downloads](https://img.shields.io/npm/dt/@tenedev/markdom?color=blue\u0026label=Downloads\u0026logo=archive\u0026style=flat-square)](https://www.npmjs.com/package/@tenedev/markdom)\n![size](https://img.shields.io/bundlephobia/minzip/@tenedev/markdom?style=flat-square\u0026label=Size\u0026logo=webpack\u0026color=blue)\n![maintenance](https://img.shields.io/maintenance/active/2025?style=flat-square\u0026label=Maintained\u0026logo=calendar\u0026color=blue)\n![Node.js](https://img.shields.io/badge/Node.js-%3E%3D16-blue?logo=node.js\u0026style=flat-square)\n[![contribute](https://img.shields.io/badge/Contribute-Open%20PRs-blue?style=flat-square\u0026logo=git)](https://github.com/TenEplaysOfficial/markdom/pulls)\n[![stars](https://img.shields.io/github/stars/TenEplaysOfficial/markdom?style=flat-square\u0026label=Stars\u0026logo=github)](https://github.com/TenEplaysOfficial/markdom)\n![forks](https://img.shields.io/github/forks/TenEplaysOfficial/markdom?style=flat-square\u0026label=Forks\u0026logo=github)\n[![issues](https://img.shields.io/github/issues/TenEplaysOfficial/markdom?style=flat-square\u0026label=Issues\u0026logo=github\u0026color=blue)](https://github.com/TenEplaysOfficial/markdom/issues)\n[![last commit](https://img.shields.io/github/last-commit/TenEplaysOfficial/markdom?style=flat-square\u0026label=Last%20Commit\u0026logo=github\u0026color=blue)](https://github.com/TenEplaysOfficial/markdom)\n![workflow](https://img.shields.io/github/actions/workflow/status/TenEplaysOfficial/markdom/publish.yml?style=flat-square\u0026label=Build\u0026logo=githubactions\u0026color=blue)\n![license](https://img.shields.io/github/license/TenEplaysOfficial/markdom?style=flat-square\u0026label=License\u0026logo=open-source-initiative\u0026color=blue)\n\n`@tenedev/markdom` is a **Markdown parser** for Node.js that effortlessly converts **Markdown** files into **HTML** with automatic **Table of Contents (TOC)** generation, heading anchors, and more. Whether you’re building docs, wikis, or simply rendering Markdown to HTML, Markdom makes it easy to transform your Markdown into a beautiful, navigable HTML structure.\n\n## 🚀 Key Features\n\n- **📄 Markdown to HTML Parsing**: Converts Markdown to clean HTML, maintaining the original structure and formatting.\n- **📑 Table of Contents (TOC)**: Automatically generates a TOC based on your Markdown headings.\n- **🔗 Anchor Links for Headings**: Creates clickable anchor links for each heading, making navigation seamless.\n- **🎨 Customizable**: Tailor the HTML and TOC generation to fit your needs.\n- **🖥️ CLI Support**: Use the built-in CLI to quickly parse Markdown files and output HTML to a file.\n\n## 🗂️ Table of Contents\n\n- [Markdom](#markdom)\n  - [🚀 Key Features](#-key-features)\n  - [🗂️ Table of Contents](#️-table-of-contents)\n  - [🛠️ Installation](#️-installation)\n    - [Using `npm`:](#using-npm)\n    - [Using `yarn`:](#using-yarn)\n  - [📋 Prerequisites](#-prerequisites)\n  - [🧑‍💻 How to Use](#-how-to-use)\n    - [Node.js API](#nodejs-api)\n      - [`markdom.parse` function returns:](#markdomparse-function-returns)\n    - [📡 Command-Line Interface (CLI)](#-command-line-interface-cli)\n  - [🛠️ API Documentation](#️-api-documentation)\n    - [`markdom.parse(md: string): { html: string, toc: TOC[] }`](#markdomparsemd-string--html-string-toc-toc-)\n  - [🗂️ Table of Contents (TOC) Generation](#️-table-of-contents-toc-generation)\n    - [Resulting TOC:](#resulting-toc)\n    - [Rendering of Headings](#rendering-of-headings)\n  - [💻 Example Output](#-example-output)\n    - [Input (Markdown):](#input-markdown)\n    - [Output (HTML):](#output-html)\n  - [🤝 Contributing](#-contributing)\n  - [📜 License](#-license)\n\n## 🛠️ Installation\n\nTo get started with `@tenedev/markdom`, install it using your preferred package manager:\n\n### Using `npm`:\n\n```bash\nnpm install @tenedev/markdom\n```\n\n### Using `yarn`:\n\n```bash\nyarn add @tenedev/markdom\n```\n\n---\n\n## 📋 Prerequisites\n\n- **Node.js** version 16.x or higher\n- Basic familiarity with **Markdown syntax**\n\n---\n\n## 🧑‍💻 How to Use\n\n### Node.js API\n\nImport `@tenedev/markdom` into your project and start converting Markdown to HTML:\n\n```ts\nimport { markdom } from '@tenedev/markdom';\n\n// Example usage\nconst markdown = `# Example Heading\\n\\nThis is a sample markdown document.`;\nconst { html, toc } = markdom.parse(markdown);\n\nconsole.log(html);\nconsole.log(toc);\n```\n\n#### `markdom.parse` function returns:\n\n- `html`: The generated HTML content.\n- `toc`: An array of Table of Contents items, each containing:\n  - `id`: Slugified heading ID\n  - `title`: The heading text\n  - `level`: Heading level (e.g., 1 for H1, 2 for H2, etc.)\n\n---\n\n### 📡 Command-Line Interface (CLI)\n\nYou can also use the powerful CLI provided by `@tenedev/markdom` to convert Markdown files directly from the terminal.\n\n1. **Basic Usage**:\n\n```bash\nnpx @tenedev/markdom \u003cinput.md\u003e\n```\n\n2. **With Output Option**:\n\n```bash\nnpx @tenedev/markdom \u003cinput.md\u003e -o output.html\n```\n\n\u003e **Note**: The `-o` option supports only `.html` or `.htm` extensions. Other file types will trigger an error.\n\n---\n\n## 🛠️ API Documentation\n\n### `markdom.parse(md: string): { html: string, toc: TOC[] }`\n\n**Parameters**:\n\n- `md` (string): The input Markdown string to be parsed.\n\n**Returns**:\n\n- `html` (string): The resulting HTML content after parsing.\n- `toc` (array): An array representing the Table of Contents, with each item containing:\n  - `id` (string): A slugified version of the heading.\n  - `title` (string): The title of the heading.\n  - `level` (number): The level of the heading (1 for H1, 2 for H2, etc.).\n\n---\n\n## 🗂️ Table of Contents (TOC) Generation\n\nThe Table of Contents (TOC) is automatically generated and inserted at the `\u003c!-- TOC-HERE --\u003e` comment in your Markdown. For example:\n\n```markdown\n\u003c!-- TOC-HERE --\u003e\n\n# Heading 1\n\nSome content.\n\n## Heading 2\n\nMore content.\n```\n\n### Resulting TOC:\n\n```html\n\u003cnav class=\"markdown-toc\"\u003e\n  \u003cul\u003e\n    \u003cli class=\"toc-level-1\"\u003e\u003ca href=\"#heading-1\"\u003eHeading 1\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\"toc-level-2\"\u003e\u003ca href=\"#heading-2\"\u003eHeading 2\u003c/a\u003e\u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/nav\u003e\n```\n\n### Rendering of Headings\n\nMarkdown headings automatically receive anchor links for easy navigation:\n\n```markdown\n# Heading 1\n```\n\nThis is rendered as:\n\n```html\n\u003ch1 id=\"heading-1\"\u003e\n  \u003ca href=\"#heading-1\" class=\"heading-anchor\"\u003e🔗\u003c/a\u003e Heading 1\n\u003c/h1\u003e\n```\n\n---\n\n## 💻 Example Output\n\n### Input (Markdown):\n\n```markdown\n\u003c!-- TOC-HERE --\u003e\n\n# Introduction\n\nThis is a Markdown document.\n\n## Subheading 1\n\nDetails about subheading 1.\n\n## Subheading 2\n\nDetails about subheading 2.\n```\n\n### Output (HTML):\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"UTF-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" /\u003e\n    \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" /\u003e\n    \u003cmeta\n      name=\"description\"\n      content=\"Markdom is a Markdown and HTML parser for Node.js with TOC generation and anchor support.\"\n    /\u003e\n    \u003ctitle\u003eMarkdown Output - @tenedev/markdom\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    \u003ch1 id=\"introduction\"\u003e\n      \u003ca href=\"#introduction\" class=\"heading-anchor\"\u003e🔗\u003c/a\u003e Introduction\n    \u003c/h1\u003e\n    \u003cp\u003eThis is a Markdown document.\u003c/p\u003e\n\n    \u003ch2 id=\"subheading-1\"\u003e\n      \u003ca href=\"#subheading-1\" class=\"heading-anchor\"\u003e🔗\u003c/a\u003e Subheading 1\n    \u003c/h2\u003e\n    \u003cp\u003eDetails about subheading 1.\u003c/p\u003e\n\n    \u003ch2 id=\"subheading-2\"\u003e\n      \u003ca href=\"#subheading-2\" class=\"heading-anchor\"\u003e🔗\u003c/a\u003e Subheading 2\n    \u003c/h2\u003e\n    \u003cp\u003eDetails about subheading 2.\u003c/p\u003e\n\n    \u003cnav class=\"markdown-toc\"\u003e\n      \u003cul\u003e\n        \u003cli class=\"toc-level-1\"\u003e\u003ca href=\"#introduction\"\u003eIntroduction\u003c/a\u003e\u003c/li\u003e\n        \u003cli class=\"toc-level-2\"\u003e\u003ca href=\"#subheading-1\"\u003eSubheading 1\u003c/a\u003e\u003c/li\u003e\n        \u003cli class=\"toc-level-2\"\u003e\u003ca href=\"#subheading-2\"\u003eSubheading 2\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/nav\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## 🤝 Contributing\n\nWe welcome contributions from the community!\n\nIf you have ideas, suggestions, or bug reports, feel free to [open an issue](https://github.com/TenEplaysOfficial/markdom/issues) or [submit a pull request](https://github.com/TenEplaysOfficial/markdom/pulls) on GitHub.\n\nLet's make `@tenedev/markdom` better together!\n\n## 📜 License\n\nThis project is licensed under the [MIT License](LICENSE).  \nCopyright © [TenEplaysOfficial](https://github.com/TenEplaysOfficial)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteneplaysofficial%2Fmarkdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteneplaysofficial%2Fmarkdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteneplaysofficial%2Fmarkdom/lists"}