{"id":26418808,"url":"https://github.com/karinjs/md-html","last_synced_at":"2025-03-18T01:54:41.912Z","repository":{"id":251472468,"uuid":"837524581","full_name":"KarinJS/md-html","owner":"KarinJS","description":"Convert Markdown text to HTML text and automatically highlight it","archived":false,"fork":false,"pushed_at":"2025-01-20T02:06:26.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-20T11:48:58.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/KarinJS.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":"2024-08-03T08:26:38.000Z","updated_at":"2025-01-20T02:06:14.000Z","dependencies_parsed_at":"2024-09-16T16:45:41.005Z","dependency_job_id":"27afa2d7-c1cb-459b-9c78-c65670e42142","html_url":"https://github.com/KarinJS/md-html","commit_stats":null,"previous_names":["karinjs/md-html"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarinJS%2Fmd-html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarinJS%2Fmd-html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarinJS%2Fmd-html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KarinJS%2Fmd-html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KarinJS","download_url":"https://codeload.github.com/KarinJS/md-html/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244141583,"owners_count":20404835,"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":[],"created_at":"2025-03-18T01:54:41.063Z","updated_at":"2025-03-18T01:54:41.896Z","avatar_url":"https://github.com/KarinJS.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project Name\n\nmd-html\n\n[中文](README_ZH.md)\n\n## Project Overview\n\n`md-html` is a tool for rendering Markdown files to HTML, using GitHub-style Markdown and syntax highlighting. It also integrates `marked-alert` and `marked-katex-extension` plugins for handling alerts and mathematical formulas.\n\n## Features\n\n- **Custom Templates**: Supports custom HTML templates.\n- **Syntax Highlighting**: Uses `highlight.js` for syntax highlighting.\n- **GitHub-style Markdown**: Supports GitHub-style Markdown.\n- **Alerts**: Integrates `marked-alert` plugin for Markdown alerts.\n- **Mathematical Formulas**: Integrates `marked-katex-extension` plugin for KaTeX mathematical formula rendering.\n\n## Installation\n\nInstall using npm:\n\n```bash\nnpm install @karinjs/md-html\n```\n\n## Usage\n\n### Basic Usage\n\nHere is a basic usage example:\n\n```javascript\nimport { markdown } from '@karinjs/md-html'\n\nconst markdownText = '# Hello, Markdown!'\nconst html = markdown(markdownText, {})\nconsole.log(html)\n```\n\n### Configuration Options\n\nYou can pass a configuration object to customize the rendering behavior:\n\n```javascript\nimport { markdown } from '@karinjs/md-html'\n\nconst options = {\n  template: 'path/to/custom/template.html',\n  katex: { throwOnError: false },\n  gitcss: 'github-markdown-dark.css', // Use GitHub-style dark theme\n  highlight: 'atom-one-dark', // Use Atom One Dark syntax highlighting theme\n}\n\nconst markdownText = '# Hello, Markdown!'\nconst html = markdown(markdownText, options)\nconsole.log(html)\n```\n\n### Use in Karin\n\n```javascript\nimport karin, { render, segment } from 'node-karin'\nimport { markdown } from '@karinjs/md-html'\nimport fs from 'node:fs'\n\nexport const hello = karin.command(/^#test$/, async (e) =\u003e {\n  // define plugin path\n  const pluginPath = process.cwd() + '/plugins/karin-plugin-basic'\n  // read the markdown file\n  const markdownText = fs.readFileSync(`${pluginPath}/README.md`, 'utf8')\n  // generate html text\n  const html = markdown(markdownText, {})\n  // write to html file\n  fs.writeFileSync(`${pluginPath}/README.html`, html, 'utf8')\n  // render picture\n  const image = await render.renderHtml(`${pluginPath}/README.html`)\n  // send pictures\n  e.reply(segment.image(image))\n  return true\n})\n\n```\n\n## Configuration Options\n\nThe `Options` interface defines configurable options:\n\n- `template` (optional): Path to a custom HTML template file or template string.\n- `katex` (optional): KaTeX configuration options. Refer to the [KaTeX documentation](https://katex.org/docs/options.html) for details.\n- `gitcss` (optional): GitHub Markdown style theme. Possible values are in the `GithubMarkdownThemes` enum.\n- `highlight` (optional): Syntax highlighting theme. Possible values are in the `HighlightJsThemes` enum.\n\n## Development and Build\n\n### Project Structure\n\n```\n@karinjs/md-html/\n├── src/\n│   ├── index.ts\n│   ├── styles.ts\n├── package.json\n├── README.md\n└── ...\n```\n\n### Scripts\n\n- `npm run build`: Build the project.\n\n## Contributions\n\nFeel free to submit issues and pull requests to contribute to the project.\n\n## License\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarinjs%2Fmd-html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarinjs%2Fmd-html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarinjs%2Fmd-html/lists"}