{"id":21589482,"url":"https://github.com/ksw2000/hackmd-to-html-cli","last_synced_at":"2025-04-10T22:14:57.118Z","repository":{"id":57260156,"uuid":"435223687","full_name":"ksw2000/hackmd-to-html-cli","owner":"ksw2000","description":"A CLI/Package converts HackMD markdown to HTML.","archived":false,"fork":false,"pushed_at":"2025-04-08T17:09:10.000Z","size":1857,"stargazers_count":24,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T18:24:34.329Z","etag":null,"topics":["hackmd","markdown","nodejs","npm"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/hackmd-to-html-cli","language":"TypeScript","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/ksw2000.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":"2021-12-05T16:46:24.000Z","updated_at":"2025-04-08T17:09:08.000Z","dependencies_parsed_at":"2024-11-07T15:29:47.689Z","dependency_job_id":"a9e94a53-a682-464a-a282-2bd83776e18a","html_url":"https://github.com/ksw2000/hackmd-to-html-cli","commit_stats":{"total_commits":70,"total_committers":1,"mean_commits":70.0,"dds":0.0,"last_synced_commit":"d8734f78ff2dbd784077d7f05183f9102cafdbfc"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksw2000%2Fhackmd-to-html-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksw2000%2Fhackmd-to-html-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksw2000%2Fhackmd-to-html-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksw2000%2Fhackmd-to-html-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksw2000","download_url":"https://codeload.github.com/ksw2000/hackmd-to-html-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247909136,"owners_count":21016475,"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":["hackmd","markdown","nodejs","npm"],"created_at":"2024-11-24T16:14:37.296Z","updated_at":"2025-04-10T22:14:56.584Z","avatar_url":"https://github.com/ksw2000.png","language":"TypeScript","readme":"# hackmd-to-html-cli\n\n[![NPM version](https://img.shields.io/npm/v/hackmd-to-html-cli.svg?logo=npm\u0026style=flat-square)](https://www.npmjs.org/package/hackmd-to-html-cli) ![](https://img.shields.io/github/license/ksw2000/hackmd-to-html-cli?color=yellow\u0026style=flat-square) ![](https://img.shields.io/github/actions/workflow/status/ksw2000/hackmd-to-html-cli/gitpage.yml?branch=main\u0026style=flat-square) ![](https://img.shields.io/npm/dt/hackmd-to-html-cli?color=blue\u0026style=flat-square)\n\nNot only is this a CLI tool, but it is also an importable package for converting standard Markdown and even [HackMD](https://hackmd.io/)-supported Markdown into HTML.\n\n+ Example of input markdown: [./example/index.md](https://raw.githubusercontent.com/ksw2000/hackmd-to-html-cli/main/example/index.md)\n+ Example of output html: [https://ksw2000.github.io/hackmd-to-html-cli/](https://ksw2000.github.io/hackmd-to-html-cli/)\n+ Example of output html in dark mode: [https://ksw2000.github.io/hackmd-to-html-cli/index.dark.html](https://ksw2000.github.io/hackmd-to-html-cli/index.dark.html)\n+ Example of converting in web: [https://ksw2000.github.io/hackmd-to-html-cli/webjs.html](https://ksw2000.github.io/hackmd-to-html-cli/webjs.html)\n\n## Install\n\n```sh\n# CLI\nnpm install -g hackmd-to-html-cli\n\n# Package\nnpm install hackmd-to-html-cli\n```\n\n## CLI\n\n```sh\n$ hmd2html --help\nhmd2html --help\nUsage: index [options]\n\nOptions:\n  -v, --version                   output the current version\n  -i, --input \u003cfiles_or_urls...\u003e  the path/url of input markdown files\n  -d, --dest \u003cdir\u003e                the path of output directory (filename is generated automatically) (default: ./output)\n  -o, --output \u003cfiles...\u003e         the path of output file (ignored if the flag -d is set) (default: \"\")\n  -l, --layout \u003chtml_file\u003e        specify the layout file (default: \"\")\n  -b, --hardBreak                 use hard break instead of soft break\n  -k, --dark                      use the dark mode layout (activate only if the -l option is not set)\n  -h, --help                      display help for command\n```\n\n**Convert**\n\n```sh\n# convert files\n$ hmd2html -i file1.md file2.md file3.md\n\n# allow wildcard input\n$ hmd2html -i dir/*.md\n\n# allow url input\n$ hmd2html -i https://github.com/ksw2000/hackmd-to-html-cli/blob/main/example/index.md\n\n# set output folder\n$ hmd2html -i file1.md -d ./my_output\n\n# set the filename of output\n$ hmd2html -i file1.md -o file1.html\n$ hmd2html -i file1.md file2.md -o file1.html file2.html\n\n# use default darkmode layout\n$ hmd2html -i file1.md -k\n\n# use custom layout\n$ hmd2html -i hello.md -l ./myLayout.html\n```\n\n## Layouts\n\nWe provide the two default layouts. Please see layouts here: [https://github.com/ksw2000/hackmd-to-html-cli/blob/main/layouts/](./layouts/)\n\n+ `{{main}}` renders main content of markdown.\n+ `{{lang}}` renders lang property if there are yaml metadata about `lang` in markdown file. e.g. `lang=\"zh-TW\"`\n+ `{{dir}}` renders dir property if there are yaml metadata about `dir` in markdown file. e.g. `dir=\"ltr\"`\n+ `{{meta}}` renders meta tag if there are yaml metadata about `title`, `description`, `robots` or`image`. e.g. `\u003cmeta name=\"robots\" content=\"noindex\"\u003e`\n\nExample:\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml {{lang}} {{dir}}\u003e\n\u003chead\u003e\n    {{metas}}\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\"\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003cbody\u003e\n      {{main}}\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThere are some features rendered by other dependencies. Thus, in our default layout, we include those dependencies.\n\n## Example\n\n### CommonJS\n\n```js\nconst { Converter } = require('hackmd-to-html-cli')\n\nconst converter = new Converter();\nconst res = converter.render(\"# hello\");\n\nconsole.log(res.main);\n```\n\n\n### ES Module\n\n```ts\nimport { Converter } from \"hackmd-to-html-cli\"\n\nconst converter = new Converter();\nconst res = converter.render(\"# hello\");\n\nconsole.log(res.main);\n```\n\n### Web\n\n```js\nconst converter = new window.hmd2html.Converter();\nconst res = converter.render(\"# hello\");\nconsole.log(res.main);\n```\n\n## Support\n\n`hmd2html`: our tool (the latest)\n\n`HackMD Default Converter`: The default markdown to html converter provided by HackMD, i.e., download HTML file on HackMD.\n\nHackMD fully supports syntax: [features](https://hackmd.io/features-tw?both)\n\n| Features   | hmd2html  | HackMD\u003cbr\u003eDefault Converter |\n|---------------------------------|:--:|:--:|\n| ToC                             | ✅ | ✅ |\n| Emoji                           | ✅ | ✅ |\n| ToDo list                       | ✅ | ✅ |\n| Code block                      | ✅ | ✅ |\n| - Show line number or not       | ✅ | ❌ |\n| - Specify the start line number | ✅ | ❌ |\n| - Continue line number          | ✅ | ❌ |\n| Blockquote                      | ✅ | ✅ |\n| - specify your name             | ✅ | ✅ |\n| - specify time                  | ✅ | ✅ |\n| - color                         | ✅ | ✅ |\n| Render CSV as table             | ✅ | ✅ |\n| MathJax                         | ✅ | ✅ |\n| Sequence diagrams               | ✅ | ❌ |\n| Flow charts                     | ✅ | ❌ |\n| Graphviz                        | ✅ | ❌ |\n| Mermaid                         | ✅ | ❌ |\n| Abc                             | ✅ | ❌ |\n| PlantUML                        | ✅ | ✅ |\n| Vega-Lite                       | ✅ | ❌ |\n| Fretboard                       | ✅ | ❌ |\n| Alert Area                      | ✅ | ✅ |\n| Detail                          | ✅ | ✅ |\n| Spoiler container               | ✅ | ✅ |\n| Headers h1-h6                   | ✅ | ✅ |\n| Horizontal line `---` `***`     | ✅ | ✅ |\n| Bold `**b**` `__b__`            | ✅ | ✅ |\n| Italic `*i*` `_i_`              | ✅ | ✅ |\n| Deleted text `~~del~~`          | ✅ | ✅ |\n| Superscript `^sup^`             | ✅ | ✅ |\n| Subscript  `~sub~`              | ✅ | ✅ |\n| Inserted text `++ins++`         | ✅ | ✅ |\n| Marked text `==mark==`          | ✅ | ✅ |\n| Ruby case                       | ✅ | ✅ |\n| Typographic\u003cbr\u003ereplacements     | ✅ | ✅ |\n| Blockquotes                     | ✅ | ✅ |\n| List                            | ✅ | ✅ |\n| Tables                          | ✅ | ✅ |\n| Links                           | ✅ | ✅ |\n| Link with title                 | ✅ | ✅ |\n| Autoconverted link              | ✅ | ✅ |\n| Image                           | ✅ | ✅ |\n| - normal                        | ✅ | ✅ |\n| - with title                    | ✅ | ✅ |\n| - given size                    | ✅ | ✅ |\n| Footnotes                       | ✅ | ✅ |\n| Definition list                 | ✅ | ✅ |\n| Abbreviations                   | ✅ | ✅ |\n\n### Support Externals\n\n| Features    | hmd2html  | HackMD\u003cbr\u003eDefault Converter|\n|-------------|:---------:|:---------:|\n| Youtube     | ✅       | ✅        |\n| Vimeo       | ✅       | ❌        |\n| Gist        | ✅       | ✅        |\n| SlideShare  | ❌       | ❌        |\n| Speakerdeck | ✅       | ✅        |\n| PDF         | ✅       | ✅        |\n| Figma       | ✅       | ✅        |\n\n### Support YAML Metadata\n\n| Features      | hmd2html  | Implementation  |\n|---------------|:---------:|:-------:|\n| title         | ✅       | `\u003ctitle\u003e\u003c/title\u003e`\u003cbr\u003e`\u003cmeta name=\"twitter:title\"\u003e`\u003cbr\u003e`\u003cmeta property=\"og:title\"\u003e`|\n| description   | ✅       | `\u003cmeta name=\"description\"\u003e`\u003cbr\u003e`\u003cmeta name=\"twitter:description\"\u003e`\u003cbr\u003e`\u003cmeta property=\"og:description\"\u003e` |\n| robots        | ✅       | `\u003cmeta name=\"robots\"\u003e` |\n| lang          | ✅       | `\u003chtml lang=\"\"\u003e` |\n| dir           | ✅       | `\u003chtml dir=\"\"\u003e` |\n| image         | ✅       | `\u003cmeta property=\"og:image\"\u003e`\u003cbr\u003e`\u003cmeta name=\"twitter:image:src\"\u003e` |\n| others        | ✅       | Hide the metadata by html comment |\n\nHackMD sets the `lang` tag and `dir` tag at the beginning of `\u003cbody\u003e`. hmd2html sets the the `lang` tag and `dir` tag at `\u003chtml\u003e` when using default layout.\n\n## Development\n\n1. `npm run lint` to check the format of source code.\n2. `npm run example` runs example for this package, which generates result from `./example` and places them in `./output`.\n3. `npm test` runs unit test files whose filenames end with `.spec.ts`\n\n## Contributing\n\nContributions to **hackmd-to-html-cli** are welcome and highly appreciated. Please run lint `npm run lint` and test `npm run test` before pull requesting.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksw2000%2Fhackmd-to-html-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksw2000%2Fhackmd-to-html-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksw2000%2Fhackmd-to-html-cli/lists"}