{"name":"mdast-util-from-markdown","version":"1.0.0-beta.1","description":"mdast utility to parse markdown","license":"MIT","keywords":["unist","mdast","mdast-util","util","utility","markdown","markup","parse","syntax","tree","ast"],"repository":{"type":"git","url":"git+https://github.com/syntax-tree/mdast-util-from-markdown.git"},"bugs":{"url":"https://github.com/syntax-tree/mdast-util-from-markdown/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/unified"},"author":{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"},"contributors":[{"name":"Titus Wormer","email":"tituswormer@gmail.com","url":"https://wooorm.com"}],"sideEffects":false,"type":"module","main":"index.js","types":"index.d.ts","exports":{"development":"./dev/index.js","default":"./index.js"},"dependencies":{"@types/mdast":"^3.0.0","@types/unist":"^2.0.0","mdast-util-to-string":"^3.0.0","micromark":"^3.0.0-beta.1","micromark-util-decode-numeric-character-reference":"^1.0.0-beta.1","micromark-util-normalize-identifier":"^1.0.0-beta.1","micromark-util-symbol":"^1.0.0-beta.1","micromark-util-types":"^1.0.0-beta.1","parse-entities":"^3.0.0","unist-util-stringify-position":"^3.0.0"},"devDependencies":{"@types/tape":"^4.0.0","c8":"^7.0.0","commonmark.json":"^0.30.0","esbuild":"^0.12.0","gzip-size-cli":"^5.0.0","hast-util-to-html":"^8.0.0","mdast-util-to-hast":"^11.0.0","micromark-build":"^1.0.0-beta.1","prettier":"^2.0.0","rehype-parse":"^7.0.0","rehype-stringify":"^8.0.0","remark-cli":"^9.0.0","remark-preset-wooorm":"^8.0.0","rimraf":"^3.0.0","tape":"^5.0.0","terser":"^5.0.0","type-coverage":"^2.0.0","typescript":"^4.0.0","unified":"^9.0.0","xo":"^0.39.0"},"scripts":{"build":"rimraf \"dev/**/*.d.ts\" \"test/**/*.d.ts\" && tsc && type-coverage && micromark-build && esbuild . --bundle --minify | terser | gzip-size --raw","format":"remark . -qfo && prettier . -w --loglevel warn && xo --fix","test-api":"node --conditions development test/index.js","test-coverage":"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --conditions development test/index.js","test":"npm run build && npm run format && npm run test-coverage"},"prettier":{"tabWidth":2,"useTabs":false,"singleQuote":true,"bracketSpacing":false,"semi":false,"trailingComma":"none"},"xo":{"prettier":true,"rules":{"complexity":"off","unicorn/prefer-switch":"off"}},"remarkConfig":{"plugins":["preset-wooorm"]},"typeCoverage":{"atLeast":100,"detail":true,"strict":true,"ignoreCatch":true},"readme":"# mdast-util-from-markdown\n\n[![Build][build-badge]][build]\n[![Coverage][coverage-badge]][coverage]\n[![Downloads][downloads-badge]][downloads]\n[![Size][size-badge]][size]\n[![Sponsors][sponsors-badge]][collective]\n[![Backers][backers-badge]][collective]\n[![Chat][chat-badge]][chat]\n\n**[mdast][]** utility to parse markdown.\n\n## When to use this\n\nUse this if you want to use **[micromark][]** but need an AST.\nUse **[remark][]** instead, which includes both to provide a nice interface and\nhundreds of plugins.\n\n## Install\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):\nNode 12+ is needed to use it and it must be `import`ed instead of `require`d.\n\n[npm][]:\n\n```sh\nnpm install mdast-util-from-markdown\n```\n\n## Use\n\nSay we have the following markdown file, `example.md`:\n\n```markdown\n## Hello, *World*!\n```\n\nAnd our script, `example.js`, looks as follows:\n\n```js\nimport fs from 'node:fs'\nimport {fromMarkdown} from 'mdast-util-from-markdown'\n\nconst doc = fs.readFileSync('example.md')\n\nconst tree = fromMarkdown(doc)\n\nconsole.log(tree)\n```\n\nNow, running `node example` yields (positional info removed for brevity):\n\n```js\n{\n  type: 'root',\n  children: [\n    {\n      type: 'heading',\n      depth: 2,\n      children: [\n        {type: 'text', value: 'Hello, '},\n        {\n          type: 'emphasis',\n          children: [{type: 'text', value: 'World'}]\n        },\n        {type: 'text', value: '!'}\n      ]\n    }\n  ]\n}\n```\n\n## API\n\nThis package exports the following identifier: `fromMarkdown`.\nThere is no default export.\n\nThe export map supports the endorsed\n[`development` condition](https://nodejs.org/api/packages.html#packages_resolving_user_conditions).\nRun `node --conditions development module.js` to get instrumented dev code.\nWithout this condition, production code is loaded.\n\n### `fromMarkdown(doc[, encoding][, options])`\n\nParse markdown to a **[mdast][]** tree.\n\n##### Parameters\n\n###### `doc`\n\nValue to parse (`string` or [`Buffer`][buffer]).\n\n###### `encoding`\n\n[Character encoding][encoding] to understand `doc` as when it’s a\n[`Buffer`][buffer] (`string`, default: `'utf8'`).\n\n###### `options.extensions`\n\nArray of syntax extensions (`Array.<MicromarkSyntaxExtension>`, default: `[]`).\nPassed to [`micromark` as `extensions`][micromark-extensions].\n\n###### `options.mdastExtensions`\n\nArray of mdast extensions (`Array.<MdastExtension>`, default: `[]`).\n\n##### Returns\n\n[`Root`][root].\n\n## List of extensions\n\n*   [`syntax-tree/mdast-util-directive`](https://github.com/syntax-tree/mdast-util-directive)\n    — parse directives\n*   [`syntax-tree/mdast-util-footnote`](https://github.com/syntax-tree/mdast-util-footnote)\n    — parse footnotes\n*   [`syntax-tree/mdast-util-frontmatter`](https://github.com/syntax-tree/mdast-util-frontmatter)\n    — parse frontmatter (YAML, TOML, more)\n*   [`syntax-tree/mdast-util-gfm`](https://github.com/syntax-tree/mdast-util-gfm)\n    — parse GFM\n*   [`syntax-tree/mdast-util-gfm-autolink-literal`](https://github.com/syntax-tree/mdast-util-gfm-autolink-literal)\n    — parse GFM autolink literals\n*   [`syntax-tree/mdast-util-gfm-strikethrough`](https://github.com/syntax-tree/mdast-util-gfm-strikethrough)\n    — parse GFM strikethrough\n*   [`syntax-tree/mdast-util-gfm-table`](https://github.com/syntax-tree/mdast-util-gfm-table)\n    — parse GFM tables\n*   [`syntax-tree/mdast-util-gfm-task-list-item`](https://github.com/syntax-tree/mdast-util-gfm-task-list-item)\n    — parse GFM task list items\n*   [`syntax-tree/mdast-util-math`](https://github.com/syntax-tree/mdast-util-math)\n    — parse math\n*   [`syntax-tree/mdast-util-mdx`](https://github.com/syntax-tree/mdast-util-mdx)\n    — parse MDX or MDX.js\n*   [`syntax-tree/mdast-util-mdx-expression`](https://github.com/syntax-tree/mdast-util-mdx-expression)\n    — parse MDX or MDX.js expressions\n*   [`syntax-tree/mdast-util-mdx-jsx`](https://github.com/syntax-tree/mdast-util-mdx-jsx)\n    — parse MDX or MDX.js JSX\n*   [`syntax-tree/mdast-util-mdxjs-esm`](https://github.com/syntax-tree/mdast-util-mdxjs-esm)\n    — parse MDX.js ESM\n\n## Security\n\nAs markdown is sometimes used for HTML, and improper use of HTML can open you up\nto a [cross-site scripting (XSS)][xss] attack, use of `mdast-util-from-markdown`\ncan also be unsafe.\nWhen going to HTML, use this utility in combination with\n[`hast-util-sanitize`][sanitize] to make the tree safe.\n\n## Related\n\n*   [`micromark/micromark`](https://github.com/micromark/micromark)\n    — the smallest commonmark-compliant markdown parser that exists\n*   [`remarkjs/remark`](https://github.com/remarkjs/remark)\n    — markdown processor powered by plugins\n*   [`syntax-tree/mdast-util-to-markdown`](https://github.com/syntax-tree/mdast-util-to-markdown)\n    — serialize mdast to markdown\n\n## Contribute\n\nSee [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get\nstarted.\nSee [`support.md`][support] for ways to get help.\n\nThis project has a [code of conduct][coc].\nBy interacting with this repository, organization, or community you agree to\nabide by its terms.\n\n## License\n\n[MIT][license] © [Titus Wormer][author]\n\n<!-- Definitions -->\n\n[build-badge]: https://github.com/syntax-tree/mdast-util-from-markdown/workflows/main/badge.svg\n\n[build]: https://github.com/syntax-tree/mdast-util-from-markdown/actions\n\n[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/mdast-util-from-markdown.svg\n\n[coverage]: https://codecov.io/github/syntax-tree/mdast-util-from-markdown\n\n[downloads-badge]: https://img.shields.io/npm/dm/mdast-util-from-markdown.svg\n\n[downloads]: https://www.npmjs.com/package/mdast-util-from-markdown\n\n[size-badge]: https://img.shields.io/bundlephobia/minzip/mdast-util-from-markdown.svg\n\n[size]: https://bundlephobia.com/result?p=mdast-util-from-markdown\n\n[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg\n\n[backers-badge]: https://opencollective.com/unified/backers/badge.svg\n\n[collective]: https://opencollective.com/unified\n\n[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg\n\n[chat]: https://github.com/syntax-tree/unist/discussions\n\n[npm]: https://docs.npmjs.com/cli/install\n\n[license]: license\n\n[author]: https://wooorm.com\n\n[contributing]: https://github.com/syntax-tree/.github/blob/HEAD/contributing.md\n\n[support]: https://github.com/syntax-tree/.github/blob/HEAD/support.md\n\n[coc]: https://github.com/syntax-tree/.github/blob/HEAD/code-of-conduct.md\n\n[mdast]: https://github.com/syntax-tree/mdast\n\n[root]: https://github.com/syntax-tree/mdast#root\n\n[encoding]: https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings\n\n[buffer]: https://nodejs.org/api/buffer.html\n\n[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting\n\n[sanitize]: https://github.com/syntax-tree/hast-util-sanitize\n\n[micromark]: https://github.com/micromark/micromark\n\n[micromark-extensions]: https://github.com/micromark/micromark#optionsextensions\n\n[remark]: https://github.com/remarkjs/remark\n","readmeFilename":"readme.md","gitHead":"fefe843d067c43328fb08912b572ba65b858825c","homepage":"https://github.com/syntax-tree/mdast-util-from-markdown#readme","_id":"mdast-util-from-markdown@1.0.0-beta.1","_nodeVersion":"16.2.0","_npmVersion":"7.18.1","dist":{"integrity":"sha512-qc6ZvXr4HoQp1jY4vSp4aF2aVN22CdemMnqZeP9NGP3IVNOD0uw7r/SDUjBGKwLjEMe9bilfVwAl2v8g46gDMQ==","shasum":"2ca369a019bc366d1f53ed7a2e39a76eb875da3a","tarball":"http://registry-npm.ywwl.com/mdast-util-from-markdown/download/mdast-util-from-markdown-1.0.0-beta.1.tgz","fileCount":11,"unpackedSize":81279,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgz1mKCRA9TVsSAnZWagAAxekP/jWEMDq/stGm2ntlPoUP\ndZwL6L0nWbH8X77ExTQH3aBwtvgN+3r05TiqLzlCvwCOOg59biEmZg+KY0Lh\nv4tI3xyyrVBYGvid0XG6PetBvdhZ7FghKPzoc9NftaS6jbOPiE0W234wmIJu\nwpy5bCW49cOQGykdQuPywdx+5g+goAir2jUqGXrZZmA4QblFYodd9pyzDVL1\njPc8JY+dO4DW7YmQNL06sYNaThhX9eLlmvs6VrMfQqFByQIOa8apYAwEaFcf\nF16mW51yjuTPEqtc0UyVSQdtDxLmFRodqjoV8OEHXn2f1X7T6qrLpUjKy/PN\nytcT8t1QN0wwD2TZazeUwJv0uZcHidycatiGcAyhlwALdGcNN9od8f+owgC8\nI9EAM3jjT/sz+VcX4wQv/W5Fejz2318vbxJfHRQ+m0GTp3MXjwY2A4w4TCtP\nx+1BoAr1vA6/E5pQKHDWNlNRI+5herHOH/rOjjf2hEEpn68lxbmy1ZVhIdcN\n0Y1GYzJy9Z8JINTYfIX88LtraUf42Gjt7b4CidH1UgawIS6jApUdkdH1doc3\nt6XTPLDH47g/IROWI+jA9HgMXZ1tze50+k5uFQdqtC0lIzeWoiQnceZh+FU/\n9+Nn5JCs9OVrUCbU9OSCr5hjNWHUcCavQty4ILiTSKmbZkfuNJpNpftoTQFt\nH6b0\r\n=f/Qt\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEyTu+7toYN9LncyNzuwD5NX50OdFmE2viKdFucvxeQLAiA/2XE6tEH+3oQAF6q6HxUJy0XO4AJiFgMutt831fGxIQ=="}],"size":15526,"noattachment":false,"key":"/mdast-util-from-markdown/-/mdast-util-from-markdown-1.0.0-beta.1.tgz"},"_npmUser":{"name":"wooorm","email":"tituswormer@gmail.com"},"directories":{},"maintainers":[{"name":"wooorm","email":"tituswormer@gmail.com"},{"name":"kmck","email":"keith@mcknig.ht"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mdast-util-from-markdown_1.0.0-beta.1_1624201609627_0.9926337163445234"},"_hasShrinkwrap":false,"publish_time":1624201609781,"_cnpm_publish_time":1624201609781,"dist-tags":{"latest":"2.1.0","next":"1.0.0-beta.2"}}