{"id":13395740,"url":"https://github.com/dart-lang/markdown","last_synced_at":"2025-02-26T04:09:11.200Z","repository":{"id":7027448,"uuid":"8300662","full_name":"dart-lang/markdown","owner":"dart-lang","description":"A Dart markdown library","archived":false,"fork":false,"pushed_at":"2025-02-01T02:27:19.000Z","size":6859,"stargazers_count":465,"open_issues_count":0,"forks_count":204,"subscribers_count":49,"default_branch":"master","last_synced_at":"2025-02-19T03:09:44.528Z","etag":null,"topics":["dart","dartlang","markdown","parser"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/markdown","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dart-lang.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":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-19T22:11:04.000Z","updated_at":"2025-02-18T15:20:53.000Z","dependencies_parsed_at":"2023-01-17T00:01:03.045Z","dependency_job_id":"2a302380-9efb-4faf-b26c-21cba4e0d0b5","html_url":"https://github.com/dart-lang/markdown","commit_stats":{"total_commits":498,"total_committers":51,"mean_commits":9.764705882352942,"dds":0.7771084337349398,"last_synced_commit":"3d8d7a8f14b74bb646bb6e4ae35e0bf2beb74154"},"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-lang%2Fmarkdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-lang%2Fmarkdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-lang%2Fmarkdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dart-lang%2Fmarkdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dart-lang","download_url":"https://codeload.github.com/dart-lang/markdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240788771,"owners_count":19857699,"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":["dart","dartlang","markdown","parser"],"created_at":"2024-07-30T18:00:30.131Z","updated_at":"2025-02-26T04:09:11.117Z","avatar_url":"https://github.com/dart-lang.png","language":"Dart","readme":"\u003e [!IMPORTANT]  \n\u003e This repo has moved to https://github.com/dart-lang/tools/tree/main/pkgs/markdown\n\n[![Build Status](https://github.com/dart-lang/markdown/workflows/Dart%20CI/badge.svg)](https://github.com/dart-lang/markdown/actions?query=workflow%3A\"Dart+CI\"+branch%3Amaster)\n[![Pub](https://img.shields.io/pub/v/markdown.svg)](https://pub.dev/packages/markdown)\n[![package publisher](https://img.shields.io/pub/publisher/markdown.svg)](https://pub.dev/packages/markdown/publisher)\n[![Coverage Status](https://coveralls.io/repos/github/dart-lang/markdown/badge.svg?branch=master)](https://coveralls.io/github/dart-lang/markdown?branch=master)\n\nA portable Markdown library written in Dart. It can parse Markdown into\nHTML on both the client and server.\n\nPlay with it at\n[dart-lang.github.io/markdown](https://dart-lang.github.io/markdown).\n\n### Usage\n\n```dart\nimport 'package:markdown/markdown.dart';\n\nvoid main() {\n  print(markdownToHtml('Hello *Markdown*'));\n  //=\u003e \u003cp\u003eHello \u003cem\u003eMarkdown\u003c/em\u003e\u003c/p\u003e\n}\n```\n\n### Syntax extensions\n\nA few Markdown extensions, beyond what was specified in the original\n[Perl Markdown][] implementation, are supported. By default, the ones supported\nin [CommonMark] are enabled. Any individual extension can be enabled by\nspecifying an Array of extension syntaxes in the `blockSyntaxes` or\n`inlineSyntaxes` argument of `markdownToHtml`.\n\nThe currently supported inline extension syntaxes are:\n\n* `InlineHtmlSyntax()` - approximately CommonMark's\n  [definition][commonmark-raw-html] of \"Raw HTML\".\n\nThe currently supported block extension syntaxes are:\n\n* `const FencedCodeBlockSyntax()` - Code blocks familiar to Pandoc and PHP\n  Markdown Extra users.\n* `const HeaderWithIdSyntax()` - ATX-style headers have generated IDs, for link\n  anchors (akin to Pandoc's [`auto_identifiers`][pandoc-auto_identifiers]).\n* `const SetextHeaderWithIdSyntax()` - Setext-style headers have generated IDs\n  for link anchors (akin to Pandoc's\n  [`auto_identifiers`][pandoc-auto_identifiers]).\n* `const TableSyntax()` - Table syntax familiar to GitHub, PHP Markdown Extra,\n  and Pandoc users.\n\nFor example:\n\n```dart\nimport 'package:markdown/markdown.dart';\n\nvoid main() {\n  print(markdownToHtml('Hello \u003cspan class=\"green\"\u003eMarkdown\u003c/span\u003e',\n      inlineSyntaxes: [InlineHtmlSyntax()]));\n  //=\u003e \u003cp\u003eHello \u003cspan class=\"green\"\u003eMarkdown\u003c/span\u003e\u003c/p\u003e\n}\n```\n\n### Extension sets\n\nTo make extension management easy, you can also just specify an extension set.\nBoth `markdownToHtml()` and `Document()` accept an `extensionSet` named\nparameter. Currently, there are four pre-defined extension sets:\n\n* `ExtensionSet.none` includes no extensions. With no extensions, Markdown\n  documents will be parsed with a default set of block and inline syntax\n  parsers that closely match how the document might be parsed by the original\n  [Perl Markdown][] implementation.\n\n* `ExtensionSet.commonMark` includes two extensions in addition to the default\n  parsers to bring the parsed output closer to the [CommonMark] specification:\n\n  * Block Syntax Parser\n    * `const FencedCodeBlockSyntax()`\n  \n  * Inline Syntax Parser\n    * `InlineHtmlSyntax()`\n\n* `ExtensionSet.gitHubFlavored` includes five extensions in addition to the default\n  parsers to bring the parsed output close to the [GitHub Flavored] Markdown\n  specification: \n\n  * Block Syntax Parser\n    * `const FencedCodeBlockSyntax()`\n    * `const TableSyntax()`\n  \n  * Inline Syntax Parser\n    * `InlineHtmlSyntax()`\n    * `StrikethroughSyntax()`\n    * `AutolinkExtensionSyntax()`\n\n* `ExtensionSet.gitHubWeb` includes eight extensions. The same set of parsers use\n   in the `gitHubFlavored` extension set with the addition of the block syntax parsers,\n   HeaderWithIdSyntax and SetextHeaderWithIdSyntax, which add `id` attributes to\n   headers and inline syntax parser, EmojiSyntax, for parsing GitHub style emoji\n   characters:\n\n  * Block Syntax Parser\n    * `const FencedCodeBlockSyntax()`\n    * `const HeaderWithIdSyntax()`, which adds `id` attributes to ATX-style\n      headers, for easy intra-document linking.\n    * `const SetextHeaderWithIdSyntax()`, which adds `id` attributes to\n      Setext-style headers, for easy intra-document linking.\n    * `const TableSyntax()`\n  \n  * Inline Syntax Parser\n    * `InlineHtmlSyntax()`\n    * `StrikethroughSyntax()`\n    * `EmojiSyntax()`\n    * `AutolinkExtensionSyntax()`\n\n### Custom syntax extensions\n\nYou can create and use your own syntaxes.\n\n```dart\nimport 'package:markdown/markdown.dart';\n\nvoid main() {\n  var syntaxes = [TextSyntax('nyan', sub: '~=[,,_,,]:3')];\n  print(markdownToHtml('nyan', inlineSyntaxes: syntaxes));\n  //=\u003e \u003cp\u003e~=[,,_,,]:3\u003c/p\u003e\n}\n```\n\n### HTML sanitization\n\nThis package offers no features in the way of HTML sanitization. Read Estevão\nSoares dos Santos's great article, [\"Markdown's XSS Vulnerability (and how to\nmitigate it)\"], to learn more.\n\nThe authors recommend that you perform any necessary sanitization on the\nresulting HTML, for example via `dart:html`'s [NodeValidator].\n\n### CommonMark compliance\n\nThis package contains a number of files in the `tool` directory for tracking\ncompliance with [CommonMark].\n\n#### Updating CommonMark stats when changing the implementation\n\n 1. Update the library and test code, making sure that tests still pass.\n 2. Run `dart run tool/stats.dart --update-files` to update the\n    per-test results `tool/common_mark_stats.json` and the test summary\n    `tool/common_mark_stats.txt`.\n 3. Verify that more tests now pass – or at least, no more tests fail.\n 4. Make sure you include the updated stats files in your commit.\n\n#### Updating the CommonMark test file for a spec update\n\n 1. Check out the [CommonMark source]. Make sure you checkout a *major* release.\n 2. Dump the test output overwriting the existing tests file.\n\n    ```console\n    \u003e cd /path/to/common_mark_dir\n    \u003e python3 test/spec_tests.py --dump-tests \u003e \\\n      /path/to/markdown.dart/tool/common_mark_tests.json\n    ```\n\n 3. Update the stats files as described above. Note any changes in the results.\n 4. Update any references to the existing spec by search for\n    `https://spec.commonmark.org/0.30/` in the repository. (Including this one.)\n    Verify the updated links are still valid.\n 5. Commit changes, including a corresponding note in `CHANGELOG.md`.\n\n[Perl Markdown]: https://daringfireball.net/projects/markdown/\n[CommonMark]: https://commonmark.org/\n[commonMark-raw-html]: https://spec.commonmark.org/0.30/#raw-html\n[CommonMark source]: https://github.com/commonmark/commonmark-spec\n[GitHub Flavored]: https://github.github.io/gfm/\n[pandoc-auto_identifiers]: https://pandoc.org/MANUAL.html#extension-auto_identifiers\n[\"Markdown's XSS Vulnerability (and how to mitigate it)\"]: https://github.com/showdownjs/showdown/wiki/Markdown%27s-XSS-Vulnerability-(and-how-to-mitigate-it)\n[NodeValidator]: https://api.dart.dev/stable/dart-html/NodeValidator-class.html\n","funding_links":[],"categories":["Parsers","解析器","Libraries"],"sub_categories":["Parsers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdart-lang%2Fmarkdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdart-lang%2Fmarkdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdart-lang%2Fmarkdown/lists"}