{"id":13800447,"url":"https://github.com/littletof/charmd","last_synced_at":"2026-02-28T06:54:18.956Z","repository":{"id":53833448,"uuid":"325817855","full_name":"littletof/charmd","owner":"littletof","description":"A simple, extendable markdown renderer for your terminal.","archived":false,"fork":false,"pushed_at":"2024-04-24T17:01:39.000Z","size":904,"stargazers_count":64,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T07:03:50.101Z","etag":null,"topics":["ast","cli","deno","deno-cli","markdown","markdown-viewer","terminal","terminal-markdown"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/littletof.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"ko_fi":"littletof","custom":["https://www.buymeacoffee.com/littletof","https://coindrop.to/littletof"]}},"created_at":"2020-12-31T14:38:20.000Z","updated_at":"2025-04-29T17:53:22.000Z","dependencies_parsed_at":"2024-04-24T17:52:09.132Z","dependency_job_id":"43c21bc4-8d27-46d7-8751-3b27d8ba7432","html_url":"https://github.com/littletof/charmd","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":"0.31034482758620685","last_synced_commit":"c350f36ab62132033d26891d544efce7ea589806"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littletof%2Fcharmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littletof%2Fcharmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littletof%2Fcharmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/littletof%2Fcharmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/littletof","download_url":"https://codeload.github.com/littletof/charmd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251658201,"owners_count":21622819,"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":["ast","cli","deno","deno-cli","markdown","markdown-viewer","terminal","terminal-markdown"],"created_at":"2024-08-04T00:01:12.691Z","updated_at":"2026-02-28T06:54:13.911Z","avatar_url":"https://github.com/littletof.png","language":"JavaScript","funding_links":["https://ko-fi.com/littletof","https://www.buymeacoffee.com/littletof","https://coindrop.to/littletof"],"categories":["JavaScript","Modules"],"sub_categories":["CLI utils"],"readme":"# 🎩 charMD\n\n[![deno badge](https://img.shields.io/badge/deno.land/x-success?logo=deno\u0026logoColor=black\u0026labelColor=white\u0026color=black)](https://deno.land/x/charmd)\n[![JSR](https://jsr.io/badges/@littletof/charmd)](https://jsr.io/@littletof/charmd)\n[![snapper_deno](https://img.shields.io/badge/-snapper%20%F0%9F%93%B7-%230DBC79)](https://github.com/littletof/snapper)\n\n*A simple, extendable markdown renderer for your terminal.*\n\n**`charMD`** enables you to render a markdown text into a string, which printed in the terminal provides a well formatted output, instead of plain text.\n\n![Showcase](docs/showcase.png)\n\n## Try it out\n\nTo see the general capabilities of this module run:\n\n```bash\ndeno run https://deno.land/x/charmd/example.ts\n```\n\nTo see, how a specific markdown gets rendered run:\n\n```bash\ndeno run --allow-read https://deno.land/x/charmd/example.ts ./README.md\n```\n\n## Usage\n\nSimply import the module and call the `renderMarkdown` method with your markdown text.\n\n```ts\nimport { renderMarkdown } from 'https://deno.land/x/charmd/mod.ts';\n\nconsole.log(renderMarkdown('# Hello world 🌍!'));\n```\n\nAlternatevily you can import from [JSR](https://jsr.io/)\n\n```ts\nimport { renderMarkdown } from 'jsr:@littletof/charmd';\n```\n\n\n### 🧩 Extensions\n\nThe module provides a way to extend it functionality with additional extensions, which can be provided in it's `options` param.\n\nAn extension can implement any of the `Extension` interface's methods, which are:\n\n- `init`: Called before AST generation, if a string is returned, it will override the input markdown for later extension's init fn and processing steps.\n- `postAST`: Called with the generated AST's root node, before any    transformations\n- `transformNode`: Called with each node to do modifications on the node and it's children in the `AST`.\n- `postTransform`: Called with root, after all the transformations ran for all nodes.\n- `generateNode`: Called with each node. It should return the string representation of the rendered node,if the extension handles that specific node, or void, if its not handled by the extension.\n- `postGenerate`: Called after the string representation is created.\n\nA simple extension, that renders `link` with green and blue instead of the built-in cyan would look something like this:\n\n```ts\nconst LinkExt = {\n    generateNode(genFn, node: Node, parent: Node, options: Options) {\n          if(node.type === 'link') {\n            const linkText = node.children?.map(ch =\u003e genFn(ch, node, options)).join('') || '';\n            const link = `Link with text '${colors.blue(linkText)}' points to ${colors.cyan(node.url!)}`\n            return colors.green(link);\n          }\n      }\n}\n\nconsole.log(renderMarkdown(\n    '[charMD](https://github.com/littletof/charmd)',\n    { extensions: [LinkExt] }\n));\n```\n\n### Direct use - `cli.ts`\n\nFor direct use in the terminal run `cli.ts`:\n\n```bash\ndeno run --allow-net https://deno.land/x/charmd/cli.ts -r https://raw.githubusercontent.com/denoland/deno/master/README.md\n```\n\nOr install it with `deno install`\n\nIt has three options:\n\n- `-s` for rendering a string directly: `-s \"# markdown string\"`\n- `-l` for rendering a local file: `-l ./README.md`\n- `-r` for rendering a remote file: `-r https://raw.githubusercontent.com/denoland/deno/master/README.md`\n\n## Permissions\n\nThe module itself requires no permissions to run.\n\n## Limitations\n\n- No syntax highlight\n- No multiline tables cells\n- Possible hiccups with more complex markdowns (Please open an issue about it)\n\nThese could change in the future, but the aim is to keep the module's complexity minimal.\n\u003e Also, many of these should also be solvable using extensions.\n\u003e\n\u003e [syntax highlight example](https://github.com/littletof/charmd/issues/2#issuecomment-832771746)\n\n## Notes\n\n- The main functions are also exported from the module, so for example you can use the `toAST` function to get your ast for the markdown and process it yourself.\n\n- As its core, it currently uses [mdast-util-from-markdown](https://github.com/syntax-tree/mdast-util-from-markdown), to get the `AST`, you can also provide extensions to it in the options **unstable** `mdast` property.\n\n- This module's core structure draws from @dephraims work with \u003chttps://github.com/dephraiim/termd\u003e.\n\n## Contributions\n\nFeedback and contributions are always welcome. Open an issue or a PR, or contact me on the Deno discord.\n\n## TODO\n\n- [x] fix lists\n- [x] remove dots from codeblock backgrounds\n- [x] links with images\n- [x] `# Header with *italic*`\n- [x] strikethrough, ~~underline~~\n- [x] basic tests\n- [x] lint\n- [x] fmt\n- [ ] Look into alternatives for the AST generation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittletof%2Fcharmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittletof%2Fcharmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittletof%2Fcharmd/lists"}