{"id":32297665,"url":"https://github.com/dikmax/mdown","last_synced_at":"2025-10-23T04:46:13.816Z","repository":{"id":20094761,"uuid":"23364164","full_name":"dikmax/mdown","owner":"dikmax","description":"Fast CommonMark-compliant Markdown parser.","archived":false,"fork":false,"pushed_at":"2019-07-01T20:12:57.000Z","size":1211,"stargazers_count":20,"open_issues_count":1,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T04:45:50.163Z","etag":null,"topics":["commonmark","dart","markdown","markdown-parser"],"latest_commit_sha":null,"homepage":"https://pub.dartlang.org/packages/md_proc","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/dikmax.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}},"created_at":"2014-08-26T19:32:10.000Z","updated_at":"2023-09-08T16:50:08.000Z","dependencies_parsed_at":"2022-08-05T07:00:25.021Z","dependency_job_id":null,"html_url":"https://github.com/dikmax/mdown","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/dikmax/mdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikmax%2Fmdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikmax%2Fmdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikmax%2Fmdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikmax%2Fmdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dikmax","download_url":"https://codeload.github.com/dikmax/mdown/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dikmax%2Fmdown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280563533,"owners_count":26351731,"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-10-23T02:00:06.710Z","response_time":142,"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":["commonmark","dart","markdown","markdown-parser"],"created_at":"2025-10-23T04:46:08.706Z","updated_at":"2025-10-23T04:46:13.811Z","avatar_url":"https://github.com/dikmax.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"mdown\n=====\n\n[![Build Status](https://travis-ci.org/dikmax/mdown.svg?branch=master)](https://travis-ci.org/dikmax/mdown)\n[![codecov](https://codecov.io/gh/dikmax/mdown/branch/master/graph/badge.svg)](https://codecov.io/gh/dikmax/mdown)\n[![Pub](https://img.shields.io/pub/v/mdown.svg)](https://pub.dartlang.org/packages/mdown)\n[![CommonMark spec](https://img.shields.io/badge/commonmark-0.28-green.svg)](http://spec.commonmark.org/)\n\n***mdown*** is fast and [CommonMark][]-compliant Markdown parser.\n\nBasic usage:\n\n```dart\nprint(markdownToHtml('# Hello world!'));\n```\n\nProject main goal is create processing library for Markdown.\n\nPerformance\n===========\n\nAs there are not many Markdown parsers written in Dart out there,\nparsing speed is compared with markdown package. [Progit][] was used as\na source of markdown files in different languages. ***mdown*** appears\nto be **3** times faster in **VM**, **11** times faster\nin **Chrome**, **2.2** times faster in **Safari** and **3.7** times\nfaster in **Firefox**.\n\n[Run benchmarks yourself or see details.](https://github.com/dikmax/mdown-benchmark)\n\n***mdown*** make extensive use of `String.codeUnitAt` instead\nof `RegExp`. So you can see noticeable gain for non-latin languages\n(up to \u0026times;38 in Chrome for Japan language).\n\nExtensions\n==========\n\n***mdown*** supports some language extensions. You can specify enabled\nextensions using options parameter in `markdownToHtml`.\n\n```dart\nOptions options = const Options(superscript: true);\nString res = markdownToHtml('Hello world!\\n===', options);\n```\n\nThere three predefined sets of options:\n\n- `Options.strict`: all extensions, except `rawHtml` are disabled\n- `Options.commonmark`: only `smartPunctuation` and `rawHtml` extension\n  are enabled.\n- `Options.gfm`: `rawHtml`, `tagFilter`, `pipeTables`.\n- `Options.defaults`: `smartPunctuation`, `strikeout`, `subscript`,\n  `superscript`, `pipeTables`, `texMathDollars`, `rawTex`, `rawHtml`\n  are enabled.\n\nTo get correspondent parser/writer instance use static getter on class:\n\n```dart\nString res = markdownToHtml('Hello world!\\n===', Options.strict);\n```\n\nIf second parameter is not provided, `Options.defaults` is used.\n\nRaw HTML (`Options.rawHtml`)\n----------------------------\n\nAllows to include raw HTML blocks. Official CommonMark extension.\n\nTag filter (`Options.tagFilter`)\n--------------------------------\n\nFilters `\u003ctextarea\u003e`, `\u003cstyle\u003e`, `\u003cxmp\u003e`, `\u003ciframe\u003e`, `\u003cnoembed\u003e`,\n`\u003cnoframes\u003e`, `\u003cscript\u003e`, `\u003cplaintext\u003e` from HTML output. Works together\nwith `Options.rawHtml`. Part of [GitHub Flavored Markdown][gfm].\n\nSmart punctuation (`Options.smartPunctuation`)\n----------------------------------------------\n\nSmart punctuation is automatic replacement of `...`, `---`, `--`, `\"`\nand `'` to \"…\", \"—\", \"–\" and curly versions of quote marks accordingly.\nIt's only official extension to date.\n\n**NOTE:** This extension uses Unicode chars. Make sure that your code\nsupports it.\n\n\nExtended attributes for fenced code (`Options.fencedCodeAttributes`)\n--------------------------------------------------------------------\n\nAllows fenced code block to have arbitrary extended attributes.\n\n``````md\n``` {#someId .class1 .class2 key=value}\ncode\n```\n``````\n\nThis will be rendered in HTML as\n\n```html\n\u003cpre id=\"someId\" class=\"class1 class2\" key=\"value\"\u003e\u003ccode\u003ecode\n\u003c/code\u003e\u003c/pre\u003e\n```\n\n\nExtended attributes for headings (`Options.headingAttributes`)\n--------------------------------------------------------------\n\nAllows headings to have arbitrary extended attributes.\n\n``````md\n# Heading 1 {#someId}\n\nHeading 2 {.someClass}\n-------------------\n``````\n\nThis will be rendered in HTML as\n\n```html\n\u003ch1 id=\"someId\"\u003eHeading 1\u003c/h1\u003e\n\u003ch2 class=\"someClass\"\u003eHeading 2\u003c/h2\u003e\n```\n\n\nExtended attributes for inline code (`Options.inlineCodeAttributes`)\n--------------------------------------------------------------------\n\nAdds extended attributes support to inline code.\n\n``````md\n`code`{#id .class key='value'}\n``````\n\nExtended attributes for links and images (`Options.linkAttributes`)\n-------------------------------------------------------------------\n\nExtended attributes for links and images. Both inline and reference\nlinks are supported.\n\n``````md\n![](image.jpg){width=\"800\" height=\"600\"}\n\n[test][ref]\n\n[ref]: http://test.com/ {#id}\n``````\n\nThis will be transformed into:\n\n``````html\n\u003cp\u003e\u003cimg src=\"image.jpg\" alt=\"\" width=\"800\" height=\"600\" /\u003e\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"http://test.com/\" id=\"id\"\u003etest\u003c/a\u003e\u003c/p\u003e\n``````\n\nStrikeout (`Options.strikeout`)\n-------------------------------\n\nStrikeouts text (~~like this~~). Just wrap text with double tildes (`~~`).\n\n```md\nStrikeouts text (~~like this~~).\n```\n\n\nSubscript (`Options.subscript`)\n-------------------------------\n\nSupport for subscript (H\u003csub\u003e2\u003c/sub\u003eO). Wrap text with tildes (`~`).\n\n```md\nH~2~O\n```\n\nSubscript couldn't contain spaces. If you need to insert space into the\nsubscript, escape space (`\\ `).\n\n```md\nsubscript~with\\ spaces~\n```\n\n\nSuperscript (`Options.superscript`)\n-----------------------------------\n\nSupport for superscript (2\u003csup\u003e2\u003c/sup\u003e=4). Wrap text with carets (`^`).\n\n```md\n2^2^=4\n```\n\nSuperscript couldn't contain spaces. If you need to insert space into\nsuperscript, escape space (`\\ `).\n\n```md\nsuperscript^with\\ spaces^\n```\n\n\nPipe tables (`Options.pipeTables`)\n----------------------------------\n\nAllows to parse tables where cells are separated with vertical bars\n(`|`). Compatible with [GitHub table syntax][gfm].\n\n```md\nhead | cells\n-----|------\nbody | cells\nmore | cells\n```\n\nAlso supports cells alignment.\n\n```md\n:----|:-----:|----:\nleft aligned | center aligned | right aligned\n```\n\n\nTeX Math between dollars (`Options.texMathDollars`)\n---------------------------------------------------\n\nAnything between two `$` characters will be treated as inline TeX math.\nThe opening `$` must have a non-space character immediately to its\nright, while the closing `$` must have a non-space character immediately\nto its left, and must not be followed immediately by a digit. Thus,\n`$20,000 and $30,000` won’t parse as math. If for some reason you need\nto enclose text in literal `$` characters, backslash-escape them and\nthey won’t be treated as math delimiters.\n\nAnything between two `$$` will be treated as display TeX math.\n\nHTML writer generates markup for [MathJax][] library. I.e. wraps content\nwith `\\(...\\)` or `\\[...\\]` and additionally wraps it with\n`\u003cspan class=\"math inline\"\u003e` or `\u003cspan class=\"math display\"\u003e`. If you\nneed custom classes for `span` you can override them with\n`Options.inlineTexMathClasses` and `Options.displayTexMathClasses`.\n\n\nTeX Math between backslashed `()` or `[]` (`Options.texMathSingleBackslash`)\n----------------------------------------------------------------------------\n\nCauses anything between `\\(` and `\\)` to be interpreted as inline TeX\nmath and anything between `\\[` and `\\]` to be interpreted as display\nTeX math.\n\n**NOTE 1:** This extension breaks escaping of `(` and `[]`.\n\n**NOTE 2:** This extension is disabled by default.\n\n\nTeX Math between double backslashed `()` or `[]` (`Options.texMathDoubleBackslash`)\n-----------------------------------------------------------------------------------\n\nCauses anything between `\\\\(` and `\\\\)` to be interpreted as inline TeX\nmath and anything between `\\\\[` and `\\\\]` to be interpreted as display\nTeX math.\n\n**NOTE:** This extension is disabled by default.\n\n\nRaw TeX (`Options.rawTex`)\n--------------------------\n\nAllows to include raw TeX blocks into documents. Right now only\nenvironment blocks are supported. Everything between `\\begin{...}` and\n`\\end{...}` is treated as TeX and passed into resulting HTML as is.\n\n\nCustom reference resolver\n-------------------------\n\nCustom reference resolver may be required when parsing document without\nimplicitly defined references, for example, Dartdoc.\n\n```dart\n/**\n * Throws a [StateError] if ...\n * similar to [anotherMethod], but ...\n */\n```\n\nIn that case, you could supply parser with the resolver, which should\nprovide all missing links.\n\n```dart\nimport 'package:mdown/mdown.dart';\nimport 'package:mdown/ast/standard_ast_factory.dart';\n\nString library = \"mdown\";\nString version = \"0.11.0\";\nTarget linkResolver(String normalizedReference, String reference) {\n  if (reference.startsWith(\"new \")) {\n    String className = reference.substring(4);\n    return astFactory.target(\n        \"http://www.dartdocs.org/documentation/$library/$version/index.html#$library/$library.$className@id_$className-\",\n        null);\n  } else {\n    return null;\n  }\n}\n\nString res = markdownToHtml('Hello world!\\n===', new Options(linkResolver: linkResolver));\n```\n\n[CommonMark]: http://commonmark.org/\n[gfm]: https://github.github.com/gfm/\n[MathJax]: https://www.mathjax.org/\n[Progit]: https://github.com/progit/progit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdikmax%2Fmdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdikmax%2Fmdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdikmax%2Fmdown/lists"}