{"id":32309134,"url":"https://github.com/jarontai/html2md","last_synced_at":"2026-02-21T16:03:08.882Z","repository":{"id":31685592,"uuid":"128036168","full_name":"jarontai/html2md","owner":"jarontai","description":"A library for converting HTML to Markdown in Dart. It supports CommonMark, simple table and custom converting rules. 将html转换为markdown的Dart库，支持CommonMark、简单表格以及自定义转换规则。","archived":false,"fork":false,"pushed_at":"2024-05-29T12:34:02.000Z","size":113,"stargazers_count":57,"open_issues_count":6,"forks_count":27,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-01T15:21:03.552Z","etag":null,"topics":["converter","dart","html","markdown"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/html2md","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jarontai.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":"2018-04-04T09:00:29.000Z","updated_at":"2025-10-14T01:55:35.000Z","dependencies_parsed_at":"2024-05-29T14:26:29.924Z","dependency_job_id":"d281f8c3-eecf-4292-93d6-7e64786ebcab","html_url":"https://github.com/jarontai/html2md","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jarontai/html2md","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jarontai%2Fhtml2md","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jarontai%2Fhtml2md/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jarontai%2Fhtml2md/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jarontai%2Fhtml2md/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jarontai","download_url":"https://codeload.github.com/jarontai/html2md/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jarontai%2Fhtml2md/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29685050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["converter","dart","html","markdown"],"created_at":"2025-10-23T08:13:41.847Z","updated_at":"2026-02-21T16:03:08.876Z","avatar_url":"https://github.com/jarontai.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"English | [简体中文](./README_CN.md)\n\n# html2md\n\n[![Pub](https://img.shields.io/pub/v/html2md.svg)](https://pub.dev/packages/html2md)\n[![Build status](https://travis-ci.org/jarontai/html2md.svg)](https://travis-ci.org/jarontai/html2md)\n\nA library for converting HTML to Markdown in Dart. It supports CommonMark, simple table and custom converting rules.\n\n## Usage\n\nA simple usage example:\n\n~~~dart\nimport 'package:html2md/html2md.dart' as html2md;\n\nmain() {\n    var html = '\u003ch1\u003eHTML2MD Demo\u003c/h1\u003e';\n    print(html2md.convert(html));\n}\n~~~\n\nIn flutter, you can use the [flutter_markdown](https://pub.dev/packages/flutter_markdown) for rendering:\n\n~~~dart\nimport 'package:html2md/html2md.dart' as html2md;\nimport 'package:flutter_markdown/flutter_markdown.dart';\n\nbuild(BuildContext context) {\n    // Caution!\n    // This is not best practice, you should not call convert in build\n    // and the converted markdown should put in state.\n    var html = '\u003ch1\u003eHTML2MD Demo\u003c/h1\u003e';\n    var markdown = html2md.convert(html);\n    return Markdown(data: markdown);\n}\n~~~\n\n## Config\n\nYou can config convert style by passing `styleOptions` to `convert`, elements that should be ignored also can be set with `ignore`. If you want to customize element converting, use custom [rules](#custom-rules)!\n\n~~~dart\nhtml2md.convert(html,\n    styleOptions: {'headingStyle': 'atx'},\n    ignore: ['script'],\n    rules: [Rule('custom')]);\n~~~\n\nThe default and available style options:\n\n| Name        | Default           | Options  |\n| ------------- |:-------------:| -----:|\n| headingStyle      | \"setext\" | \"setext\", \"atx\" |\n| hr      | \"* * *\" | \"* * *\", \"- - -\", \"_ _ _\" |\n| bulletListMarker      | \"*\" | \"*\", \"-\", \"_\" |\n| codeBlockStyle      | \"indented\" | \"indented\", \"fenced\" |\n| fence      | \"\\`\\`\\`\" | \"\\`\\`\\`\", \"~~~\" |\n| emDelimiter      | \"_\" | \"_\", \"*\" |\n| strongDelimiter      | \"**\" | \"**\", \"__\" |\n| linkStyle      | \"inlined\" | \"inlined\", \"referenced\" |\n| linkReferenceStyle      | \"full\" | \"full\", \"collapsed\", \"shortcut\" |\n\n## Table support\n\nBasic table converting is supported! \n\nHtml table source:\n\n    \u003ctable\u003e\n        \u003ctr\u003e\n            \u003cth\u003eFirst Header\u003c/th\u003e\n            \u003cth\u003eFirst Header\u003c/th\u003e \n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eContent Cell\u003c/td\u003e\n            \u003ctd\u003eContent Cell\u003c/td\u003e\n        \u003c/tr\u003e\n        \u003ctr\u003e\n            \u003ctd\u003eContent Cell\u003c/td\u003e\n            \u003ctd\u003eContent Cell\u003c/td\u003e\n        \u003c/tr\u003e\n    \u003c/table\u003e\n\nThe converted markdown source:\n\n    | First Header  | Second Header |\n    | ----- | ----- |\n    | Content Cell  | Content Cell  |\n    | Content Cell  | Content Cell  |\n\nThe converted markdown table:\n\n| First Header  | Second Header |\n| ----- | ----- |\n| Content Cell  | Content Cell  |\n| Content Cell  | Content Cell  |\n\n## Custom Rules\n\nWant to customize element converting? Write your rules!\n\nRule fields explaination\n\n~~~dart\nfinal String name; // unique rule name\nfinal List\u003cString\u003e? filters; // simple element name filters, e.g. ['aside']\nfinal FilterFn? filterFn; // function for building complex element filter logic\nfinal Replacement? replacement; // function for doing the replacing\nfinal Append? append; // function for appending content\n~~~\n\nRule example - Convert the onebox section of [discourse](https://www.discourse.org/) post to a link\n\n~~~html\n\u003caside class=\"onebox\"\u003e\n  \u003cheader class=\"source\"\u003e\n      \u003cimg src=\"https://discoursesite/uploads/default/original/1X/test.png\" class=\"site-icon\" width=\"32\" height=\"32\"\u003e\n      \u003ca href=\"https://events.google.com/io/program/content?4=topic_flutter\u0026amp;lng=zh-CN\" target=\"_blank\" rel=\"noopener\"\u003eGoogle I/O 2021\u003c/a\u003e\n  \u003c/header\u003e\n\u003c/aside\u003e\n~~~\n\n~~~dart\nRule(\n  'discourse-onebox',\n  filterFn: (node) {\n    // Find aside with onebox class\n    if (node.nodeName == 'aside' \u0026\u0026\n        node.className.contains('onebox')) {\n        return true;\n    }\n    return false;\n  },\n  replacement: (content, node) {\n    // find the first a element under header\n    var header = node.firstChild;\n    var link = header!\n        .childNodes()\n        .firstWhere((element) =\u003e element.nodeName == 'a');\n    var href = link.getAttribute('href');\n    if (href != null \u0026\u0026 href.isNotEmpty) {\n      return '[$href]($href)'; // build the link\n    }\n    return '';\n  },\n)\n~~~\n\n## Test\n\n    dart run test\n\n## Features and bugs\n\nPlease file feature requests and bugs at the [issue tracker][tracker].\n\n[tracker]: https://github.com/jarontai/html2md/issues\n\n## Inspiration\n\nhtml2md is basicly a simplify version of Node's [turndown](https://github.com/domchristie/turndown)\n\n## License\nCreated from templates made available by Stagehand under a BSD-style\n[license](https://github.com/jarontai/html2md/blob/master/LICENSE).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjarontai%2Fhtml2md","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjarontai%2Fhtml2md","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjarontai%2Fhtml2md/lists"}