{"id":13837456,"url":"https://github.com/danburzo/trimd","last_synced_at":"2025-09-07T00:43:04.262Z","repository":{"id":65949605,"uuid":"603234734","full_name":"danburzo/trimd","owner":"danburzo","description":"Convert between HTML, Markdown, and plain text from the command line.","archived":false,"fork":false,"pushed_at":"2024-10-29T17:17:20.000Z","size":179,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-08-13T17:00:40.890Z","etag":null,"topics":["cli","html","markdown"],"latest_commit_sha":null,"homepage":"https://danburzo.ro/projects/trimd/","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/danburzo.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":"2023-02-17T22:48:26.000Z","updated_at":"2024-10-29T17:17:24.000Z","dependencies_parsed_at":"2024-01-29T13:07:04.237Z","dependency_job_id":"4a4445cd-9a7f-40e8-82a8-b9ed5e00d731","html_url":"https://github.com/danburzo/trimd","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"32f0903d8a3bfaf7fc3ee4afa7562d0a31561ffd"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/danburzo/trimd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danburzo%2Ftrimd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danburzo%2Ftrimd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danburzo%2Ftrimd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danburzo%2Ftrimd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danburzo","download_url":"https://codeload.github.com/danburzo/trimd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danburzo%2Ftrimd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273983074,"owners_count":25202092,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","html","markdown"],"created_at":"2024-08-04T15:01:10.046Z","updated_at":"2025-09-07T00:43:04.237Z","avatar_url":"https://github.com/danburzo.png","language":"JavaScript","funding_links":[],"categories":["HTML"],"sub_categories":[],"readme":"# trimd\n\nConvert between HTML, Markdown, and plain text from the command line.\n\nAn online companion tool is available at [**danburzo.ro/trimd**](https://danburzo.ro/trimd/).\n\n## Getting started\n\nInstall `trimd` globally using `npm`:\n\n```bash\nnpm install -g trimd\n```\n\nOr run `trimd` on the fly using `npx`:\n\n```bash\nnpx trimd markdown my-file.html\n```\n\n## Usage\n\n```bash\ntrimd [command] [options] [file1, [file2, …]]\n```\n\nTrimd accepts one or more input files, or uses the standard input (`stdin`) when no files are provided. You can also concatenate `stdin` in addition to other input files using the `-` operator.\n\nA couple of general options are available:\n\n-   **`-h, --help`** - output help information.\n-   **`-v, --version`** - output program version.\n-   **`--silent`** - suppress the output of commands.\n\nBy default, the results of processing the operands are concatenated to `stdout`. Use the `--write` option to write the results back to their respective original files.\n\nBelow is a list of supported commands.\n\n### `trimd markdown`\n\nConvert HTML to Markdown.\n\n```bash\ntrimd markdown my-file.html\n```\n\nYou can pass your own preferences for generating Markdown with options in the form **`--md.\u003coption\u003e=\u003cvalue\u003e`**, which will get forwarded to [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify):\n\n```bash\ntrimd markdown --md.strong='*' my-file.html\n```\n\nThese are the default Markdown options:\n\n```js\nconst MD_DEFAULTS = {\n\tfences: true,\n\temphasis: '_',\n\tstrong: '_',\n\tresourceLink: true,\n\trule: '-'\n};\n```\n\n### `trimd markup`\n\nConvert Markdown to HTML.\n\n```bash\ntrimd markup my-file.md\n```\n\nThis command ignores any YAML/TOML front-matter data present in the source file.\n\nUse the `--data-url` flag to output the HTML as a base64-encoded `data:` URL. This format can be useful for viewing the HTML content in a browser:\n\n```bash\ntrimd markup --data-url my-file.md | xargs open -a Firefox\n```\n\n\u003e Note that at the time of writing, Firefox does not immediately render `data:` URLs passed from the command line (you need to press \u003ckbd\u003eReturn\u003c/kbd\u003e in the URL bar). See [#1892289](https://bugzilla.mozilla.org/show_bug.cgi?id=1892289), which is in the process of being fixed.\n\nUse the `--no-sanitize` flag to skip the HTML sanitization step. Sanitization should only be disabled when the Markdown input is known to be safe.\n\n### `trimd remarkup`\n\nSimplify HTML by converting it to Markdown and back. The command is more or less the equivalent of `trimd markdown | trimd markup`.\n\nUse the `--data-url` flag to output the HTML as a base64-encoded `data:` URL.\n\nUse the `--no-sanitize` flag to skip the HTML sanitization step. Sanitization should only be disabled when the HTML input is known to be safe.\n\n### `trimd remarkdown`\n\nConvert Markdown to Markdown. The command accepts the same options as `trimd markdown`.\n\n```bash\ntrimd remarkdown my-file.md\n```\n\nThe `trimd remarkdown` command is useful for converting Markdown that may contain raw HTML into the Markdown style specified with the `--md.\u003coption\u003e=\u003cvalue\u003e` options.\n\nThis command preserves any YAML/TOML front-matter data present in the source file.\n\nYou can transform the Markdown output by providing a transform function specified in an external JavaScript file and passed via the `-t \u003ctransform\u003e` or `--transform=\u003ctransform\u003e` option.\n\n```bash\ntrimd remarkdown --transform=exclamation.js my-input.md\n```\n\n```js\n// File: exclamation.js\n\nexport default function exclamation(visit) {\n\treturn function transform(tree, file) {\n\t\tvisit(tree, 'text', function (node, index, parent) {\n\t\t\tnode.value += '!';\n\t\t});\n\t};\n}\n```\n\nThe default export of your transformer will receive a reference to the `visit` function from the [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit) package. This is provided as a convenience, you can use it or write your own processing logic.\n\nThis export must return a function that transforms the [\u003cabbr\u003eMDAST\u003c/abbr\u003e tree](https://github.com/syntax-tree/mdast) passed as the first argument. See [`unified.use(Plugin)`](https://github.com/unifiedjs/unified?tab=readme-ov-file#plugin) for more details.\n\n### `trimd demarkdown`\n\nConvert Markdown to plain text.\n\n```bash\ntrimd demarkdown my-file.md\n```\n\nThis command ignores any YAML/TOML front-matter data present in the source file.\n\n### `trimd demarkup`\n\nConvert HTML to plain text.\n\n```bash\ntrimd demarkup my-file.html\n```\n\nPlain text is produced according to the algorithm for [`HTMLElement.innerText`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText).\n\nYou can also convert HTML to plain text via Markdown by piping `markdown` and `demarkdown` commands:\n\n```bash\ntrimd markdown my-file.html | trimd demarkdown\n```\n\n## Acknowledgements\n\nTrimd is a command-line interface on top of a chain of [unified.js](https://unifiedjs.com) libraries.\n\n## See also\n\n-   [Clipboard Inspector](https://github.com/evercoder/clipboard-inspector), a tool to help you explore the kinds of data available when you paste something on a web page, or drop something onto it.\n-   [percollate](https://github.com/danburzo/percollate), a command-line tool to turn web pages into beautiful, readable PDF, EPUB, or HTML docs.\n-   [hred](https://github.com/danburzo/hred), extract data from HTML (and XML) from the command line, using a syntax inspired by CSS selector.\n-   [yamatter](https://github.com/danburzo/yamatter), inspect and transform YAML frontmatter data from the command line.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanburzo%2Ftrimd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanburzo%2Ftrimd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanburzo%2Ftrimd/lists"}