{"id":17398466,"url":"https://github.com/vweevers/markdown-to-ansi","last_synced_at":"2025-04-30T05:22:20.424Z","repository":{"id":42525679,"uuid":"315404762","full_name":"vweevers/markdown-to-ansi","owner":"vweevers","description":"Convert markdown to ansi with support of hyperlinks.","archived":false,"fork":false,"pushed_at":"2023-05-01T05:56:50.000Z","size":47,"stargazers_count":9,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-25T01:58:21.394Z","etag":null,"topics":["ansi","markdown","mdast","micromark","nodejs","npm-package"],"latest_commit_sha":null,"homepage":"","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/vweevers.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-23T18:26:31.000Z","updated_at":"2023-05-16T20:53:02.000Z","dependencies_parsed_at":"2024-06-19T20:04:11.637Z","dependency_job_id":"f54514e6-e011-429d-8976-3af42d8b96e1","html_url":"https://github.com/vweevers/markdown-to-ansi","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.36363636363636365","last_synced_commit":"596805a37d1e6d9308a89cdbf0dcff6804e0f638"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmarkdown-to-ansi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmarkdown-to-ansi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmarkdown-to-ansi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fmarkdown-to-ansi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/markdown-to-ansi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251645987,"owners_count":21620847,"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":["ansi","markdown","mdast","micromark","nodejs","npm-package"],"created_at":"2024-10-16T14:56:58.508Z","updated_at":"2025-04-30T05:22:20.402Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markdown-to-ansi\n\n**Convert markdown to ansi with support of hyperlinks.**\n\n[![npm](http://img.shields.io/npm/v/markdown-to-ansi.svg)](https://www.npmjs.org/package/markdown-to-ansi)\n[![node](https://img.shields.io/node/v/markdown-to-ansi.svg)](https://www.npmjs.org/package/markdown-to-ansi)\n[![Test](https://img.shields.io/github/workflow/status/vweevers/markdown-to-ansi/Test?label=test)](https://github.com/vweevers/hallmark/actions/workflows/test.yml)\n[![JavaScript Style Guide](https://img.shields.io/badge/standard-informational?logo=javascript\u0026logoColor=fff)](https://standardjs.com)\n[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org)\n\n## Features\n\nMeant for short snippets of markdown, `markdown-to-ansi` supports a subset of (GFM) markdown:\n\n- Inline code\n- Links. If [the terminal does not support hyperlinks]((https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#supporting-apps)), only the url is returned.\n- Literal urls. GitHub and npm urls are shortened (see example below).\n- Emphasis and strong\n- Headings\n- Thematic breaks (`---`)\n\nOther markdown is simply returned as markdown (not necessarily as-is because it does go through a parser). Pull requests are welcome to support additional markdown syntax. It's easy to extend because `markdown-to-ansi` is built on the [`micromark`](https://github.com/micromark/micromark) parser and friends.\n\n## Usage\n\n_This package is ESM-only._\n\nGiven an `example.md`:\n\n```\n## Links\n\nLiteral url: https://example.com\nMarkdown link: [beep](https://example.com)\nWith formatting: [`boop`](https://example.com)\nPR: https://github.com/vweevers/markdown-to-ansi/pull/1\nCommit: https://github.com/vweevers/markdown-to-ansi/commit/1234567\nRepo: https://github.com/vweevers/markdown-to-ansi\nPackage: https://www.npmjs.com/package/markdown-to-ansi\n\n---\n\n## Lists, strong and emphasis\n\n- **foo**\n- _bar_\n- **_baz_**\n```\n\nAnd running the following `example.js`:\n\n```js\nimport markdownToAnsi from 'markdown-to-ansi'\nimport fs from 'fs'\n\nconst markdown = fs.readFileSync('example.md', 'utf8')\nconst transform = markdownToAnsi()\nconst result = transform(markdown)\n\nconsole.log(result)\n```\n\nResults in:\n\n![example screenshot 1](example/1.png)\n\nMy terminal doesn't support bold, so let me demonstrate custom styles:\n\n```js\nconst chalk = require('chalk')\nconst transform = require('markdown-to-ansi')({\n  style: {\n    thematicBreak: chalk.red,\n    emphasis: chalk.underline,\n    strong: chalk.red\n  }\n})\n```\n\nResults in:\n\n![example screenshot 2](example/2.png)\n\n## API\n\n### `transform = markdownToAnsi([options])`\n\nFactory that returns a `transform` function. Options:\n\n- `stream`: stream to detect support of hyperlinks on, defaults to `stdout`\n- `width` (number): terminal width, used for thematic breaks, defaults to `stream.columns`\n- `style` (object): override one or more styles by providing functions that return a formatted string for:\n  - `inlineCode`\n  - `heading`\n  - `emphasis`\n  - `strong`\n  - `thematicBreak`.\n\n### `ansi = transform(markdown)`\n\nTakes a `markdown` string, returns a string containing ansi escape sequences.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install markdown-to-ansi\n```\n\n## License\n\n[MIT](LICENSE) © Vincent Weevers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fmarkdown-to-ansi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fmarkdown-to-ansi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fmarkdown-to-ansi/lists"}